Skip to content

Commit

Permalink
refactor: upgrade masto 5 (elk-zone#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jan 8, 2023
1 parent 39034c5 commit 5c8f75b
Show file tree
Hide file tree
Showing 108 changed files with 438 additions and 445 deletions.
4 changes: 2 additions & 2 deletions components/account/AccountAvatar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
square?: boolean
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountBigAvatar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
// Avatar with a background base achieving a 3px border to be used in status cards
// The border is used for Avatar on Avatar for reblogs and connecting replies
defineProps<{
account: Account
account: mastodon.v1.Account
square?: boolean
}>()
</script>
Expand Down
5 changes: 3 additions & 2 deletions components/account/AccountBigCard.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts" setup>
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account, as = 'div' } = $defineProps<{
account: Account
account: mastodon.v1.Account
as?: string
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountCard.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
hoverCard?: boolean
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountDisplayName.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
}>()
</script>

Expand Down
12 changes: 6 additions & 6 deletions components/account/AccountFollowButton.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Account, Relationship } from 'masto'
import type { mastodon } from 'masto'
const { account, command, ...props } = defineProps<{
account: Account
relationship?: Relationship
account: mastodon.v1.Account
relationship?: mastodon.v1.Relationship
command?: boolean
}>()
Expand All @@ -15,7 +15,7 @@ const masto = useMasto()
async function toggleFollow() {
relationship!.following = !relationship!.following
try {
const newRel = await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
const newRel = await masto.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
Object.assign(relationship!, newRel)
}
catch {
Expand All @@ -27,7 +27,7 @@ async function toggleFollow() {
async function unblock() {
relationship!.blocking = false
try {
const newRel = await masto.accounts.unblock(account.id)
const newRel = await masto.v1.accounts.unblock(account.id)
Object.assign(relationship!, newRel)
}
catch {
Expand All @@ -39,7 +39,7 @@ async function unblock() {
async function unmute() {
relationship!.muting = false
try {
const newRel = await masto.accounts.unmute(account.id)
const newRel = await masto.v1.accounts.unmute(account.id)
Object.assign(relationship!, newRel)
}
catch {
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountHandle.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const serverName = $computed(() => getServerName(account))
Expand Down
12 changes: 6 additions & 6 deletions components/account/AccountHeader.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account, Field } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
command?: boolean
}>()
Expand All @@ -14,8 +14,8 @@ const createdAt = $(useFormattedDateTime(() => account.createdAt, {
year: 'numeric',
}))
const namedFields = ref<Field[]>([])
const iconFields = ref<Field[]>([])
const namedFields = ref<mastodon.v1.AccountField[]>([])
const iconFields = ref<mastodon.v1.AccountField[]>([])
function getFieldIconTitle(fieldName: string) {
return fieldName === 'Joined' ? t('account.joined') : fieldName
Expand All @@ -40,8 +40,8 @@ function previewAvatar() {
}
watchEffect(() => {
const named: Field[] = []
const icons: Field[] = []
const named: mastodon.v1.AccountField[] = []
const icons: mastodon.v1.AccountField[] = []
account.fields?.forEach((field) => {
const icon = getAccountFieldIcon(field.name)
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountHoverCard.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const relationship = $(useRelationship(account))
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountHoverWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const props = defineProps<{
account?: Account
account?: mastodon.v1.Account
handle?: string
disabled?: boolean
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountInfo.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account, as = 'div' } = defineProps<{
account: Account
account: mastodon.v1.Account
as?: string
hoverCard?: boolean
square?: boolean
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountInlineInfo.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { link = true, avatar = true } = defineProps<{
account: Account
account: mastodon.v1.Account
link?: boolean
avatar?: boolean
}>()
Expand Down
12 changes: 6 additions & 6 deletions components/account/AccountMoreButton.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const { account } = defineProps<{
account: Account
account: mastodon.v1.Account
command?: boolean
}>()
let relationship = $(useRelationship(account))
Expand All @@ -15,24 +15,24 @@ const toggleMute = async () => {
relationship!.muting = !relationship!.muting
relationship = relationship!.muting
? await masto.accounts.mute(account.id, {
? await masto.v1.accounts.mute(account.id, {
// TODO support more options
})
: await masto.accounts.unmute(account.id)
: await masto.v1.accounts.unmute(account.id)
}
const toggleBlockUser = async () => {
// TODO: Add confirmation
relationship!.blocking = !relationship!.blocking
relationship = await masto.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
relationship = await masto.v1.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
}
const toggleBlockDomain = async () => {
// TODO: Add confirmation
relationship!.domainBlocking = !relationship!.domainBlocking
await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
await masto.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
}
</script>

Expand Down
11 changes: 4 additions & 7 deletions components/account/AccountMoved.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script setup lang="ts">
// type used in <template>
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type { Account } from 'masto'
import type { mastodon } from 'masto'
defineProps<{
account: Account
account: mastodon.v1.Account
}>()
</script>

Expand All @@ -16,9 +14,8 @@ defineProps<{
</div>

<div flex>
<!-- type error of masto.js -->
<NuxtLink :to="getAccountRoute(account.moved as unknown as Account)">
<AccountInfo :account="account.moved as unknown as Account" />
<NuxtLink :to="getAccountRoute(account.moved!)">
<AccountInfo :account="account.moved!" />
</NuxtLink>
<div flex-auto />
<div flex items-center>
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountPaginator.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account, Paginator } from 'masto'
import type { Paginator, mastodon } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Account[]>
paginator: Paginator<mastodon.v1.Account[], mastodon.DefaultPaginationParams>
}>()
</script>

Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountPostsFollowers.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Account } from 'masto'
import type { mastodon } from 'masto'
const props = defineProps<{
account: Account
account: mastodon.v1.Account
}>()
const { formatHumanReadableNumber, formatNumber, forSR } = useHumanReadableNumber()
Expand Down
2 changes: 1 addition & 1 deletion components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
eventType = 'update',
preprocess,
} = defineProps<{
paginator: Paginator<any, any[]>
paginator: Paginator<any[], any>
keyProp?: string
virtualScroller?: boolean
stream?: Promise<WsEvents>
Expand Down
4 changes: 2 additions & 2 deletions components/common/CommonTrending.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" setup>
import type { History } from 'masto'
import type { mastodon } from 'masto'
const {
history,
maxDay = 2,
} = $defineProps<{
history: History[]
history: mastodon.v1.TagHistory[]
maxDay?: number
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/common/CommonTrendingCharts.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script lang="ts" setup>
import type { History } from 'masto'
import type { mastodon } from 'masto'
import sparkline from '@fnando/sparkline'
const {
history,
width = 60,
height = 40,
} = $defineProps<{
history?: History[]
history?: mastodon.v1.TagHistory[]
width?: number
height?: number
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/content/ContentRich.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Emoji } from 'masto'
import type { mastodon } from 'masto'

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

Expand Down
4 changes: 2 additions & 2 deletions components/conversation/ConversationCard.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Conversation } from 'masto'
import type { mastodon } from 'masto'
const { conversation } = defineProps<{
conversation: Conversation
conversation: mastodon.v1.Conversation
}>()
const withAccounts = $computed(() =>
Expand Down
4 changes: 2 additions & 2 deletions components/conversation/ConversationPaginator.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Conversation, Paginator } from 'masto'
import type { Paginator, mastodon } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Conversation[]>
paginator: Paginator<mastodon.v1.Conversation[], mastodon.DefaultPaginationParams>
}>()
</script>

Expand Down
4 changes: 2 additions & 2 deletions components/modal/ModalContainer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Status } from 'masto'
import type { mastodon } from 'masto'
import type { ConfirmDialogChoice } from '~/types'
import {
isCommandPanelOpen,
Expand Down Expand Up @@ -30,7 +30,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {
}
})
const handlePublished = (status: Status) => {
const handlePublished = (status: mastodon.v1.Status) => {
lastPublishDialogStatus.value = status
isPublishDialogOpen.value = false
}
Expand Down
4 changes: 2 additions & 2 deletions components/modal/ModalMediaPreviewCarousel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { SwipeDirection } from '@vueuse/core'
import { useReducedMotion } from '@vueuse/motion'
import type { Attachment } from 'masto'
import type { mastodon } from 'masto'
const { media = [], threshold = 20 } = defineProps<{
media?: Attachment[]
media?: mastodon.v1.MediaAttachment[]
threshold?: number
}>()
Expand Down
4 changes: 2 additions & 2 deletions components/notification/NotificationCard.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Notification } from 'masto'
import type { mastodon } from 'masto'
const { notification } = defineProps<{
notification: Notification
notification: mastodon.v1.Notification
}>()
</script>

Expand Down
Loading

0 comments on commit 5c8f75b

Please sign in to comment.