refactor: upgrade masto 5 (#867)

This commit is contained in:
三咲智子 Kevin Deng 2023-01-08 14:21:09 +08:00 committed by GitHub
parent 39034c5777
commit 5c8f75b9b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
108 changed files with 438 additions and 445 deletions

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
square?: boolean
}>()

View file

@ -1,11 +1,11 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
// Avatar with a background base achieving a 3px border to be used in status cards
// The border is used for Avatar on Avatar for reblogs and connecting replies
defineProps<{
account: Account
account: mastodon.v1.Account
square?: boolean
}>()
</script>

View file

@ -1,7 +1,8 @@
<script lang="ts" setup>
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account, as = 'div' } = $defineProps<{
account: Account
account: mastodon.v1.Account
as?: string
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
hoverCard?: boolean
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
}>()
</script>

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Account, Relationship } from 'masto'
import type { mastodon } from 'masto'
const { account, command, ...props } = defineProps<{
account: Account
relationship?: Relationship
account: mastodon.v1.Account
relationship?: mastodon.v1.Relationship
command?: boolean
}>()
@ -15,7 +15,7 @@ const masto = useMasto()
async function toggleFollow() {
relationship!.following = !relationship!.following
try {
const newRel = await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
const newRel = await masto.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
Object.assign(relationship!, newRel)
}
catch {
@ -27,7 +27,7 @@ async function toggleFollow() {
async function unblock() {
relationship!.blocking = false
try {
const newRel = await masto.accounts.unblock(account.id)
const newRel = await masto.v1.accounts.unblock(account.id)
Object.assign(relationship!, newRel)
}
catch {
@ -39,7 +39,7 @@ async function unblock() {
async function unmute() {
relationship!.muting = false
try {
const newRel = await masto.accounts.unmute(account.id)
const newRel = await masto.v1.accounts.unmute(account.id)
Object.assign(relationship!, newRel)
}
catch {

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const serverName = $computed(() => getServerName(account))

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account, Field } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
command?: boolean
}>()
@ -14,8 +14,8 @@ const createdAt = $(useFormattedDateTime(() => account.createdAt, {
year: 'numeric',
}))
const namedFields = ref<Field[]>([])
const iconFields = ref<Field[]>([])
const namedFields = ref<mastodon.v1.AccountField[]>([])
const iconFields = ref<mastodon.v1.AccountField[]>([])
function getFieldIconTitle(fieldName: string) {
return fieldName === 'Joined' ? t('account.joined') : fieldName
@ -40,8 +40,8 @@ function previewAvatar() {
}
watchEffect(() => {
const named: Field[] = []
const icons: Field[] = []
const named: mastodon.v1.AccountField[] = []
const icons: mastodon.v1.AccountField[] = []
account.fields?.forEach((field) => {
const icon = getAccountFieldIcon(field.name)

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const relationship = $(useRelationship(account))

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const props = defineProps<{
account?: Account
account?: mastodon.v1.Account
handle?: string
disabled?: boolean
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account, as = 'div' } = defineProps<{
account: Account
account: mastodon.v1.Account
as?: string
hoverCard?: boolean
square?: boolean

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { link = true, avatar = true } = defineProps<{
account: Account
account: mastodon.v1.Account
link?: boolean
avatar?: boolean
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
command?: boolean
}>()
let relationship = $(useRelationship(account))
@ -15,24 +15,24 @@ const toggleMute = async () => {
relationship!.muting = !relationship!.muting
relationship = relationship!.muting
? await masto.accounts.mute(account.id, {
? await masto.v1.accounts.mute(account.id, {
// TODO support more options
})
: await masto.accounts.unmute(account.id)
: await masto.v1.accounts.unmute(account.id)
}
const toggleBlockUser = async () => {
// TODO: Add confirmation
relationship!.blocking = !relationship!.blocking
relationship = await masto.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
relationship = await masto.v1.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
}
const toggleBlockDomain = async () => {
// TODO: Add confirmation
relationship!.domainBlocking = !relationship!.domainBlocking
await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
await masto.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
}
</script>

View file

@ -1,10 +1,8 @@
<script setup lang="ts">
// type used in <template>
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
}>()
</script>
@ -16,9 +14,8 @@ defineProps<{
</div>
<div flex>
<!-- type error of masto.js -->
<NuxtLink :to="getAccountRoute(account.moved as unknown as Account)">
<AccountInfo :account="account.moved as unknown as Account" />
<NuxtLink :to="getAccountRoute(account.moved!)">
<AccountInfo :account="account.moved!" />
</NuxtLink>
<div flex-auto />
<div flex items-center>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account, Paginator } from 'masto'
import type { Paginator, mastodon } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Account[]>
paginator: Paginator<mastodon.v1.Account[], mastodon.DefaultPaginationParams>
}>()
</script>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const props = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()

View file

@ -12,7 +12,7 @@ const {
eventType = 'update',
preprocess,
} = defineProps<{
paginator: Paginator<any, any[]>
paginator: Paginator<any[], any>
keyProp?: string
virtualScroller?: boolean
stream?: Promise<WsEvents>

View file

@ -1,11 +1,11 @@
<script lang="ts" setup>
import type { History } from 'masto'
import type { mastodon } from 'masto'
const {
history,
maxDay = 2,
} = $defineProps<{
history: History[]
history: mastodon.v1.TagHistory[]
maxDay?: number
}>()

View file

@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { History } from 'masto'
import type { mastodon } from 'masto'
import sparkline from '@fnando/sparkline'
const {
@ -7,7 +7,7 @@ const {
width = 60,
height = 40,
} = $defineProps<{
history?: History[]
history?: mastodon.v1.TagHistory[]
width?: number
height?: number
}>()

View file

@ -1,4 +1,4 @@
import type { Emoji } from 'masto'
import type { mastodon } from 'masto'
defineOptions({
name: 'ContentRich',
@ -10,7 +10,7 @@ const {
markdown = true,
} = defineProps<{
content: string
emojis?: Emoji[]
emojis?: mastodon.v1.CustomEmoji[]
markdown?: boolean
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Conversation } from 'masto'
import type { mastodon } from 'masto'
const { conversation } = defineProps<{
conversation: Conversation
conversation: mastodon.v1.Conversation
}>()
const withAccounts = $computed(() =>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Conversation, Paginator } from 'masto'
import type { Paginator, mastodon } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Conversation[]>
paginator: Paginator<mastodon.v1.Conversation[], mastodon.DefaultPaginationParams>
}>()
</script>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Status } from 'masto'
import type { mastodon } from 'masto'
import type { ConfirmDialogChoice } from '~/types'
import {
isCommandPanelOpen,
@ -30,7 +30,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {
}
})
const handlePublished = (status: Status) => {
const handlePublished = (status: mastodon.v1.Status) => {
lastPublishDialogStatus.value = status
isPublishDialogOpen.value = false
}

View file

@ -1,10 +1,10 @@
<script setup lang="ts">
import { SwipeDirection } from '@vueuse/core'
import { useReducedMotion } from '@vueuse/motion'
import type { Attachment } from 'masto'
import type { mastodon } from 'masto'
const { media = [], threshold = 20 } = defineProps<{
media?: Attachment[]
media?: mastodon.v1.MediaAttachment[]
threshold?: number
}>()

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Notification } from 'masto'
import type { mastodon } from 'masto'
const { notification } = defineProps<{
notification: Notification
notification: mastodon.v1.Notification
}>()
</script>

View file

@ -1,20 +1,19 @@
<script setup lang="ts">
// type used in <template>
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type { Notification, Paginator, WsEvents } from 'masto'
import { mastodon } from 'masto'
import type { Paginator, WsEvents } from 'masto'
// type used in <template>
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type { GroupedAccountLike, GroupedLikeNotifications, NotificationSlot } from '~/types'
const { paginator, stream } = defineProps<{
paginator: Paginator<any, Notification[]>
paginator: Paginator<mastodon.v1.Notification[], mastodon.v1.ListNotificationsParams>
stream?: Promise<WsEvents>
}>()
const groupCapacity = Number.MAX_VALUE // No limit
// Group by type (and status when applicable)
const groupId = (item: Notification): string => {
const groupId = (item: mastodon.v1.Notification): string => {
// If the update is related to an status, group notifications from the same account (boost + favorite the same status)
const id = item.status
? {
@ -27,12 +26,12 @@ const groupId = (item: Notification): string => {
return JSON.stringify(id)
}
function groupItems(items: Notification[]): NotificationSlot[] {
function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
const results: NotificationSlot[] = []
let id = 0
let currentGroupId = ''
let currentGroup: Notification[] = []
let currentGroup: mastodon.v1.Notification[] = []
const processGroup = () => {
if (currentGroup.length === 0)
return
@ -127,7 +126,7 @@ const { formatNumber } = useHumanReadableNumber()
/>
<NotificationCard
v-else
:notification="item as Notification"
:notification="item as mastodon.v1.Notification"
hover:bg-active
border="b base"
/>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Attachment } from 'masto'
import type { mastodon } from 'masto'
const props = withDefaults(defineProps<{
attachment: Attachment
attachment: mastodon.v1.MediaAttachment
alt?: string
removable?: boolean
dialogLabelledBy?: string

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Attachment, CreateStatusParams, Status, StatusVisibility } from 'masto'
import type { mastodon } from 'masto'
import { fileOpen } from 'browser-fs-access'
import { useDropZone } from '@vueuse/core'
import { EditorContent } from '@tiptap/vue-3'
@ -18,13 +18,13 @@ const {
initial?: () => Draft
placeholder?: string
inReplyToId?: string
inReplyToVisibility?: StatusVisibility
inReplyToVisibility?: mastodon.v1.StatusVisibility
expanded?: boolean
dialogLabelledBy?: string
}>()
const emit = defineEmits<{
(evt: 'published', status: Status): void
(evt: 'published', status: mastodon.v1.Status): void
}>()
const { t } = useI18n()
@ -103,7 +103,7 @@ async function uploadAttachments(files: File[]) {
if (draft.attachments.length < limit) {
isExceedingAttachmentLimit = false
try {
const attachment = await masto.mediaAttachments.create({
const attachment = await masto.v1.mediaAttachments.create({
file,
})
draft.attachments.push(attachment)
@ -122,9 +122,9 @@ async function uploadAttachments(files: File[]) {
isUploading = false
}
async function setDescription(att: Attachment, description: string) {
async function setDescription(att: mastodon.v1.MediaAttachment, description: string) {
att.description = description
await masto.mediaAttachments.update(att.id, { description: att.description })
await masto.v1.mediaAttachments.update(att.id, { description: att.description })
}
function removeAttachment(index: number) {
@ -136,8 +136,8 @@ async function publish() {
...draft.params,
status: htmlToText(draft.params.status || ''),
mediaIds: draft.attachments.map(a => a.id),
...(masto.version.includes('+glitch') ? { 'content-type': 'text/markdown' } : {}),
} as CreateStatusParams
...((masto.config as any).props.version.raw.includes('+glitch') ? { 'content-type': 'text/markdown' } : {}),
} as mastodon.v1.CreateStatusParams
if (process.dev) {
// eslint-disable-next-line no-console
@ -154,11 +154,11 @@ async function publish() {
try {
isSending = true
let status: Status
let status: mastodon.v1.Status
if (!draft.editingStatus)
status = await masto.statuses.create(payload)
status = await masto.v1.statuses.create(payload)
else
status = await masto.statuses.update(draft.editingStatus.id, payload)
status = await masto.v1.statuses.update(draft.editingStatus.id, payload)
if (draft.params.inReplyToId)
navigateToStatus({ status })

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
}>()
</script>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Tag } from 'masto'
import type { mastodon } from 'masto'
const { hashtag } = defineProps<{
hashtag: Tag
hashtag: mastodon.v1.Tag
}>()
const totalTrend = $computed(() =>

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import type { UpdateCredentialsParams } from 'masto'
import type { mastodon } from 'masto'
const { form } = defineModel<{
form: {
fieldsAttributes: NonNullable<UpdateCredentialsParams['fieldsAttributes']>
fieldsAttributes: NonNullable<mastodon.v1.UpdateCredentialsParams['fieldsAttributes']>
}
}>()
const dropdown = $ref<any>()

View file

@ -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>

View file

@ -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
}>()

View file

@ -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

View file

@ -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
}>()

View file

@ -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
}>()

View file

@ -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

View file

@ -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')

View file

@ -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
}>(), {

View file

@ -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>

View file

@ -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)

View file

@ -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',

View file

@ -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 */

View file

@ -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'

View file

@ -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
}>()

View file

@ -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()

View file

@ -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
}>()

View file

@ -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>

View file

@ -1,21 +1,21 @@
<script setup lang="ts">
import type { Tag } from 'masto'
import type { mastodon } from 'masto'
const { tag } = defineProps<{
tag: Tag
tag: mastodon.v1.Tag
}>()
const emit = defineEmits<{
(event: 'change'): void
}>()
const { tags } = useMasto()
const masto = useMasto()
const toggleFollowTag = async () => {
if (tag.following)
await tags.unfollow(tag.name)
await masto.v1.tags.unfollow(tag.name)
else
await tags.follow(tag.name)
await masto.v1.tags.follow(tag.name)
emit('change')
}

View file

@ -1,10 +1,10 @@
<script lang="ts" setup>
import type { Tag } from 'masto'
import type { mastodon } from 'masto'
const {
tag,
} = $defineProps<{
tag: Tag
tag: mastodon.v1.Tag
}>()
const to = $computed(() => new URL(tag.url).pathname)

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().blocks.iterate()
const paginator = useMasto().v1.blocks.list()
</script>
<template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().bookmarks.iterate()
const paginator = useMasto().v1.bookmarks.list()
</script>
<template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().conversations.iterate()
const paginator = useMasto().v1.conversations.list()
</script>
<template>

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
const masto = useMasto()
const paginator = masto.domainBlocks.iterate()
const paginator = masto.v1.domainBlocks.list()
const unblock = async (domain: string) => {
await masto.domainBlocks.unblock(domain)
await masto.v1.domainBlocks.unblock(domain)
}
</script>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().favourites.iterate()
const paginator = useMasto().v1.favourites.list()
</script>
<template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
const paginator = useMasto().timelines.iterateHome()
const stream = useMasto().stream.streamUser()
const paginator = useMasto().v1.timelines.listHome()
const stream = useMasto().v1.stream.streamUser()
onBeforeUnmount(() => stream?.then(s => s.disconnect()))
</script>

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Status } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
timelines: Status[]
timelines: mastodon.v1.Status[]
}>()
</script>

View file

@ -1,11 +1,11 @@
<script setup lang="ts">
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMasto().notifications.iterate({ limit: 30, types: ['mention'] })
const paginator = useMasto().v1.notifications.list({ limit: 30, types: ['mention'] })
const { clearNotifications } = useNotifications()
onActivated(clearNotifications)
const stream = useMasto().stream.streamUser()
const stream = useMasto().v1.stream.streamUser()
</script>
<template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().mutes.iterate()
const paginator = useMasto().v1.mutes.list()
</script>
<template>

View file

@ -1,11 +1,11 @@
<script setup lang="ts">
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMasto().notifications.iterate({ limit: 30 })
const paginator = useMasto().v1.notifications.list({ limit: 30 })
const { clearNotifications } = useNotifications()
onActivated(clearNotifications)
const stream = useMasto().stream.streamUser()
const stream = useMasto().v1.stream.streamUser()
</script>
<template>

View file

@ -2,13 +2,13 @@
// @ts-expect-error missing types
import { DynamicScrollerItem } from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import type { Account, FilterContext, Paginator, Status, WsEvents } from 'masto'
import type { Paginator, WsEvents, mastodon } from 'masto'
const { paginator, stream, account } = defineProps<{
paginator: Paginator<any, Status[]>
paginator: Paginator<mastodon.v1.Status[], mastodon.v1.ListAccountStatusesParams>
stream?: Promise<WsEvents>
context?: FilterContext
account?: Account
context?: mastodon.v2.FilterContext
account?: mastodon.v1.Account
preprocess?: (items: any[]) => any[]
}>()

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const paginator = useMasto().accounts.iterateStatuses(currentUser.value!.account.id, { pinned: true })
const paginator = useMasto().v1.accounts.listStatuses(currentUser.value!.account.id, { pinned: true })
</script>
<template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
const paginator = useMasto().timelines.iteratePublic()
const stream = useMasto().stream.streamPublicTimeline()
const paginator = useMasto().v1.timelines.listPublic()
const stream = useMasto().v1.stream.streamPublicTimeline()
onBeforeUnmount(() => stream.then(s => s.disconnect()))
</script>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
const paginator = useMasto().timelines.iteratePublic({ local: true })
const stream = useMasto().stream.streamCommunityTimeline()
const paginator = useMasto().v1.timelines.listPublic({ local: true })
const stream = useMasto().v1.stream.streamCommunityTimeline()
onBeforeUnmount(() => stream.then(s => s.disconnect()))
</script>

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Tag } from 'masto'
import type { mastodon } from 'masto'
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
const { items, command } = defineProps<{
items: Tag[]
items: mastodon.v1.Tag[]
command: Function
isPending?: boolean
}>()

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
const { items, command } = defineProps<{
items: Account[]
items: mastodon.v1.Account[]
command: Function
isPending?: boolean
}>()