mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-22 01:15:25 +03:00
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">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
square?: boolean
|
square?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script setup lang="ts">
|
<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
|
// 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
|
// The border is used for Avatar on Avatar for reblogs and connecting replies
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
square?: boolean
|
square?: boolean
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account, as = 'div' } = $defineProps<{
|
const { account, as = 'div' } = $defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
as?: string
|
as?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
hoverCard?: boolean
|
hoverCard?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account, Relationship } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account, command, ...props } = defineProps<{
|
const { account, command, ...props } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
relationship?: Relationship
|
relationship?: mastodon.v1.Relationship
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ const masto = useMasto()
|
||||||
async function toggleFollow() {
|
async function toggleFollow() {
|
||||||
relationship!.following = !relationship!.following
|
relationship!.following = !relationship!.following
|
||||||
try {
|
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)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
@ -27,7 +27,7 @@ async function toggleFollow() {
|
||||||
async function unblock() {
|
async function unblock() {
|
||||||
relationship!.blocking = false
|
relationship!.blocking = false
|
||||||
try {
|
try {
|
||||||
const newRel = await masto.accounts.unblock(account.id)
|
const newRel = await masto.v1.accounts.unblock(account.id)
|
||||||
Object.assign(relationship!, newRel)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
@ -39,7 +39,7 @@ async function unblock() {
|
||||||
async function unmute() {
|
async function unmute() {
|
||||||
relationship!.muting = false
|
relationship!.muting = false
|
||||||
try {
|
try {
|
||||||
const newRel = await masto.accounts.unmute(account.id)
|
const newRel = await masto.v1.accounts.unmute(account.id)
|
||||||
Object.assign(relationship!, newRel)
|
Object.assign(relationship!, newRel)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const serverName = $computed(() => getServerName(account))
|
const serverName = $computed(() => getServerName(account))
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account, Field } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const createdAt = $(useFormattedDateTime(() => account.createdAt, {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const namedFields = ref<Field[]>([])
|
const namedFields = ref<mastodon.v1.AccountField[]>([])
|
||||||
const iconFields = ref<Field[]>([])
|
const iconFields = ref<mastodon.v1.AccountField[]>([])
|
||||||
|
|
||||||
function getFieldIconTitle(fieldName: string) {
|
function getFieldIconTitle(fieldName: string) {
|
||||||
return fieldName === 'Joined' ? t('account.joined') : fieldName
|
return fieldName === 'Joined' ? t('account.joined') : fieldName
|
||||||
|
@ -40,8 +40,8 @@ function previewAvatar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
const named: Field[] = []
|
const named: mastodon.v1.AccountField[] = []
|
||||||
const icons: Field[] = []
|
const icons: mastodon.v1.AccountField[] = []
|
||||||
|
|
||||||
account.fields?.forEach((field) => {
|
account.fields?.forEach((field) => {
|
||||||
const icon = getAccountFieldIcon(field.name)
|
const icon = getAccountFieldIcon(field.name)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const relationship = $(useRelationship(account))
|
const relationship = $(useRelationship(account))
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
account?: Account
|
account?: mastodon.v1.Account
|
||||||
handle?: string
|
handle?: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account, as = 'div' } = defineProps<{
|
const { account, as = 'div' } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
as?: string
|
as?: string
|
||||||
hoverCard?: boolean
|
hoverCard?: boolean
|
||||||
square?: boolean
|
square?: boolean
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { link = true, avatar = true } = defineProps<{
|
const { link = true, avatar = true } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
link?: boolean
|
link?: boolean
|
||||||
avatar?: boolean
|
avatar?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
let relationship = $(useRelationship(account))
|
let relationship = $(useRelationship(account))
|
||||||
|
@ -15,24 +15,24 @@ const toggleMute = async () => {
|
||||||
|
|
||||||
relationship!.muting = !relationship!.muting
|
relationship!.muting = !relationship!.muting
|
||||||
relationship = relationship!.muting
|
relationship = relationship!.muting
|
||||||
? await masto.accounts.mute(account.id, {
|
? await masto.v1.accounts.mute(account.id, {
|
||||||
// TODO support more options
|
// TODO support more options
|
||||||
})
|
})
|
||||||
: await masto.accounts.unmute(account.id)
|
: await masto.v1.accounts.unmute(account.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleBlockUser = async () => {
|
const toggleBlockUser = async () => {
|
||||||
// TODO: Add confirmation
|
// TODO: Add confirmation
|
||||||
|
|
||||||
relationship!.blocking = !relationship!.blocking
|
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 () => {
|
const toggleBlockDomain = async () => {
|
||||||
// TODO: Add confirmation
|
// TODO: Add confirmation
|
||||||
|
|
||||||
relationship!.domainBlocking = !relationship!.domainBlocking
|
relationship!.domainBlocking = !relationship!.domainBlocking
|
||||||
await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
|
await masto.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// type used in <template>
|
import type { mastodon } from 'masto'
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
||||||
import type { Account } from 'masto'
|
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -16,9 +14,8 @@ defineProps<{
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div flex>
|
<div flex>
|
||||||
<!-- type error of masto.js -->
|
<NuxtLink :to="getAccountRoute(account.moved!)">
|
||||||
<NuxtLink :to="getAccountRoute(account.moved as unknown as Account)">
|
<AccountInfo :account="account.moved!" />
|
||||||
<AccountInfo :account="account.moved as unknown as Account" />
|
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div flex-auto />
|
<div flex-auto />
|
||||||
<div flex items-center>
|
<div flex items-center>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account, Paginator } from 'masto'
|
import type { Paginator, mastodon } from 'masto'
|
||||||
|
|
||||||
const { paginator } = defineProps<{
|
const { paginator } = defineProps<{
|
||||||
paginator: Paginator<any, Account[]>
|
paginator: Paginator<mastodon.v1.Account[], mastodon.DefaultPaginationParams>
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
|
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ const {
|
||||||
eventType = 'update',
|
eventType = 'update',
|
||||||
preprocess,
|
preprocess,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
paginator: Paginator<any, any[]>
|
paginator: Paginator<any[], any>
|
||||||
keyProp?: string
|
keyProp?: string
|
||||||
virtualScroller?: boolean
|
virtualScroller?: boolean
|
||||||
stream?: Promise<WsEvents>
|
stream?: Promise<WsEvents>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { History } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
history,
|
history,
|
||||||
maxDay = 2,
|
maxDay = 2,
|
||||||
} = $defineProps<{
|
} = $defineProps<{
|
||||||
history: History[]
|
history: mastodon.v1.TagHistory[]
|
||||||
maxDay?: number
|
maxDay?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { History } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import sparkline from '@fnando/sparkline'
|
import sparkline from '@fnando/sparkline'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -7,7 +7,7 @@ const {
|
||||||
width = 60,
|
width = 60,
|
||||||
height = 40,
|
height = 40,
|
||||||
} = $defineProps<{
|
} = $defineProps<{
|
||||||
history?: History[]
|
history?: mastodon.v1.TagHistory[]
|
||||||
width?: number
|
width?: number
|
||||||
height?: number
|
height?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Emoji } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'ContentRich',
|
name: 'ContentRich',
|
||||||
|
@ -10,7 +10,7 @@ const {
|
||||||
markdown = true,
|
markdown = true,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
content: string
|
content: string
|
||||||
emojis?: Emoji[]
|
emojis?: mastodon.v1.CustomEmoji[]
|
||||||
markdown?: boolean
|
markdown?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Conversation } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { conversation } = defineProps<{
|
const { conversation } = defineProps<{
|
||||||
conversation: Conversation
|
conversation: mastodon.v1.Conversation
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const withAccounts = $computed(() =>
|
const withAccounts = $computed(() =>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Conversation, Paginator } from 'masto'
|
import type { Paginator, mastodon } from 'masto'
|
||||||
|
|
||||||
const { paginator } = defineProps<{
|
const { paginator } = defineProps<{
|
||||||
paginator: Paginator<any, Conversation[]>
|
paginator: Paginator<mastodon.v1.Conversation[], mastodon.DefaultPaginationParams>
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type { ConfirmDialogChoice } from '~/types'
|
import type { ConfirmDialogChoice } from '~/types'
|
||||||
import {
|
import {
|
||||||
isCommandPanelOpen,
|
isCommandPanelOpen,
|
||||||
|
@ -30,7 +30,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handlePublished = (status: Status) => {
|
const handlePublished = (status: mastodon.v1.Status) => {
|
||||||
lastPublishDialogStatus.value = status
|
lastPublishDialogStatus.value = status
|
||||||
isPublishDialogOpen.value = false
|
isPublishDialogOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SwipeDirection } from '@vueuse/core'
|
import { SwipeDirection } from '@vueuse/core'
|
||||||
import { useReducedMotion } from '@vueuse/motion'
|
import { useReducedMotion } from '@vueuse/motion'
|
||||||
import type { Attachment } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { media = [], threshold = 20 } = defineProps<{
|
const { media = [], threshold = 20 } = defineProps<{
|
||||||
media?: Attachment[]
|
media?: mastodon.v1.MediaAttachment[]
|
||||||
threshold?: number
|
threshold?: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Notification } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { notification } = defineProps<{
|
const { notification } = defineProps<{
|
||||||
notification: Notification
|
notification: mastodon.v1.Notification
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// type used in <template>
|
import { mastodon } from 'masto'
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
import type { Paginator, WsEvents } from 'masto'
|
||||||
import type { Notification, Paginator, WsEvents } from 'masto'
|
|
||||||
// type used in <template>
|
// type used in <template>
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||||
import type { GroupedAccountLike, GroupedLikeNotifications, NotificationSlot } from '~/types'
|
import type { GroupedAccountLike, GroupedLikeNotifications, NotificationSlot } from '~/types'
|
||||||
|
|
||||||
const { paginator, stream } = defineProps<{
|
const { paginator, stream } = defineProps<{
|
||||||
paginator: Paginator<any, Notification[]>
|
paginator: Paginator<mastodon.v1.Notification[], mastodon.v1.ListNotificationsParams>
|
||||||
stream?: Promise<WsEvents>
|
stream?: Promise<WsEvents>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const groupCapacity = Number.MAX_VALUE // No limit
|
const groupCapacity = Number.MAX_VALUE // No limit
|
||||||
|
|
||||||
// Group by type (and status when applicable)
|
// 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)
|
// If the update is related to an status, group notifications from the same account (boost + favorite the same status)
|
||||||
const id = item.status
|
const id = item.status
|
||||||
? {
|
? {
|
||||||
|
@ -27,12 +26,12 @@ const groupId = (item: Notification): string => {
|
||||||
return JSON.stringify(id)
|
return JSON.stringify(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupItems(items: Notification[]): NotificationSlot[] {
|
function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
||||||
const results: NotificationSlot[] = []
|
const results: NotificationSlot[] = []
|
||||||
|
|
||||||
let id = 0
|
let id = 0
|
||||||
let currentGroupId = ''
|
let currentGroupId = ''
|
||||||
let currentGroup: Notification[] = []
|
let currentGroup: mastodon.v1.Notification[] = []
|
||||||
const processGroup = () => {
|
const processGroup = () => {
|
||||||
if (currentGroup.length === 0)
|
if (currentGroup.length === 0)
|
||||||
return
|
return
|
||||||
|
@ -127,7 +126,7 @@ const { formatNumber } = useHumanReadableNumber()
|
||||||
/>
|
/>
|
||||||
<NotificationCard
|
<NotificationCard
|
||||||
v-else
|
v-else
|
||||||
:notification="item as Notification"
|
:notification="item as mastodon.v1.Notification"
|
||||||
hover:bg-active
|
hover:bg-active
|
||||||
border="b base"
|
border="b base"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Attachment } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
attachment: Attachment
|
attachment: mastodon.v1.MediaAttachment
|
||||||
alt?: string
|
alt?: string
|
||||||
removable?: boolean
|
removable?: boolean
|
||||||
dialogLabelledBy?: string
|
dialogLabelledBy?: string
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Attachment, CreateStatusParams, Status, StatusVisibility } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { fileOpen } from 'browser-fs-access'
|
import { fileOpen } from 'browser-fs-access'
|
||||||
import { useDropZone } from '@vueuse/core'
|
import { useDropZone } from '@vueuse/core'
|
||||||
import { EditorContent } from '@tiptap/vue-3'
|
import { EditorContent } from '@tiptap/vue-3'
|
||||||
|
@ -18,13 +18,13 @@ const {
|
||||||
initial?: () => Draft
|
initial?: () => Draft
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
inReplyToId?: string
|
inReplyToId?: string
|
||||||
inReplyToVisibility?: StatusVisibility
|
inReplyToVisibility?: mastodon.v1.StatusVisibility
|
||||||
expanded?: boolean
|
expanded?: boolean
|
||||||
dialogLabelledBy?: string
|
dialogLabelledBy?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(evt: 'published', status: Status): void
|
(evt: 'published', status: mastodon.v1.Status): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
@ -103,7 +103,7 @@ async function uploadAttachments(files: File[]) {
|
||||||
if (draft.attachments.length < limit) {
|
if (draft.attachments.length < limit) {
|
||||||
isExceedingAttachmentLimit = false
|
isExceedingAttachmentLimit = false
|
||||||
try {
|
try {
|
||||||
const attachment = await masto.mediaAttachments.create({
|
const attachment = await masto.v1.mediaAttachments.create({
|
||||||
file,
|
file,
|
||||||
})
|
})
|
||||||
draft.attachments.push(attachment)
|
draft.attachments.push(attachment)
|
||||||
|
@ -122,9 +122,9 @@ async function uploadAttachments(files: File[]) {
|
||||||
isUploading = false
|
isUploading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setDescription(att: Attachment, description: string) {
|
async function setDescription(att: mastodon.v1.MediaAttachment, description: string) {
|
||||||
att.description = description
|
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) {
|
function removeAttachment(index: number) {
|
||||||
|
@ -136,8 +136,8 @@ async function publish() {
|
||||||
...draft.params,
|
...draft.params,
|
||||||
status: htmlToText(draft.params.status || ''),
|
status: htmlToText(draft.params.status || ''),
|
||||||
mediaIds: draft.attachments.map(a => a.id),
|
mediaIds: draft.attachments.map(a => a.id),
|
||||||
...(masto.version.includes('+glitch') ? { 'content-type': 'text/markdown' } : {}),
|
...((masto.config as any).props.version.raw.includes('+glitch') ? { 'content-type': 'text/markdown' } : {}),
|
||||||
} as CreateStatusParams
|
} as mastodon.v1.CreateStatusParams
|
||||||
|
|
||||||
if (process.dev) {
|
if (process.dev) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
@ -154,11 +154,11 @@ async function publish() {
|
||||||
try {
|
try {
|
||||||
isSending = true
|
isSending = true
|
||||||
|
|
||||||
let status: Status
|
let status: mastodon.v1.Status
|
||||||
if (!draft.editingStatus)
|
if (!draft.editingStatus)
|
||||||
status = await masto.statuses.create(payload)
|
status = await masto.v1.statuses.create(payload)
|
||||||
else
|
else
|
||||||
status = await masto.statuses.update(draft.editingStatus.id, payload)
|
status = await masto.v1.statuses.update(draft.editingStatus.id, payload)
|
||||||
if (draft.params.inReplyToId)
|
if (draft.params.inReplyToId)
|
||||||
navigateToStatus({ status })
|
navigateToStatus({ status })
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Tag } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { hashtag } = defineProps<{
|
const { hashtag } = defineProps<{
|
||||||
hashtag: Tag
|
hashtag: mastodon.v1.Tag
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const totalTrend = $computed(() =>
|
const totalTrend = $computed(() =>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { UpdateCredentialsParams } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { form } = defineModel<{
|
const { form } = defineModel<{
|
||||||
form: {
|
form: {
|
||||||
fieldsAttributes: NonNullable<UpdateCredentialsParams['fieldsAttributes']>
|
fieldsAttributes: NonNullable<mastodon.v1.UpdateCredentialsParams['fieldsAttributes']>
|
||||||
}
|
}
|
||||||
}>()
|
}>()
|
||||||
const dropdown = $ref<any>()
|
const dropdown = $ref<any>()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { account, link = true } = defineProps<{
|
const { account, link = true } = defineProps<{
|
||||||
account: Account
|
account: mastodon.v1.Account
|
||||||
link?: boolean
|
link?: boolean
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
details?: boolean
|
details?: boolean
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
details?: boolean
|
details?: boolean
|
||||||
command?: boolean
|
command?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
@ -40,21 +40,21 @@ const toggleTranslation = async () => {
|
||||||
|
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
|
|
||||||
const getPermalinkUrl = (status: Status) => {
|
const getPermalinkUrl = (status: mastodon.v1.Status) => {
|
||||||
const url = getStatusPermalinkRoute(status)
|
const url = getStatusPermalinkRoute(status)
|
||||||
if (url)
|
if (url)
|
||||||
return `${location.origin}/${url}`
|
return `${location.origin}/${url}`
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyLink = async (status: Status) => {
|
const copyLink = async (status: mastodon.v1.Status) => {
|
||||||
const url = getPermalinkUrl(status)
|
const url = getPermalinkUrl(status)
|
||||||
if (url)
|
if (url)
|
||||||
await clipboard.copy(url)
|
await clipboard.copy(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { share, isSupported: isShareSupported } = useShare()
|
const { share, isSupported: isShareSupported } = useShare()
|
||||||
const shareLink = async (status: Status) => {
|
const shareLink = async (status: mastodon.v1.Status) => {
|
||||||
const url = getPermalinkUrl(status)
|
const url = getPermalinkUrl(status)
|
||||||
if (url)
|
if (url)
|
||||||
await share({ url })
|
await share({ url })
|
||||||
|
@ -69,7 +69,7 @@ const deleteStatus = async () => {
|
||||||
return
|
return
|
||||||
|
|
||||||
removeCachedStatus(status.id)
|
removeCachedStatus(status.id)
|
||||||
await masto.statuses.remove(status.id)
|
await masto.v1.statuses.remove(status.id)
|
||||||
|
|
||||||
if (route.name === 'status')
|
if (route.name === 'status')
|
||||||
router.back()
|
router.back()
|
||||||
|
@ -87,7 +87,7 @@ const deleteAndRedraft = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCachedStatus(status.id)
|
removeCachedStatus(status.id)
|
||||||
await masto.statuses.remove(status.id)
|
await masto.v1.statuses.remove(status.id)
|
||||||
await openPublishDialog('dialog', await getDraftFromStatus(status), true)
|
await openPublishDialog('dialog', await getDraftFromStatus(status), true)
|
||||||
|
|
||||||
// Go to the new status, if the page is the old status
|
// Go to the new status, if the page is the old status
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { clamp } from '@vueuse/core'
|
import { clamp } from '@vueuse/core'
|
||||||
import type { Attachment } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
attachment,
|
attachment,
|
||||||
fullSize = false,
|
fullSize = false,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
attachment: Attachment
|
attachment: mastodon.v1.MediaAttachment
|
||||||
attachments?: Attachment[]
|
attachments?: mastodon.v1.MediaAttachment[]
|
||||||
fullSize?: boolean
|
fullSize?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status, StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
status,
|
status,
|
||||||
withAction = true,
|
withAction = true,
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
status: Status | StatusEdit
|
status: mastodon.v1.Status | mastodon.v1.StatusEdit
|
||||||
withAction?: boolean
|
withAction?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FilterContext, Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
actions?: boolean
|
actions?: boolean
|
||||||
context?: FilterContext
|
context?: mastodon.v2.FilterContext
|
||||||
hover?: boolean
|
hover?: boolean
|
||||||
faded?: boolean
|
faded?: boolean
|
||||||
|
|
||||||
// If we know the prev and next status in the timeline, we can simplify the card
|
// If we know the prev and next status in the timeline, we can simplify the card
|
||||||
older?: Status
|
older?: mastodon.v1.Status
|
||||||
newer?: Status
|
newer?: mastodon.v1.Status
|
||||||
// Manual overrides
|
// Manual overrides
|
||||||
hasOlder?: boolean
|
hasOlder?: boolean
|
||||||
hasNewer?: boolean
|
hasNewer?: boolean
|
||||||
// When looking into a detailed view of a post, we can simplify the replying badges
|
// When looking into a detailed view of a post, we can simplify the replying badges
|
||||||
// to the main expanded post
|
// to the main expanded post
|
||||||
main?: Status
|
main?: mastodon.v1.Status
|
||||||
}>(),
|
}>(),
|
||||||
{ actions: true },
|
{ actions: true },
|
||||||
)
|
)
|
||||||
|
@ -63,7 +63,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
|
||||||
|
|
||||||
// Content Filter logic
|
// Content Filter logic
|
||||||
const filterResult = $computed(() => status.filtered?.length ? status.filtered[0] : null)
|
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
|
// 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
|
// clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FilterContext, Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { status, context } = defineProps<{
|
const { status, context } = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
context?: FilterContext | 'details'
|
context?: mastodon.v2.FilterContext | 'details'
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const isDM = $computed(() => status.visibility === 'direct')
|
const isDM = $computed(() => status.visibility === 'direct')
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
command?: boolean
|
command?: boolean
|
||||||
actions?: boolean
|
actions?: boolean
|
||||||
}>(), {
|
}>(), {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status, StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { status } = defineProps<{
|
const { status } = defineProps<{
|
||||||
status: Status | StatusEdit
|
status: mastodon.v1.Status | mastodon.v1.StatusEdit
|
||||||
fullSize?: boolean
|
fullSize?: boolean
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { status } = defineProps<{
|
const { status } = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
}>()
|
}>()
|
||||||
const poll = reactive({ ...status.poll! })
|
const poll = reactive({ ...status.poll! })
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ async function vote(e: Event) {
|
||||||
poll.votersCount = (poll.votersCount || 0) + 1
|
poll.votersCount = (poll.votersCount || 0) + 1
|
||||||
cacheStatus({ ...status, poll }, undefined, true)
|
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)
|
const votersCount = $computed(() => poll.votersCount ?? 0)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Card, CardType } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
card: Card
|
card: mastodon.v1.PreviewCard
|
||||||
/** For the preview image, only the small image mode is displayed */
|
/** For the preview image, only the small image mode is displayed */
|
||||||
smallPictureOnly?: boolean
|
smallPictureOnly?: boolean
|
||||||
/** When it is root card in the list, not appear as a child card */
|
/** 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'))
|
const gitHubCards = $(useFeatureFlag('experimentalGitHubCards'))
|
||||||
|
|
||||||
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
||||||
const cardTypeIconMap: Record<CardType, string> = {
|
const cardTypeIconMap: Record<mastodon.v1.PreviewCardType, string> = {
|
||||||
link: 'i-ri:profile-line',
|
link: 'i-ri:profile-line',
|
||||||
photo: 'i-ri:image-line',
|
photo: 'i-ri:image-line',
|
||||||
video: 'i-ri:play-line',
|
video: 'i-ri:play-line',
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Card } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
card: Card
|
card: mastodon.v1.PreviewCard
|
||||||
/** When it is root card in the list, not appear as a child card */
|
/** When it is root card in the list, not appear as a child card */
|
||||||
root?: boolean
|
root?: boolean
|
||||||
/** For the preview image, only the small image mode is displayed */
|
/** For the preview image, only the small image mode is displayed */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Card } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
card: Card
|
card: mastodon.v1.PreviewCard
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
type UrlType = 'user' | 'repo' | 'issue' | 'pull'
|
type UrlType = 'user' | 'repo' | 'issue' | 'pull'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { status, collapsed = false, simplified = false } = defineProps<{
|
const { status, collapsed = false, simplified = false } = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
collapsed?: boolean
|
collapsed?: boolean
|
||||||
simplified?: boolean
|
simplified?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status, StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { formatTimeAgo } from '@vueuse/core'
|
import { formatTimeAgo } from '@vueuse/core'
|
||||||
|
|
||||||
const { status } = defineProps<{
|
const { status } = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const masto = useMasto()
|
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)
|
openEditHistoryDialog(edit)
|
||||||
}
|
}
|
||||||
const timeAgoOptions = useTimeAgoOptions()
|
const timeAgoOptions = useTimeAgoOptions()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { status } = defineProps<{
|
const { status } = defineProps<{
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
inline: boolean
|
inline: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { edit } = defineProps<{
|
const { edit } = defineProps<{
|
||||||
edit: StatusEdit
|
edit: mastodon.v1.StatusEdit
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Tag } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const { tag } = defineProps<{
|
const { tag } = defineProps<{
|
||||||
tag: Tag
|
tag: mastodon.v1.Tag
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'change'): void
|
(event: 'change'): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { tags } = useMasto()
|
const masto = useMasto()
|
||||||
|
|
||||||
const toggleFollowTag = async () => {
|
const toggleFollowTag = async () => {
|
||||||
if (tag.following)
|
if (tag.following)
|
||||||
await tags.unfollow(tag.name)
|
await masto.v1.tags.unfollow(tag.name)
|
||||||
else
|
else
|
||||||
await tags.follow(tag.name)
|
await masto.v1.tags.follow(tag.name)
|
||||||
|
|
||||||
emit('change')
|
emit('change')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Tag } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
tag,
|
tag,
|
||||||
} = $defineProps<{
|
} = $defineProps<{
|
||||||
tag: Tag
|
tag: mastodon.v1.Tag
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const to = $computed(() => new URL(tag.url).pathname)
|
const to = $computed(() => new URL(tag.url).pathname)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().blocks.iterate()
|
const paginator = useMasto().v1.blocks.list()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().bookmarks.iterate()
|
const paginator = useMasto().v1.bookmarks.list()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().conversations.iterate()
|
const paginator = useMasto().v1.conversations.list()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const paginator = masto.domainBlocks.iterate()
|
const paginator = masto.v1.domainBlocks.list()
|
||||||
|
|
||||||
const unblock = async (domain: string) => {
|
const unblock = async (domain: string) => {
|
||||||
await masto.domainBlocks.unblock(domain)
|
await masto.v1.domainBlocks.unblock(domain)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().favourites.iterate()
|
const paginator = useMasto().v1.favourites.list()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().timelines.iterateHome()
|
const paginator = useMasto().v1.timelines.listHome()
|
||||||
const stream = useMasto().stream.streamUser()
|
const stream = useMasto().v1.stream.streamUser()
|
||||||
onBeforeUnmount(() => stream?.then(s => s.disconnect()))
|
onBeforeUnmount(() => stream?.then(s => s.disconnect()))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
timelines: Status[]
|
timelines: mastodon.v1.Status[]
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// Default limit is 20 notifications, and servers are normally caped to 30
|
// 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()
|
const { clearNotifications } = useNotifications()
|
||||||
onActivated(clearNotifications)
|
onActivated(clearNotifications)
|
||||||
|
|
||||||
const stream = useMasto().stream.streamUser()
|
const stream = useMasto().v1.stream.streamUser()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().mutes.iterate()
|
const paginator = useMasto().v1.mutes.list()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// Default limit is 20 notifications, and servers are normally caped to 30
|
// 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()
|
const { clearNotifications } = useNotifications()
|
||||||
onActivated(clearNotifications)
|
onActivated(clearNotifications)
|
||||||
|
|
||||||
const stream = useMasto().stream.streamUser()
|
const stream = useMasto().v1.stream.streamUser()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
// @ts-expect-error missing types
|
// @ts-expect-error missing types
|
||||||
import { DynamicScrollerItem } from 'vue-virtual-scroller'
|
import { DynamicScrollerItem } from 'vue-virtual-scroller'
|
||||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
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<{
|
const { paginator, stream, account } = defineProps<{
|
||||||
paginator: Paginator<any, Status[]>
|
paginator: Paginator<mastodon.v1.Status[], mastodon.v1.ListAccountStatusesParams>
|
||||||
stream?: Promise<WsEvents>
|
stream?: Promise<WsEvents>
|
||||||
context?: FilterContext
|
context?: mastodon.v2.FilterContext
|
||||||
account?: Account
|
account?: mastodon.v1.Account
|
||||||
preprocess?: (items: any[]) => any[]
|
preprocess?: (items: any[]) => any[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().timelines.iteratePublic()
|
const paginator = useMasto().v1.timelines.listPublic()
|
||||||
const stream = useMasto().stream.streamPublicTimeline()
|
const stream = useMasto().v1.stream.streamPublicTimeline()
|
||||||
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const paginator = useMasto().timelines.iteratePublic({ local: true })
|
const paginator = useMasto().v1.timelines.listPublic({ local: true })
|
||||||
const stream = useMasto().stream.streamCommunityTimeline()
|
const stream = useMasto().v1.stream.streamCommunityTimeline()
|
||||||
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Tag } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
|
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
|
||||||
|
|
||||||
const { items, command } = defineProps<{
|
const { items, command } = defineProps<{
|
||||||
items: Tag[]
|
items: mastodon.v1.Tag[]
|
||||||
command: Function
|
command: Function
|
||||||
isPending?: boolean
|
isPending?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
|
import CommonScrollIntoView from '../common/CommonScrollIntoView.vue'
|
||||||
|
|
||||||
const { items, command } = defineProps<{
|
const { items, command } = defineProps<{
|
||||||
items: Account[]
|
items: mastodon.v1.Account[]
|
||||||
command: Function
|
command: Function
|
||||||
isPending?: boolean
|
isPending?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import LRU from 'lru-cache'
|
import LRU from 'lru-cache'
|
||||||
import type { Account, Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const cache = new LRU<string, any>({
|
const cache = new LRU<string, any>({
|
||||||
max: 1000,
|
max: 1000,
|
||||||
|
@ -17,13 +17,13 @@ function removeCached(key: string) {
|
||||||
cache.delete(key)
|
cache.delete(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchStatus(id: string, force = false): Promise<Status> {
|
export function fetchStatus(id: string, force = false): Promise<mastodon.v1.Status> {
|
||||||
const server = currentServer.value
|
const server = currentServer.value
|
||||||
const key = `${server}:status:${id}`
|
const key = `${server}:status:${id}`
|
||||||
const cached = cache.get(key)
|
const cached = cache.get(key)
|
||||||
if (cached && !force)
|
if (cached && !force)
|
||||||
return cached
|
return cached
|
||||||
const promise = useMasto().statuses.fetch(id)
|
const promise = useMasto().v1.statuses.fetch(id)
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
cacheStatus(status)
|
cacheStatus(status)
|
||||||
return status
|
return status
|
||||||
|
@ -32,7 +32,7 @@ export function fetchStatus(id: string, force = false): Promise<Status> {
|
||||||
return promise
|
return promise
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchAccountById(id?: string | null): Promise<Account | null> {
|
export function fetchAccountById(id?: string | null): Promise<mastodon.v1.Account | null> {
|
||||||
if (!id)
|
if (!id)
|
||||||
return Promise.resolve(null)
|
return Promise.resolve(null)
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ export function fetchAccountById(id?: string | null): Promise<Account | null> {
|
||||||
const cached = cache.get(key)
|
const cached = cache.get(key)
|
||||||
if (cached)
|
if (cached)
|
||||||
return cached
|
return cached
|
||||||
const uri = currentInstance.value?.uri
|
const domain = currentInstance.value?.domain
|
||||||
const promise = useMasto().accounts.fetch(id)
|
const promise = useMasto().v1.accounts.fetch(id)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r.acct && !r.acct.includes('@') && uri)
|
if (r.acct && !r.acct.includes('@') && domain)
|
||||||
r.acct = `${r.acct}@${uri}`
|
r.acct = `${r.acct}@${domain}`
|
||||||
|
|
||||||
cacheAccount(r, server, true)
|
cacheAccount(r, server, true)
|
||||||
return r
|
return r
|
||||||
|
@ -54,17 +54,17 @@ export function fetchAccountById(id?: string | null): Promise<Account | null> {
|
||||||
return promise
|
return promise
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchAccountByHandle(acct: string): Promise<Account> {
|
export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Account> {
|
||||||
const server = currentServer.value
|
const server = currentServer.value
|
||||||
const key = `${server}:account:${acct}`
|
const key = `${server}:account:${acct}`
|
||||||
const cached = cache.get(key)
|
const cached = cache.get(key)
|
||||||
if (cached)
|
if (cached)
|
||||||
return cached
|
return cached
|
||||||
const uri = currentInstance.value?.uri
|
const domain = currentInstance.value?.domain
|
||||||
const account = useMasto().accounts.lookup({ acct })
|
const account = useMasto().v1.accounts.lookup({ acct })
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r.acct && !r.acct.includes('@') && uri)
|
if (r.acct && !r.acct.includes('@') && domain)
|
||||||
r.acct = `${r.acct}@${uri}`
|
r.acct = `${r.acct}@${domain}`
|
||||||
|
|
||||||
cacheAccount(r, server, true)
|
cacheAccount(r, server, true)
|
||||||
return r
|
return r
|
||||||
|
@ -81,7 +81,7 @@ export function useAccountById(id?: string | null) {
|
||||||
return useAsyncState(() => fetchAccountById(id), null).state
|
return useAsyncState(() => fetchAccountById(id), null).state
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cacheStatus(status: Status, server = currentServer.value, override?: boolean) {
|
export function cacheStatus(status: mastodon.v1.Status, server = currentServer.value, override?: boolean) {
|
||||||
setCached(`${server}:status:${status.id}`, status, override)
|
setCached(`${server}:status:${status.id}`, status, override)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export function removeCachedStatus(id: string, server = currentServer.value) {
|
||||||
removeCached(`${server}:status:${id}`)
|
removeCached(`${server}:status:${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cacheAccount(account: Account, server = currentServer.value, override?: boolean) {
|
export function cacheAccount(account: mastodon.v1.Account, server = currentServer.value, override?: boolean) {
|
||||||
setCached(`${server}:account:${account.id}`, account, override)
|
setCached(`${server}:account:${account.id}`, account, override)
|
||||||
setCached(`${server}:account:${account.acct}`, account, override)
|
setCached(`${server}:account:${account.acct}`, account, override)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// @unimport-disable
|
// @unimport-disable
|
||||||
import type { Emoji } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type { Node } from 'ultrahtml'
|
import type { Node } from 'ultrahtml'
|
||||||
import { DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE, h, parse, render } from 'ultrahtml'
|
import { DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE, h, parse, render } from 'ultrahtml'
|
||||||
import { findAndReplaceEmojisInText } from '@iconify/utils'
|
import { findAndReplaceEmojisInText } from '@iconify/utils'
|
||||||
import { emojiRegEx, getEmojiAttributes } from '../config/emojis'
|
import { emojiRegEx, getEmojiAttributes } from '../config/emojis'
|
||||||
|
|
||||||
export interface ContentParseOptions {
|
export interface ContentParseOptions {
|
||||||
emojis?: Record<string, Emoji>
|
emojis?: Record<string, mastodon.v1.CustomEmoji>
|
||||||
markdown?: boolean
|
markdown?: boolean
|
||||||
replaceUnicodeEmoji?: boolean
|
replaceUnicodeEmoji?: boolean
|
||||||
astTransforms?: Transform[]
|
astTransforms?: Transform[]
|
||||||
|
@ -87,7 +87,7 @@ export function parseMastodonHTML(
|
||||||
/**
|
/**
|
||||||
* Converts raw HTML form Mastodon server to HTML for Tiptap editor
|
* Converts raw HTML form Mastodon server to HTML for Tiptap editor
|
||||||
*/
|
*/
|
||||||
export function convertMastodonHTML(html: string, customEmojis: Record<string, Emoji> = {}) {
|
export function convertMastodonHTML(html: string, customEmojis: Record<string, mastodon.v1.CustomEmoji> = {}) {
|
||||||
const tree = parseMastodonHTML(html, {
|
const tree = parseMastodonHTML(html, {
|
||||||
emojis: customEmojis,
|
emojis: customEmojis,
|
||||||
markdown: true,
|
markdown: true,
|
||||||
|
@ -287,7 +287,7 @@ function transformUnicodeEmoji(node: Node) {
|
||||||
return matches.filter(Boolean)
|
return matches.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceCustomEmoji(customEmojis: Record<string, Emoji>): Transform {
|
function replaceCustomEmoji(customEmojis: Record<string, mastodon.v1.CustomEmoji>): Transform {
|
||||||
return (node) => {
|
return (node) => {
|
||||||
if (node.type !== TEXT_NODE)
|
if (node.type !== TEXT_NODE)
|
||||||
return node
|
return node
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import type { Attachment, Status, StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type { ConfirmDialogChoice, ConfirmDialogLabel, Draft } from '~/types'
|
import type { ConfirmDialogChoice, ConfirmDialogLabel, Draft } from '~/types'
|
||||||
import { STORAGE_KEY_FIRST_VISIT } from '~/constants'
|
import { STORAGE_KEY_FIRST_VISIT } from '~/constants'
|
||||||
|
|
||||||
export const confirmDialogChoice = ref<ConfirmDialogChoice>()
|
export const confirmDialogChoice = ref<ConfirmDialogChoice>()
|
||||||
export const confirmDialogLabel = ref<ConfirmDialogLabel>()
|
export const confirmDialogLabel = ref<ConfirmDialogLabel>()
|
||||||
|
|
||||||
export const mediaPreviewList = ref<Attachment[]>([])
|
export const mediaPreviewList = ref<mastodon.v1.MediaAttachment[]>([])
|
||||||
export const mediaPreviewIndex = ref(0)
|
export const mediaPreviewIndex = ref(0)
|
||||||
|
|
||||||
export const statusEdit = ref<StatusEdit>()
|
export const statusEdit = ref<mastodon.v1.StatusEdit>()
|
||||||
export const dialogDraftKey = ref<string>()
|
export const dialogDraftKey = ref<string>()
|
||||||
|
|
||||||
export const commandPanelInput = ref('')
|
export const commandPanelInput = ref('')
|
||||||
|
@ -23,7 +23,7 @@ export const isPreviewHelpOpen = ref(isFirstVisit.value)
|
||||||
export const isCommandPanelOpen = ref(false)
|
export const isCommandPanelOpen = ref(false)
|
||||||
export const isConfirmDialogOpen = ref(false)
|
export const isConfirmDialogOpen = ref(false)
|
||||||
|
|
||||||
export const lastPublishDialogStatus = ref<Status | null>(null)
|
export const lastPublishDialogStatus = ref<mastodon.v1.Status | null>(null)
|
||||||
|
|
||||||
export function openSigninDialog() {
|
export function openSigninDialog() {
|
||||||
isSigninDialogOpen.value = true
|
isSigninDialogOpen.value = true
|
||||||
|
@ -80,7 +80,7 @@ if (process.client) {
|
||||||
restoreMediaPreviewFromState()
|
restoreMediaPreviewFromState()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openMediaPreview(attachments: Attachment[], index = 0) {
|
export function openMediaPreview(attachments: mastodon.v1.MediaAttachment[], index = 0) {
|
||||||
mediaPreviewList.value = attachments
|
mediaPreviewList.value = attachments
|
||||||
mediaPreviewIndex.value = index
|
mediaPreviewIndex.value = index
|
||||||
isMediaPreviewOpen.value = true
|
isMediaPreviewOpen.value = true
|
||||||
|
@ -97,7 +97,7 @@ export function closeMediaPreview() {
|
||||||
history.back()
|
history.back()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openEditHistoryDialog(edit: StatusEdit) {
|
export function openEditHistoryDialog(edit: mastodon.v1.StatusEdit) {
|
||||||
statusEdit.value = edit
|
statusEdit.value = edit
|
||||||
isEditHistoryDialogOpen.value = true
|
isEditHistoryDialogOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Emoji } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type { CustomEmojisInfo } from './push-notifications/types'
|
import type { CustomEmojisInfo } from './push-notifications/types'
|
||||||
import { STORAGE_KEY_CUSTOM_EMOJIS } from '~/constants'
|
import { STORAGE_KEY_CUSTOM_EMOJIS } from '~/constants'
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@ export async function updateCustomEmojis() {
|
||||||
return
|
return
|
||||||
|
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const emojis = await masto.customEmojis.fetchAll()
|
const emojis = await masto.v1.customEmojis.list()
|
||||||
Object.assign(currentCustomEmojis.value, {
|
Object.assign(currentCustomEmojis.value, {
|
||||||
lastUpdate: Date.now(),
|
lastUpdate: Date.now(),
|
||||||
emojis,
|
emojis,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformEmojiData(emojis: Emoji[]) {
|
function transformEmojiData(emojis: mastodon.v1.CustomEmoji[]) {
|
||||||
const result = []
|
const result = []
|
||||||
|
|
||||||
for (const emoji of emojis) {
|
for (const emoji of emojis) {
|
||||||
|
@ -52,9 +52,9 @@ export const customEmojisData = computed(() => currentCustomEmojis.value.emojis.
|
||||||
}]
|
}]
|
||||||
: undefined)
|
: undefined)
|
||||||
|
|
||||||
export function useEmojisFallback(emojisGetter: () => Emoji[] | undefined) {
|
export function useEmojisFallback(emojisGetter: () => mastodon.v1.CustomEmoji[] | undefined) {
|
||||||
return computed(() => {
|
return computed(() => {
|
||||||
const result: Emoji[] = []
|
const result: mastodon.v1.CustomEmoji[] = []
|
||||||
const emojis = emojisGetter()
|
const emojis = emojisGetter()
|
||||||
if (emojis)
|
if (emojis)
|
||||||
result.push(...emojis)
|
result.push(...emojis)
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
import type { Account } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
export function getDisplayName(account?: Account, options?: { rich?: boolean }) {
|
export function getDisplayName(account?: mastodon.v1.Account, options?: { rich?: boolean }) {
|
||||||
const displayName = account?.displayName || account?.username || ''
|
const displayName = account?.displayName || account?.username || ''
|
||||||
if (options?.rich)
|
if (options?.rich)
|
||||||
return displayName
|
return displayName
|
||||||
return displayName.replace(/:([\w-]+?):/g, '')
|
return displayName.replace(/:([\w-]+?):/g, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getShortHandle({ acct }: Account) {
|
export function getShortHandle({ acct }: mastodon.v1.Account) {
|
||||||
if (!acct)
|
if (!acct)
|
||||||
return ''
|
return ''
|
||||||
return `@${acct.includes('@') ? acct.split('@')[0] : acct}`
|
return `@${acct.includes('@') ? acct.split('@')[0] : acct}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getServerName(account: Account) {
|
export function getServerName(account: mastodon.v1.Account) {
|
||||||
if (account.acct?.includes('@'))
|
if (account.acct?.includes('@'))
|
||||||
return account.acct.split('@')[1]
|
return account.acct.split('@')[1]
|
||||||
// We should only lack the server name if we're on the same server as the account
|
// We should only lack the server name if we're on the same server as the account
|
||||||
return currentInstance.value?.uri || ''
|
return currentInstance.value?.domain || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFullHandle(account: Account) {
|
export function getFullHandle(account: mastodon.v1.Account) {
|
||||||
const handle = `@${account.acct}`
|
const handle = `@${account.acct}`
|
||||||
if (!currentUser.value || account.acct.includes('@'))
|
if (!currentUser.value || account.acct.includes('@'))
|
||||||
return handle
|
return handle
|
||||||
|
@ -36,16 +36,16 @@ export function toShortHandle(fullHandle: string) {
|
||||||
return fullHandle
|
return fullHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractAccountHandle(account: Account) {
|
export function extractAccountHandle(account: mastodon.v1.Account) {
|
||||||
let handle = getFullHandle(account).slice(1)
|
let handle = getFullHandle(account).slice(1)
|
||||||
const uri = currentInstance.value?.uri ?? currentServer.value
|
const uri = currentInstance.value?.domain ?? currentServer.value
|
||||||
if (currentInstance.value && handle.endsWith(`@${uri}`))
|
if (currentInstance.value && handle.endsWith(`@${uri}`))
|
||||||
handle = handle.slice(0, -uri.length - 1)
|
handle = handle.slice(0, -uri.length - 1)
|
||||||
|
|
||||||
return handle
|
return handle
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAccountHandle(account: Account, fullServer = true) {
|
export function useAccountHandle(account: mastodon.v1.Account, fullServer = true) {
|
||||||
return computed(() => fullServer
|
return computed(() => fullServer
|
||||||
? getFullHandle(account)
|
? getFullHandle(account)
|
||||||
: getShortHandle(account),
|
: getShortHandle(account),
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import type { Account, Relationship } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
// Batch requests for relationships when used in the UI
|
// Batch requests for relationships when used in the UI
|
||||||
// We don't want to hold to old values, so every time a Relationship is needed it
|
// We don't want to hold to old values, so every time a Relationship is needed it
|
||||||
// is requested again from the server to show the latest state
|
// is requested again from the server to show the latest state
|
||||||
|
|
||||||
const requestedRelationships = new Map<string, Ref<Relationship | undefined>>()
|
const requestedRelationships = new Map<string, Ref<mastodon.v1.Relationship | undefined>>()
|
||||||
let timeoutHandle: NodeJS.Timeout | undefined
|
let timeoutHandle: NodeJS.Timeout | undefined
|
||||||
|
|
||||||
export function useRelationship(account: Account): Ref<Relationship | undefined> {
|
export function useRelationship(account: mastodon.v1.Account): Ref<mastodon.v1.Relationship | undefined> {
|
||||||
if (!currentUser.value)
|
if (!currentUser.value)
|
||||||
return ref()
|
return ref()
|
||||||
let relationship = requestedRelationships.get(account.id)
|
let relationship = requestedRelationships.get(account.id)
|
||||||
if (relationship)
|
if (relationship)
|
||||||
return relationship
|
return relationship
|
||||||
relationship = ref<Relationship | undefined>()
|
relationship = ref<mastodon.v1.Relationship | undefined>()
|
||||||
requestedRelationships.set(account.id, relationship)
|
requestedRelationships.set(account.id, relationship)
|
||||||
if (timeoutHandle)
|
if (timeoutHandle)
|
||||||
clearTimeout(timeoutHandle)
|
clearTimeout(timeoutHandle)
|
||||||
|
@ -27,7 +27,7 @@ export function useRelationship(account: Account): Ref<Relationship | undefined>
|
||||||
|
|
||||||
async function fetchRelationships() {
|
async function fetchRelationships() {
|
||||||
const requested = Array.from(requestedRelationships.entries()).filter(([, r]) => !r.value)
|
const requested = Array.from(requestedRelationships.entries()).filter(([, r]) => !r.value)
|
||||||
const relationships = await useMasto().accounts.fetchRelationships(requested.map(([id]) => id))
|
const relationships = await useMasto().v1.accounts.fetchRelationships(requested.map(([id]) => id))
|
||||||
for (let i = 0; i < requested.length; i++)
|
for (let i = 0; i < requested.length; i++)
|
||||||
requested[i][1].value = relationships[i]
|
requested[i][1].value = relationships[i]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { withoutProtocol } from 'ufo'
|
import { withoutProtocol } from 'ufo'
|
||||||
import type { Account, Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
export function getAccountRoute(account: Account) {
|
export function getAccountRoute(account: mastodon.v1.Account) {
|
||||||
return useRouter().resolve({
|
return useRouter().resolve({
|
||||||
name: 'account-index',
|
name: 'account-index',
|
||||||
params: {
|
params: {
|
||||||
|
@ -10,7 +10,7 @@ export function getAccountRoute(account: Account) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function getAccountFollowingRoute(account: Account) {
|
export function getAccountFollowingRoute(account: mastodon.v1.Account) {
|
||||||
return useRouter().resolve({
|
return useRouter().resolve({
|
||||||
name: 'account-following',
|
name: 'account-following',
|
||||||
params: {
|
params: {
|
||||||
|
@ -19,7 +19,7 @@ export function getAccountFollowingRoute(account: Account) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function getAccountFollowersRoute(account: Account) {
|
export function getAccountFollowersRoute(account: mastodon.v1.Account) {
|
||||||
return useRouter().resolve({
|
return useRouter().resolve({
|
||||||
name: 'account-followers',
|
name: 'account-followers',
|
||||||
params: {
|
params: {
|
||||||
|
@ -29,7 +29,7 @@ export function getAccountFollowersRoute(account: Account) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStatusRoute(status: Status) {
|
export function getStatusRoute(status: mastodon.v1.Status) {
|
||||||
return useRouter().resolve({
|
return useRouter().resolve({
|
||||||
name: 'status',
|
name: 'status',
|
||||||
params: {
|
params: {
|
||||||
|
@ -50,11 +50,11 @@ export function getTagRoute(tag: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStatusPermalinkRoute(status: Status) {
|
export function getStatusPermalinkRoute(status: mastodon.v1.Status) {
|
||||||
return status.url ? withoutProtocol(status.url) : null
|
return status.url ? withoutProtocol(status.url) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStatusInReplyToRoute(status: Status) {
|
export function getStatusInReplyToRoute(status: mastodon.v1.Status) {
|
||||||
return useRouter().resolve({
|
return useRouter().resolve({
|
||||||
name: 'status-by-id',
|
name: 'status-by-id',
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { MaybeRef } from '@vueuse/core'
|
import type { MaybeRef } from '@vueuse/core'
|
||||||
import type { Account, Paginator, Results, SearchParams, SearchType, Status, Tag } from 'masto'
|
import type { Paginator, mastodon } from 'masto'
|
||||||
import type { RouteLocation } from 'vue-router'
|
import type { RouteLocation } from 'vue-router'
|
||||||
|
|
||||||
export interface UseSearchOptions {
|
export interface UseSearchOptions {
|
||||||
type?: MaybeRef<SearchType>
|
type?: MaybeRef<mastodon.v2.SearchType>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BuildSearchResult<K extends keyof any, T> {
|
export interface BuildSearchResult<K extends keyof any, T> {
|
||||||
|
@ -14,9 +14,9 @@ export interface BuildSearchResult<K extends keyof any, T> {
|
||||||
href: string
|
href: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export type AccountSearchResult = BuildSearchResult<'account', Account>
|
export type AccountSearchResult = BuildSearchResult<'account', mastodon.v1.Account>
|
||||||
export type HashTagSearchResult = BuildSearchResult<'hashtag', Tag>
|
export type HashTagSearchResult = BuildSearchResult<'hashtag', mastodon.v1.Tag>
|
||||||
export type StatusSearchResult = BuildSearchResult<'status', Status>
|
export type StatusSearchResult = BuildSearchResult<'status', mastodon.v1.Status>
|
||||||
|
|
||||||
export type SearchResult = HashTagSearchResult | AccountSearchResult | StatusSearchResult
|
export type SearchResult = HashTagSearchResult | AccountSearchResult | StatusSearchResult
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ export function useSearch(query: MaybeRef<string>, options?: UseSearchOptions) {
|
||||||
const hashtags = ref<HashTagSearchResult[]>([])
|
const hashtags = ref<HashTagSearchResult[]>([])
|
||||||
const statuses = ref<StatusSearchResult[]>([])
|
const statuses = ref<StatusSearchResult[]>([])
|
||||||
|
|
||||||
let paginator: Paginator<SearchParams, Results> | undefined
|
let paginator: Paginator<mastodon.v2.Search, mastodon.v2.SearchParams> | undefined
|
||||||
|
|
||||||
const appendResults = (results: Results, empty = false) => {
|
const appendResults = (results: mastodon.v2.Search, empty = false) => {
|
||||||
if (empty) {
|
if (empty) {
|
||||||
accounts.value = []
|
accounts.value = []
|
||||||
hashtags.value = []
|
hashtags.value = []
|
||||||
|
@ -72,7 +72,7 @@ export function useSearch(query: MaybeRef<string>, options?: UseSearchOptions) {
|
||||||
* Based on the source it seems like modifying the params when calling next would result in a new search,
|
* Based on the source it seems like modifying the params when calling next would result in a new search,
|
||||||
* but that doesn't seem to be the case. So instead we just create a new paginator with the new params.
|
* but that doesn't seem to be the case. So instead we just create a new paginator with the new params.
|
||||||
*/
|
*/
|
||||||
paginator = masto.search({
|
paginator = masto.v2.search({
|
||||||
q: unref(query),
|
q: unref(query),
|
||||||
resolve: !!currentUser.value,
|
resolve: !!currentUser.value,
|
||||||
type: unref(options?.type),
|
type: unref(options?.type),
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted'
|
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted'
|
||||||
type CountField = 'reblogsCount' | 'favouritesCount'
|
type CountField = 'reblogsCount' | 'favouritesCount'
|
||||||
|
|
||||||
export interface StatusActionsProps {
|
export interface StatusActionsProps {
|
||||||
status: Status
|
status: mastodon.v1.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStatusActions(props: StatusActionsProps) {
|
export function useStatusActions(props: StatusActionsProps) {
|
||||||
let status = $ref<Status>({ ...props.status })
|
let status = $ref<mastodon.v1.Status>({ ...props.status })
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -27,7 +27,7 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
muted: false,
|
muted: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise<Status>, countField?: CountField) {
|
async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise<mastodon.v1.Status>, countField?: CountField) {
|
||||||
// check login
|
// check login
|
||||||
if (!checkLogin())
|
if (!checkLogin())
|
||||||
return
|
return
|
||||||
|
@ -46,7 +46,7 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
}
|
}
|
||||||
const toggleReblog = () => toggleStatusAction(
|
const toggleReblog = () => toggleStatusAction(
|
||||||
'reblogged',
|
'reblogged',
|
||||||
() => masto.statuses[status.reblogged ? 'unreblog' : 'reblog'](status.id).then((res) => {
|
() => masto.v1.statuses[status.reblogged ? 'unreblog' : 'reblog'](status.id).then((res) => {
|
||||||
if (status.reblogged)
|
if (status.reblogged)
|
||||||
// returns the original status
|
// returns the original status
|
||||||
return res.reblog!
|
return res.reblog!
|
||||||
|
@ -57,23 +57,23 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
|
|
||||||
const toggleFavourite = () => toggleStatusAction(
|
const toggleFavourite = () => toggleStatusAction(
|
||||||
'favourited',
|
'favourited',
|
||||||
() => masto.statuses[status.favourited ? 'unfavourite' : 'favourite'](status.id),
|
() => masto.v1.statuses[status.favourited ? 'unfavourite' : 'favourite'](status.id),
|
||||||
'favouritesCount',
|
'favouritesCount',
|
||||||
)
|
)
|
||||||
|
|
||||||
const toggleBookmark = () => toggleStatusAction(
|
const toggleBookmark = () => toggleStatusAction(
|
||||||
'bookmarked',
|
'bookmarked',
|
||||||
() => masto.statuses[status.bookmarked ? 'unbookmark' : 'bookmark'](status.id),
|
() => masto.v1.statuses[status.bookmarked ? 'unbookmark' : 'bookmark'](status.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
const togglePin = async () => toggleStatusAction(
|
const togglePin = async () => toggleStatusAction(
|
||||||
'pinned',
|
'pinned',
|
||||||
() => masto.statuses[status.pinned ? 'unpin' : 'pin'](status.id),
|
() => masto.v1.statuses[status.pinned ? 'unpin' : 'pin'](status.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
const toggleMute = async () => toggleStatusAction(
|
const toggleMute = async () => toggleStatusAction(
|
||||||
'muted',
|
'muted',
|
||||||
() => masto.statuses[status.muted ? 'unmute' : 'mute'](status.id),
|
() => masto.v1.statuses[status.muted ? 'unmute' : 'mute'](status.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Account, CreateStatusParams, Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import { STORAGE_KEY_DRAFTS } from '~/constants'
|
import { STORAGE_KEY_DRAFTS } from '~/constants'
|
||||||
import type { Draft, DraftMap } from '~/types'
|
import type { Draft, DraftMap } from '~/types'
|
||||||
import type { Mutable } from '~/types/utils'
|
import type { Mutable } from '~/types/utils'
|
||||||
|
@ -10,7 +10,7 @@ export const builtinDraftKeys = [
|
||||||
'home',
|
'home',
|
||||||
]
|
]
|
||||||
|
|
||||||
export function getDefaultDraft(options: Partial<Mutable<CreateStatusParams> & Omit<Draft, 'params'>> = {}): Draft {
|
export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatusParams> & Omit<Draft, 'params'>> = {}): Draft {
|
||||||
const {
|
const {
|
||||||
attachments = [],
|
attachments = [],
|
||||||
initialText = '',
|
initialText = '',
|
||||||
|
@ -38,7 +38,7 @@ export function getDefaultDraft(options: Partial<Mutable<CreateStatusParams> & O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDraftFromStatus(status: Status): Promise<Draft> {
|
export async function getDraftFromStatus(status: mastodon.v1.Status): Promise<Draft> {
|
||||||
return getDefaultDraft({
|
return getDefaultDraft({
|
||||||
status: await convertMastodonHTML(status.content),
|
status: await convertMastodonHTML(status.content),
|
||||||
mediaIds: status.mediaAttachments.map(att => att.id),
|
mediaIds: status.mediaAttachments.map(att => att.id),
|
||||||
|
@ -54,7 +54,7 @@ function mentionHTML(acct: string) {
|
||||||
return `<span data-type="mention" data-id="${acct}" contenteditable="false">@${acct}</span>`
|
return `<span data-type="mention" data-id="${acct}" contenteditable="false">@${acct}</span>`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReplyDraft(status: Status) {
|
export function getReplyDraft(status: mastodon.v1.Status) {
|
||||||
const accountsToMention: string[] = []
|
const accountsToMention: string[] = []
|
||||||
const userId = currentUser.value?.account.id
|
const userId = currentUser.value?.account.id
|
||||||
if (status.account.id !== userId)
|
if (status.account.id !== userId)
|
||||||
|
@ -112,13 +112,13 @@ export function useDraft(
|
||||||
return { draft, isEmpty }
|
return { draft, isEmpty }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mentionUser(account: Account) {
|
export function mentionUser(account: mastodon.v1.Account) {
|
||||||
openPublishDialog('dialog', getDefaultDraft({
|
openPublishDialog('dialog', getDefaultDraft({
|
||||||
status: `@${account.acct} `,
|
status: `@${account.acct} `,
|
||||||
}), true)
|
}), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function directMessageUser(account: Account) {
|
export function directMessageUser(account: mastodon.v1.Account) {
|
||||||
openPublishDialog('dialog', getDefaultDraft({
|
openPublishDialog('dialog', getDefaultDraft({
|
||||||
status: `@${account.acct} `,
|
status: `@${account.acct} `,
|
||||||
visibility: 'direct',
|
visibility: 'direct',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Status, StatusEdit } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
export interface TranslationResponse {
|
export interface TranslationResponse {
|
||||||
translatedText: string
|
translatedText: string
|
||||||
|
@ -24,9 +24,9 @@ export async function translateText(text: string, from?: string | null, to?: str
|
||||||
return translatedText
|
return translatedText
|
||||||
}
|
}
|
||||||
|
|
||||||
const translations = new WeakMap<Status | StatusEdit, { visible: boolean; text: string }>()
|
const translations = new WeakMap<mastodon.v1.Status | mastodon.v1.StatusEdit, { visible: boolean; text: string }>()
|
||||||
|
|
||||||
export function useTranslation(status: Status | StatusEdit) {
|
export function useTranslation(status: mastodon.v1.Status | mastodon.v1.StatusEdit) {
|
||||||
if (!translations.has(status))
|
if (!translations.has(status))
|
||||||
translations.set(status, reactive({ visible: false, text: '' }))
|
translations.set(status, reactive({ visible: false, text: '' }))
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Emoji } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
export const UserLinkRE = /^https?:\/\/([^/]+)\/@([^/]+)$/
|
export const UserLinkRE = /^https?:\/\/([^/]+)\/@([^/]+)$/
|
||||||
export const TagLinkRE = /^https?:\/\/([^/]+)\/tags\/([^/]+)$/
|
export const TagLinkRE = /^https?:\/\/([^/]+)\/tags\/([^/]+)$/
|
||||||
|
@ -21,7 +21,7 @@ export function getDataUrlFromArr(arr: Uint8ClampedArray, w: number, h: number)
|
||||||
return canvas.toDataURL()
|
return canvas.toDataURL()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emojisArrayToObject(emojis: Emoji[]) {
|
export function emojisArrayToObject(emojis: mastodon.v1.CustomEmoji[]) {
|
||||||
return Object.fromEntries(emojis.map(i => [i.shortcode, i]))
|
return Object.fromEntries(emojis.map(i => [i.shortcode, i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Paginator, WsEvents } from 'masto'
|
import type { Paginator, WsEvents } from 'masto'
|
||||||
import type { PaginatorState } from '~/types'
|
import type { PaginatorState } from '~/types'
|
||||||
|
|
||||||
export function usePaginator<T>(
|
export function usePaginator<T, P>(
|
||||||
paginator: Paginator<any, T[]>,
|
paginator: Paginator<T[], P>,
|
||||||
stream?: Promise<WsEvents>,
|
stream?: Promise<WsEvents>,
|
||||||
eventType: 'notification' | 'update' = 'update',
|
eventType: 'notification' | 'update' = 'update',
|
||||||
preprocess: (items: T[]) => T[] = (items: T[]) => items,
|
preprocess: (items: T[]) => T[] = (items: T[]) => items,
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import type {
|
import type { mastodon } from 'masto'
|
||||||
CreatePushSubscriptionParams,
|
|
||||||
PushSubscription as MastoPushSubscription,
|
|
||||||
SubscriptionPolicy,
|
|
||||||
} from 'masto'
|
|
||||||
import type {
|
import type {
|
||||||
CreatePushNotification,
|
CreatePushNotification,
|
||||||
PushManagerSubscriptionInfo,
|
PushManagerSubscriptionInfo,
|
||||||
|
@ -12,14 +8,14 @@ import type {
|
||||||
export const createPushSubscription = async (
|
export const createPushSubscription = async (
|
||||||
user: RequiredUserLogin,
|
user: RequiredUserLogin,
|
||||||
notificationData: CreatePushNotification,
|
notificationData: CreatePushNotification,
|
||||||
policy: SubscriptionPolicy = 'all',
|
policy: mastodon.v1.SubscriptionPolicy = 'all',
|
||||||
force = false,
|
force = false,
|
||||||
): Promise<MastoPushSubscription | undefined> => {
|
): Promise<mastodon.v1.WebPushSubscription | undefined> => {
|
||||||
const { server: serverEndpoint, vapidKey } = user
|
const { server: serverEndpoint, vapidKey } = user
|
||||||
|
|
||||||
return await getRegistration()
|
return await getRegistration()
|
||||||
.then(getPushSubscription)
|
.then(getPushSubscription)
|
||||||
.then(({ registration, subscription }): Promise<MastoPushSubscription | undefined> => {
|
.then(({ registration, subscription }): Promise<mastodon.v1.WebPushSubscription | undefined> => {
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
const currentServerKey = (new Uint8Array(subscription.options.applicationServerKey!)).toString()
|
const currentServerKey = (new Uint8Array(subscription.options.applicationServerKey!)).toString()
|
||||||
const subscriptionServerKey = urlBase64ToUint8Array(vapidKey).toString()
|
const subscriptionServerKey = urlBase64ToUint8Array(vapidKey).toString()
|
||||||
|
@ -114,10 +110,10 @@ async function removePushNotificationDataOnError(e: Error) {
|
||||||
async function sendSubscriptionToBackend(
|
async function sendSubscriptionToBackend(
|
||||||
subscription: PushSubscription,
|
subscription: PushSubscription,
|
||||||
data: CreatePushNotification,
|
data: CreatePushNotification,
|
||||||
policy: SubscriptionPolicy,
|
policy: mastodon.v1.SubscriptionPolicy,
|
||||||
): Promise<MastoPushSubscription> {
|
): Promise<mastodon.v1.WebPushSubscription> {
|
||||||
const { endpoint, keys } = subscription.toJSON()
|
const { endpoint, keys } = subscription.toJSON()
|
||||||
const params: CreatePushSubscriptionParams = {
|
const params: mastodon.v1.CreateWebPushSubscriptionParams = {
|
||||||
policy,
|
policy,
|
||||||
subscription: {
|
subscription: {
|
||||||
endpoint: endpoint!,
|
endpoint: endpoint!,
|
||||||
|
@ -129,5 +125,5 @@ async function sendSubscriptionToBackend(
|
||||||
data,
|
data,
|
||||||
}
|
}
|
||||||
|
|
||||||
return await useMasto().pushSubscriptions.create(params)
|
return await useMasto().v1.webPushSubscriptions.create(params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Emoji, PushSubscription as MastoPushSubscription, PushSubscriptionAlerts, SubscriptionPolicy } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
import type { UserLogin } from '~/types'
|
import type { UserLogin } from '~/types'
|
||||||
|
|
||||||
|
@ -9,18 +9,18 @@ export interface PushManagerSubscriptionInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequiredUserLogin extends Required<Omit<UserLogin, 'account' | 'pushSubscription'>> {
|
export interface RequiredUserLogin extends Required<Omit<UserLogin, 'account' | 'pushSubscription'>> {
|
||||||
pushSubscription?: MastoPushSubscription
|
pushSubscription?: mastodon.v1.WebPushSubscription
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreatePushNotification {
|
export interface CreatePushNotification {
|
||||||
alerts?: Partial<PushSubscriptionAlerts> | null
|
alerts?: Partial<mastodon.v1.WebPushSubscriptionAlerts> | null
|
||||||
policy?: SubscriptionPolicy
|
policy?: mastodon.v1.SubscriptionPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PushNotificationRequest = Record<string, boolean>
|
export type PushNotificationRequest = Record<string, boolean>
|
||||||
export type PushNotificationPolicy = Record<string, SubscriptionPolicy>
|
export type PushNotificationPolicy = Record<string, mastodon.v1.SubscriptionPolicy>
|
||||||
|
|
||||||
export interface CustomEmojisInfo {
|
export interface CustomEmojisInfo {
|
||||||
lastUpdate: number
|
lastUpdate: number
|
||||||
emojis: Emoji[]
|
emojis: mastodon.v1.CustomEmoji[]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { SubscriptionPolicy } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
import type {
|
import type {
|
||||||
CreatePushNotification,
|
CreatePushNotification,
|
||||||
PushNotificationPolicy,
|
PushNotificationPolicy,
|
||||||
|
@ -62,7 +62,7 @@ export const usePushManager = () => {
|
||||||
|
|
||||||
const subscribe = async (
|
const subscribe = async (
|
||||||
notificationData?: CreatePushNotification,
|
notificationData?: CreatePushNotification,
|
||||||
policy?: SubscriptionPolicy,
|
policy?: mastodon.v1.SubscriptionPolicy,
|
||||||
force?: boolean,
|
force?: boolean,
|
||||||
): Promise<SubscriptionResult> => {
|
): Promise<SubscriptionResult> => {
|
||||||
if (!isSupported)
|
if (!isSupported)
|
||||||
|
@ -117,7 +117,7 @@ export const usePushManager = () => {
|
||||||
await removePushNotificationData(currentUser.value)
|
await removePushNotificationData(currentUser.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveSettings = async (policy?: SubscriptionPolicy) => {
|
const saveSettings = async (policy?: mastodon.v1.SubscriptionPolicy) => {
|
||||||
if (policy)
|
if (policy)
|
||||||
pushNotificationData.value.policy = policy
|
pushNotificationData.value.policy = policy
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ export const usePushManager = () => {
|
||||||
if (policyChanged)
|
if (policyChanged)
|
||||||
await subscribe(data, policy, true)
|
await subscribe(data, policy, true)
|
||||||
else
|
else
|
||||||
currentUser.value.pushSubscription = await masto.pushSubscriptions.update({ data })
|
currentUser.value.pushSubscription = await masto.v1.webPushSubscriptions.update({ data })
|
||||||
|
|
||||||
policyChanged && await nextTick()
|
policyChanged && await nextTick()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
export const navigateToStatus = ({ status, focusReply = false }: { status: Status; focusReply?: boolean }) => navigateTo({ path: getStatusRoute(status).href, state: { focusReply } })
|
export const navigateToStatus = ({ status, focusReply = false }: { status: mastodon.v1.Status; focusReply?: boolean }) => navigateTo({ path: getStatusRoute(status).href, state: { focusReply } })
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import type { Status } from 'masto'
|
import type { mastodon } from 'masto'
|
||||||
|
|
||||||
const maxDistance = 10
|
const maxDistance = 10
|
||||||
const maxSteps = 1000
|
const maxSteps = 1000
|
||||||
|
|
||||||
// Checks if (b) is a reply to (a)
|
// Checks if (b) is a reply to (a)
|
||||||
function areStatusesConsecutive(a: Status, b: Status) {
|
function areStatusesConsecutive(a: mastodon.v1.Status, b: mastodon.v1.Status) {
|
||||||
const inReplyToId = b.inReplyToId ?? b.reblog?.inReplyToId
|
const inReplyToId = b.inReplyToId ?? b.reblog?.inReplyToId
|
||||||
return !!inReplyToId && (inReplyToId === a.reblog?.id || inReplyToId === a.id)
|
return !!inReplyToId && (inReplyToId === a.reblog?.id || inReplyToId === a.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reorderedTimeline(items: Status[]) {
|
export function reorderedTimeline(items: mastodon.v1.Status[]) {
|
||||||
let steps = 0
|
let steps = 0
|
||||||
const newItems = [...items]
|
const newItems = [...items]
|
||||||
for (let i = items.length - 1; i > 0; i--) {
|
for (let i = items.length - 1; i > 0; i--) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const MentionSuggestion: Partial<SuggestionOptions> = {
|
||||||
if (query.length === 0)
|
if (query.length === 0)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
const mentionPaginator = useMasto().search({ q: query, type: 'accounts', limit: 25, resolve: true })
|
const mentionPaginator = useMasto().v2.search({ q: query, type: 'accounts', limit: 25, resolve: true })
|
||||||
const results = await mentionPaginator.next()
|
const results = await mentionPaginator.next()
|
||||||
|
|
||||||
return results.value.accounts
|
return results.value.accounts
|
||||||
|
@ -29,7 +29,7 @@ export const HashtagSuggestion: Partial<SuggestionOptions> = {
|
||||||
if (query.length === 0)
|
if (query.length === 0)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
const paginator = useMasto().search({ q: query, type: 'hashtags', limit: 25, resolve: true })
|
const paginator = useMasto().v2.search({ q: query, type: 'hashtags', limit: 25, resolve: true })
|
||||||
const results = await paginator.next()
|
const results = await paginator.next()
|
||||||
|
|
||||||
return results.value.hashtags
|
return results.value.hashtags
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { login as loginMasto } from 'masto'
|
import { login as loginMasto } from 'masto'
|
||||||
import type { Account, AccountCredentials, Instance, MastoClient, WsEvents } from 'masto'
|
import type { WsEvents, mastodon } from 'masto'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
import type { RemovableRef } from '@vueuse/core'
|
import type { RemovableRef } from '@vueuse/core'
|
||||||
import type { ElkMasto, UserLogin } from '~/types'
|
import type { ElkMasto, UserLogin } from '~/types'
|
||||||
|
@ -40,7 +40,7 @@ const initializeUsers = async (): Promise<Ref<UserLogin[]> | RemovableRef<UserLo
|
||||||
}
|
}
|
||||||
|
|
||||||
const users = await initializeUsers()
|
const users = await initializeUsers()
|
||||||
const instances = useLocalStorage<Record<string, Instance>>(STORAGE_KEY_SERVERS, mock ? mock.server : {}, { deep: true })
|
const instances = useLocalStorage<Record<string, mastodon.v2.Instance>>(STORAGE_KEY_SERVERS, mock ? mock.server : {}, { deep: true })
|
||||||
const currentUserId = useLocalStorage<string>(STORAGE_KEY_CURRENT_USER, mock ? mock.user.account.id : '')
|
const currentUserId = useLocalStorage<string>(STORAGE_KEY_CURRENT_USER, mock ? mock.user.account.id : '')
|
||||||
|
|
||||||
export const currentUser = computed<UserLogin | undefined>(() => {
|
export const currentUser = computed<UserLogin | undefined>(() => {
|
||||||
|
@ -53,8 +53,8 @@ export const currentUser = computed<UserLogin | undefined>(() => {
|
||||||
return users.value[0]
|
return users.value[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
const publicInstance = ref<Instance | null>(null)
|
const publicInstance = ref<mastodon.v2.Instance | null>(null)
|
||||||
export const currentInstance = computed<null | Instance>(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value)
|
export const currentInstance = computed<null | mastodon.v2.Instance>(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value)
|
||||||
|
|
||||||
export const publicServer = ref('')
|
export const publicServer = ref('')
|
||||||
export const currentServer = computed<string>(() => currentUser.value?.server || publicServer.value)
|
export const currentServer = computed<string>(() => currentUser.value?.server || publicServer.value)
|
||||||
|
@ -91,7 +91,7 @@ if (process.client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const currentUserHandle = computed(() => currentUser.value?.account.id
|
export const currentUserHandle = computed(() => currentUser.value?.account.id
|
||||||
? `${currentUser.value.account.acct}@${currentInstance.value?.uri || currentServer.value}`
|
? `${currentUser.value.account.acct}@${currentInstance.value?.domain || currentServer.value}`
|
||||||
: '[anonymous]',
|
: '[anonymous]',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ export const useUsers = () => users
|
||||||
|
|
||||||
export const characterLimit = computed(() => currentInstance.value?.configuration.statuses.maxCharacters ?? DEFAULT_POST_CHARS_LIMIT)
|
export const characterLimit = computed(() => currentInstance.value?.configuration.statuses.maxCharacters ?? DEFAULT_POST_CHARS_LIMIT)
|
||||||
|
|
||||||
async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCredentials }) {
|
async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: mastodon.v1.AccountCredentials }) {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const server = user?.server || route.params.server as string || publicServer.value
|
const server = user?.server || route.params.server as string || publicServer.value
|
||||||
|
@ -107,29 +107,27 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCr
|
||||||
url: `https://${server}`,
|
url: `https://${server}`,
|
||||||
accessToken: user?.token,
|
accessToken: user?.token,
|
||||||
disableVersionCheck: true,
|
disableVersionCheck: true,
|
||||||
// Suppress warning of `masto/fetch` usage
|
|
||||||
disableExperimentalWarning: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!user?.token) {
|
if (!user?.token) {
|
||||||
publicServer.value = server
|
publicServer.value = server
|
||||||
publicInstance.value = await masto.instances.fetch()
|
publicInstance.value = await masto.v2.instance.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
const [me, instance, pushSubscription] = await Promise.all([
|
const [me, instance, pushSubscription] = await Promise.all([
|
||||||
masto.accounts.verifyCredentials(),
|
masto.v1.accounts.verifyCredentials(),
|
||||||
masto.instances.fetch(),
|
masto.v2.instance.fetch(),
|
||||||
// if PWA is not enabled, don't get push subscription
|
// if PWA is not enabled, don't get push subscription
|
||||||
useRuntimeConfig().public.pwaEnabled
|
useRuntimeConfig().public.pwaEnabled
|
||||||
// we get 404 response instead empty data
|
// we get 404 response instead empty data
|
||||||
? masto.pushSubscriptions.fetch().catch(() => Promise.resolve(undefined))
|
? masto.v1.webPushSubscriptions.fetch().catch(() => Promise.resolve(undefined))
|
||||||
: Promise.resolve(undefined),
|
: Promise.resolve(undefined),
|
||||||
])
|
])
|
||||||
|
|
||||||
if (!me.acct.includes('@'))
|
if (!me.acct.includes('@'))
|
||||||
me.acct = `${me.acct}@${instance.uri}`
|
me.acct = `${me.acct}@${instance.domain}`
|
||||||
|
|
||||||
user.account = me
|
user.account = me
|
||||||
user.pushSubscription = pushSubscription
|
user.pushSubscription = pushSubscription
|
||||||
|
@ -159,7 +157,7 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCr
|
||||||
return masto
|
return masto
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setAccountInfo(userId: string, account: AccountCredentials) {
|
export function setAccountInfo(userId: string, account: mastodon.v1.AccountCredentials) {
|
||||||
const index = getUsersIndexByUserId(userId)
|
const index = getUsersIndexByUserId(userId)
|
||||||
if (index === -1)
|
if (index === -1)
|
||||||
return false
|
return false
|
||||||
|
@ -169,9 +167,9 @@ export function setAccountInfo(userId: string, account: AccountCredentials) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pullMyAccountInfo() {
|
export async function pullMyAccountInfo() {
|
||||||
const account = await useMasto().accounts.verifyCredentials()
|
const account = await useMasto().v1.accounts.verifyCredentials()
|
||||||
if (!account.acct.includes('@'))
|
if (!account.acct.includes('@'))
|
||||||
account.acct = `${account.acct}@${currentInstance.value!.uri}`
|
account.acct = `${account.acct}@${currentInstance.value!.domain}`
|
||||||
|
|
||||||
setAccountInfo(currentUserId.value, account)
|
setAccountInfo(currentUserId.value, account)
|
||||||
cacheAccount(account, currentServer.value, true)
|
cacheAccount(account, currentServer.value, true)
|
||||||
|
@ -216,7 +214,7 @@ export async function removePushNotifications(user: UserLogin) {
|
||||||
|
|
||||||
// unsubscribe push notifications
|
// unsubscribe push notifications
|
||||||
try {
|
try {
|
||||||
await useMasto().pushSubscriptions.remove()
|
await useMasto().v1.webPushSubscriptions.remove()
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
// ignore
|
// ignore
|
||||||
|
@ -274,7 +272,7 @@ export const useNotifications = () => {
|
||||||
if (!isMastoInitialised.value || !id || notifications[id] || !currentUser.value?.token)
|
if (!isMastoInitialised.value || !id || notifications[id] || !currentUser.value?.token)
|
||||||
return
|
return
|
||||||
|
|
||||||
const stream = masto.stream.streamUser()
|
const stream = masto.v1.stream.streamUser()
|
||||||
notifications[id] = [stream, 0]
|
notifications[id] = [stream, 0]
|
||||||
;(await stream).on('notification', () => {
|
;(await stream).on('notification', () => {
|
||||||
if (notifications[id])
|
if (notifications[id])
|
||||||
|
@ -330,13 +328,13 @@ export function useUserLocalStorage<T extends object>(key: string, initial: () =
|
||||||
/**
|
/**
|
||||||
* Clear all storages for the given account
|
* Clear all storages for the given account
|
||||||
*/
|
*/
|
||||||
export function clearUserLocalStorage(account?: Account) {
|
export function clearUserLocalStorage(account?: mastodon.v1.Account) {
|
||||||
if (!account)
|
if (!account)
|
||||||
account = currentUser.value?.account
|
account = currentUser.value?.account
|
||||||
if (!account)
|
if (!account)
|
||||||
return
|
return
|
||||||
|
|
||||||
const id = `${account.acct}@${currentInstance.value?.uri || currentServer.value}`
|
const id = `${account.acct}@${currentInstance.value?.domain || currentServer.value}`
|
||||||
// @ts-expect-error bind value to the function
|
// @ts-expect-error bind value to the function
|
||||||
;(useUserLocalStorage._ as Map<string, Ref<Record<string, any>>>).forEach((storage) => {
|
;(useUserLocalStorage._ as Map<string, Ref<Record<string, any>>>).forEach((storage) => {
|
||||||
if (storage.value[id])
|
if (storage.value[id])
|
||||||
|
@ -345,8 +343,8 @@ export function clearUserLocalStorage(account?: Account) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createMasto = () => {
|
export const createMasto = () => {
|
||||||
const api = shallowRef<MastoClient | null>(null)
|
const api = shallowRef<mastodon.Client | null>(null)
|
||||||
const apiPromise = ref<Promise<MastoClient> | null>(null)
|
const apiPromise = ref<Promise<mastodon.Client> | null>(null)
|
||||||
const initialised = computed(() => !!api.value)
|
const initialised = computed(() => !!api.value)
|
||||||
|
|
||||||
const masto = new Proxy({} as ElkMasto, {
|
const masto = new Proxy({} as ElkMasto, {
|
||||||
|
@ -355,7 +353,7 @@ export const createMasto = () => {
|
||||||
return initialised
|
return initialised
|
||||||
|
|
||||||
if (key === 'loginTo') {
|
if (key === 'loginTo') {
|
||||||
return (...args: any[]): Promise<MastoClient> => {
|
return (...args: any[]): Promise<mastodon.Client> => {
|
||||||
return apiPromise.value = loginTo(...args).then((r) => {
|
return apiPromise.value = loginTo(...args).then((r) => {
|
||||||
api.value = r
|
api.value = r
|
||||||
return masto
|
return masto
|
||||||
|
@ -370,7 +368,7 @@ export const createMasto = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api.value && key in api.value)
|
if (api.value && key in api.value)
|
||||||
return api.value[key as keyof MastoClient]
|
return api.value[key as keyof mastodon.Client]
|
||||||
|
|
||||||
if (!api.value) {
|
if (!api.value) {
|
||||||
return new Proxy({}, {
|
return new Proxy({}, {
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
await masto.loginTo(currentUser.value)
|
await masto.loginTo(currentUser.value)
|
||||||
|
|
||||||
// If we're logged in, search for the local id the account or status corresponds to
|
// If we're logged in, search for the local id the account or status corresponds to
|
||||||
const { value } = await masto.search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }).next()
|
const { value } = await masto.v2.search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }).next()
|
||||||
|
|
||||||
const { accounts, statuses } = value
|
const { accounts, statuses } = value
|
||||||
if (statuses[0])
|
if (statuses[0])
|
||||||
|
|
|
@ -41,10 +41,7 @@ export default defineNuxtConfig({
|
||||||
],
|
],
|
||||||
alias: {
|
alias: {
|
||||||
'querystring': 'rollup-plugin-node-polyfills/polyfills/qs',
|
'querystring': 'rollup-plugin-node-polyfills/polyfills/qs',
|
||||||
'masto/fetch': 'masto/fetch',
|
|
||||||
'masto': 'masto/fetch',
|
|
||||||
'change-case': 'scule',
|
'change-case': 'scule',
|
||||||
'semver': 'unenv/runtime/mock/empty',
|
|
||||||
},
|
},
|
||||||
imports: {
|
imports: {
|
||||||
dirs: [
|
dirs: [
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
"iso-639-1": "^2.1.15",
|
"iso-639-1": "^2.1.15",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lru-cache": "^7.14.1",
|
"lru-cache": "^7.14.1",
|
||||||
"masto": "^4.11.1",
|
"masto": "^5.1.2",
|
||||||
"pinia": "^2.0.28",
|
"pinia": "^2.0.28",
|
||||||
"shiki": "^0.12.1",
|
"shiki": "^0.12.1",
|
||||||
"shiki-es": "^0.1.2",
|
"shiki-es": "^0.1.2",
|
||||||
|
|
|
@ -20,7 +20,7 @@ const { data: status, pending, refresh: refreshStatus } = useAsyncData(
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(
|
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(
|
||||||
`context:${id}`,
|
`context:${id}`,
|
||||||
async () => masto.statuses.fetchContext(id),
|
async () => masto.v1.statuses.fetchContext(id),
|
||||||
{ watch: [isMastoInitialised], immediate: isMastoInitialised.value },
|
{ watch: [isMastoInitialised], immediate: isMastoInitialised.value },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const handle = $(computedEager(() => params.account as string))
|
||||||
definePageMeta({ name: 'account-followers' })
|
definePageMeta({ name: 'account-followers' })
|
||||||
|
|
||||||
const account = await fetchAccountByHandle(handle)
|
const account = await fetchAccountByHandle(handle)
|
||||||
const paginator = account ? useMasto().accounts.iterateFollowers(account.id, {}) : null
|
const paginator = account ? useMasto().v1.accounts.listFollowers(account.id, {}) : null
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
useHeadFixed({
|
useHeadFixed({
|
||||||
|
|
|
@ -6,7 +6,7 @@ const handle = $(computedEager(() => params.account as string))
|
||||||
definePageMeta({ name: 'account-following' })
|
definePageMeta({ name: 'account-following' })
|
||||||
|
|
||||||
const account = await fetchAccountByHandle(handle)
|
const account = await fetchAccountByHandle(handle)
|
||||||
const paginator = account ? useMasto().accounts.iterateFollowing(account.id, {}) : null
|
const paginator = account ? useMasto().v1.accounts.listFollowing(account.id, {}) : null
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
useHeadFixed({
|
useHeadFixed({
|
||||||
|
|
|
@ -8,7 +8,7 @@ const { t } = useI18n()
|
||||||
|
|
||||||
const account = await fetchAccountByHandle(handle)
|
const account = await fetchAccountByHandle(handle)
|
||||||
|
|
||||||
const paginator = useMasto().accounts.iterateStatuses(account.id, { excludeReplies: true })
|
const paginator = useMasto().v1.accounts.listStatuses(account.id, { excludeReplies: true })
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
useHeadFixed({
|
useHeadFixed({
|
||||||
|
|
|
@ -7,7 +7,7 @@ const handle = $(computedEager(() => params.account as string))
|
||||||
|
|
||||||
const account = await fetchAccountByHandle(handle)
|
const account = await fetchAccountByHandle(handle)
|
||||||
|
|
||||||
const paginator = useMasto().accounts.iterateStatuses(account.id, { onlyMedia: true, excludeReplies: false })
|
const paginator = useMasto().v1.accounts.listStatuses(account.id, { onlyMedia: true, excludeReplies: false })
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
useHeadFixed({
|
useHeadFixed({
|
||||||
|
|
|
@ -7,7 +7,7 @@ const handle = $(computedEager(() => params.account as string))
|
||||||
|
|
||||||
const account = await fetchAccountByHandle(handle)
|
const account = await fetchAccountByHandle(handle)
|
||||||
|
|
||||||
const paginator = useMasto().accounts.iterateStatuses(account.id, { excludeReplies: false })
|
const paginator = useMasto().v1.accounts.listStatuses(account.id, { excludeReplies: false })
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
useHeadFixed({
|
useHeadFixed({
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS } from '~~/constants'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const paginator = useMasto().trends.iterateStatuses()
|
const paginator = useMasto().v1.trends.listStatuses()
|
||||||
|
|
||||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS, false)
|
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS, false)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS } from '~~/constants'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const paginator = useMasto().trends.links
|
const paginator = useMasto().v1.trends.listLinks()
|
||||||
|
|
||||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS, false)
|
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS, false)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const { t } = useI18n()
|
||||||
|
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const { data, pending, error } = useLazyAsyncData(
|
const { data, pending, error } = useLazyAsyncData(
|
||||||
() => masto.trends.fetchTags({ limit: 20 }),
|
async () => masto.v1.trends.listTags({ limit: 20 }),
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ const { t } = useI18n()
|
||||||
// limit: 20 is the default configuration of the official client
|
// limit: 20 is the default configuration of the official client
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const { data, pending, error } = useLazyAsyncData(
|
const { data, pending, error } = useLazyAsyncData(
|
||||||
() => masto.suggestions.fetchAll({ limit: 20 }),
|
async () => masto.v2.suggestions.list({ limit: 20 }),
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ const params = useRoute().params
|
||||||
const tagName = $(computedEager(() => params.tag as string))
|
const tagName = $(computedEager(() => params.tag as string))
|
||||||
|
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
const { data: tag, refresh } = $(await useAsyncData(() => masto.tags.fetch(tagName), { watch: [isMastoInitialised], immediate: isMastoInitialised.value }))
|
const { data: tag, refresh } = $(await useAsyncData(() => masto.v1.tags.fetch(tagName), { watch: [isMastoInitialised], immediate: isMastoInitialised.value }))
|
||||||
|
|
||||||
const paginator = masto.timelines.iterateHashtag(tagName)
|
const paginator = masto.v1.timelines.listHashtag(tagName)
|
||||||
const stream = masto.stream.streamTagTimeline(tagName)
|
const stream = masto.v1.stream.streamTagTimeline(tagName)
|
||||||
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
||||||
|
|
||||||
if (tag) {
|
if (tag) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue