refactor: upgrade masto 5 (#867)
This commit is contained in:
parent
39034c5777
commit
5c8f75b9b7
108 changed files with 438 additions and 445 deletions
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Account } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { account, link = true } = defineProps<{
|
||||
account: Account
|
||||
account: mastodon.v1.Account
|
||||
link?: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
details?: boolean
|
||||
command?: boolean
|
||||
}>()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
details?: boolean
|
||||
command?: boolean
|
||||
}>()
|
||||
|
@ -40,21 +40,21 @@ const toggleTranslation = async () => {
|
|||
|
||||
const masto = useMasto()
|
||||
|
||||
const getPermalinkUrl = (status: Status) => {
|
||||
const getPermalinkUrl = (status: mastodon.v1.Status) => {
|
||||
const url = getStatusPermalinkRoute(status)
|
||||
if (url)
|
||||
return `${location.origin}/${url}`
|
||||
return null
|
||||
}
|
||||
|
||||
const copyLink = async (status: Status) => {
|
||||
const copyLink = async (status: mastodon.v1.Status) => {
|
||||
const url = getPermalinkUrl(status)
|
||||
if (url)
|
||||
await clipboard.copy(url)
|
||||
}
|
||||
|
||||
const { share, isSupported: isShareSupported } = useShare()
|
||||
const shareLink = async (status: Status) => {
|
||||
const shareLink = async (status: mastodon.v1.Status) => {
|
||||
const url = getPermalinkUrl(status)
|
||||
if (url)
|
||||
await share({ url })
|
||||
|
@ -69,7 +69,7 @@ const deleteStatus = async () => {
|
|||
return
|
||||
|
||||
removeCachedStatus(status.id)
|
||||
await masto.statuses.remove(status.id)
|
||||
await masto.v1.statuses.remove(status.id)
|
||||
|
||||
if (route.name === 'status')
|
||||
router.back()
|
||||
|
@ -87,7 +87,7 @@ const deleteAndRedraft = async () => {
|
|||
}
|
||||
|
||||
removeCachedStatus(status.id)
|
||||
await masto.statuses.remove(status.id)
|
||||
await masto.v1.statuses.remove(status.id)
|
||||
await openPublishDialog('dialog', await getDraftFromStatus(status), true)
|
||||
|
||||
// Go to the new status, if the page is the old status
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<script setup lang="ts">
|
||||
import { clamp } from '@vueuse/core'
|
||||
import type { Attachment } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const {
|
||||
attachment,
|
||||
fullSize = false,
|
||||
} = defineProps<{
|
||||
attachment: Attachment
|
||||
attachments?: Attachment[]
|
||||
attachment: mastodon.v1.MediaAttachment
|
||||
attachments?: mastodon.v1.MediaAttachment[]
|
||||
fullSize?: boolean
|
||||
}>()
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status, StatusEdit } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const {
|
||||
status,
|
||||
withAction = true,
|
||||
} = defineProps<{
|
||||
status: Status | StatusEdit
|
||||
status: mastodon.v1.Status | mastodon.v1.StatusEdit
|
||||
withAction?: boolean
|
||||
}>()
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<script setup lang="ts">
|
||||
import type { FilterContext, Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
actions?: boolean
|
||||
context?: FilterContext
|
||||
context?: mastodon.v2.FilterContext
|
||||
hover?: boolean
|
||||
faded?: boolean
|
||||
|
||||
// If we know the prev and next status in the timeline, we can simplify the card
|
||||
older?: Status
|
||||
newer?: Status
|
||||
older?: mastodon.v1.Status
|
||||
newer?: mastodon.v1.Status
|
||||
// Manual overrides
|
||||
hasOlder?: boolean
|
||||
hasNewer?: boolean
|
||||
// When looking into a detailed view of a post, we can simplify the replying badges
|
||||
// to the main expanded post
|
||||
main?: Status
|
||||
main?: mastodon.v1.Status
|
||||
}>(),
|
||||
{ actions: true },
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
|
|||
|
||||
// Content Filter logic
|
||||
const filterResult = $computed(() => status.filtered?.length ? status.filtered[0] : null)
|
||||
const filter = $computed(() => filterResult?.filter)
|
||||
const filter = $computed(() => filterResult?.filter as mastodon.v2.Filter)
|
||||
|
||||
// a bit of a hack due to Filter being different in v1 and v2
|
||||
// clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import type { FilterContext, Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { status, context } = defineProps<{
|
||||
status: Status
|
||||
context?: FilterContext | 'details'
|
||||
status: mastodon.v1.Status
|
||||
context?: mastodon.v2.FilterContext | 'details'
|
||||
}>()
|
||||
|
||||
const isDM = $computed(() => status.visibility === 'direct')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
command?: boolean
|
||||
actions?: boolean
|
||||
}>(), {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status, StatusEdit } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { status } = defineProps<{
|
||||
status: Status | StatusEdit
|
||||
status: mastodon.v1.Status | mastodon.v1.StatusEdit
|
||||
fullSize?: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { status } = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
}>()
|
||||
const poll = reactive({ ...status.poll! })
|
||||
|
||||
|
@ -30,7 +30,7 @@ async function vote(e: Event) {
|
|||
poll.votersCount = (poll.votersCount || 0) + 1
|
||||
cacheStatus({ ...status, poll }, undefined, true)
|
||||
|
||||
await masto.poll.vote(poll.id, { choices })
|
||||
await masto.v1.polls.vote(poll.id, { choices })
|
||||
}
|
||||
|
||||
const votersCount = $computed(() => poll.votersCount ?? 0)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Card, CardType } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = defineProps<{
|
||||
card: Card
|
||||
card: mastodon.v1.PreviewCard
|
||||
/** For the preview image, only the small image mode is displayed */
|
||||
smallPictureOnly?: boolean
|
||||
/** When it is root card in the list, not appear as a child card */
|
||||
|
@ -24,7 +24,7 @@ const providerName = $computed(() => props.card.providerName ? props.card.provid
|
|||
const gitHubCards = $(useFeatureFlag('experimentalGitHubCards'))
|
||||
|
||||
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
||||
const cardTypeIconMap: Record<CardType, string> = {
|
||||
const cardTypeIconMap: Record<mastodon.v1.PreviewCardType, string> = {
|
||||
link: 'i-ri:profile-line',
|
||||
photo: 'i-ri:image-line',
|
||||
video: 'i-ri:play-line',
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Card } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
defineProps<{
|
||||
card: Card
|
||||
card: mastodon.v1.PreviewCard
|
||||
/** When it is root card in the list, not appear as a child card */
|
||||
root?: boolean
|
||||
/** For the preview image, only the small image mode is displayed */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Card } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const props = defineProps<{
|
||||
card: Card
|
||||
card: mastodon.v1.PreviewCard
|
||||
}>()
|
||||
|
||||
type UrlType = 'user' | 'repo' | 'issue' | 'pull'
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { status, collapsed = false, simplified = false } = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
collapsed?: boolean
|
||||
simplified?: boolean
|
||||
}>()
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status, StatusEdit } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
import { formatTimeAgo } from '@vueuse/core'
|
||||
|
||||
const { status } = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
}>()
|
||||
|
||||
const masto = useMasto()
|
||||
const { data: statusEdits } = useAsyncData(`status:history:${status.id}`, () => masto.statuses.fetchHistory(status.id).then(res => res.reverse()))
|
||||
const { data: statusEdits } = useAsyncData(`status:history:${status.id}`, () => masto.v1.statuses.listHistory(status.id).then(res => res.reverse()))
|
||||
|
||||
const showHistory = (edit: StatusEdit) => {
|
||||
const showHistory = (edit: mastodon.v1.StatusEdit) => {
|
||||
openEditHistoryDialog(edit)
|
||||
}
|
||||
const timeAgoOptions = useTimeAgoOptions()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { Status } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { status } = defineProps<{
|
||||
status: Status
|
||||
status: mastodon.v1.Status
|
||||
inline: boolean
|
||||
}>()
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import type { StatusEdit } from 'masto'
|
||||
import type { mastodon } from 'masto'
|
||||
|
||||
const { edit } = defineProps<{
|
||||
edit: StatusEdit
|
||||
edit: mastodon.v1.StatusEdit
|
||||
}>()
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue