chore: upgrade to VueUse v10
This commit is contained in:
parent
076c47b7b0
commit
61526df93f
8 changed files with 106 additions and 61 deletions
|
@ -1,4 +1,4 @@
|
|||
import type { MaybeComputedRef, MaybeRef, UseTimeAgoOptions } from '@vueuse/core'
|
||||
import type { MaybeRef, MaybeRefOrGetter, UseTimeAgoOptions } from '@vueuse/core'
|
||||
|
||||
const formatter = Intl.NumberFormat()
|
||||
|
||||
|
@ -29,7 +29,7 @@ export function useHumanReadableNumber() {
|
|||
}
|
||||
}
|
||||
|
||||
export function useFormattedDateTime(value: MaybeComputedRef<string | number | Date | undefined | null>,
|
||||
export function useFormattedDateTime(value: MaybeRefOrGetter<string | number | Date | undefined | null>,
|
||||
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' }) {
|
||||
const { locale } = useI18n()
|
||||
const formatter = $computed(() => Intl.DateTimeFormat(locale.value, options))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { MaybeComputedRef, RemovableRef } from '@vueuse/core'
|
||||
import type { MaybeRefOrGetter, RemovableRef } from '@vueuse/core'
|
||||
import type { Ref } from 'vue'
|
||||
import type { UseIDBOptions } from '@vueuse/integrations/useIDBKeyval'
|
||||
import { del, get, set, update } from '~/utils/elk-idb'
|
||||
|
@ -7,7 +7,7 @@ const isIDBSupported = !process.test && typeof indexedDB !== 'undefined'
|
|||
|
||||
export async function useAsyncIDBKeyval<T>(
|
||||
key: IDBValidKey,
|
||||
initialValue: MaybeComputedRef<T>,
|
||||
initialValue: MaybeRefOrGetter<T>,
|
||||
options: UseIDBOptions = {},
|
||||
): Promise<RemovableRef<T>> {
|
||||
const {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import type { MaybeComputedRef } from '@vueuse/core'
|
||||
import type { MaybeRefOrGetter } from '@vueuse/core'
|
||||
import type { Paginator, mastodon } from 'masto'
|
||||
import type { RouteLocation } from 'vue-router'
|
||||
|
||||
export type UseSearchOptions = MaybeComputedRef<
|
||||
export type UseSearchOptions = MaybeRefOrGetter<
|
||||
Partial<Omit<mastodon.v1.SearchParams, keyof mastodon.DefaultPaginationParams | 'q'>>
|
||||
>
|
||||
|
||||
|
@ -20,7 +20,7 @@ export type StatusSearchResult = BuildSearchResult<'status', mastodon.v1.Status>
|
|||
|
||||
export type SearchResult = HashTagSearchResult | AccountSearchResult | StatusSearchResult
|
||||
|
||||
export function useSearch(query: MaybeComputedRef<string>, options: UseSearchOptions = {}) {
|
||||
export function useSearch(query: MaybeRefOrGetter<string>, options: UseSearchOptions = {}) {
|
||||
const done = ref(false)
|
||||
const { client } = $(useMasto())
|
||||
const loading = ref(false)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { withoutProtocol } from 'ufo'
|
||||
import type { mastodon } from 'masto'
|
||||
import type { EffectScope, Ref } from 'vue'
|
||||
import type { MaybeComputedRef, RemovableRef } from '@vueuse/core'
|
||||
import type { MaybeRefOrGetter, RemovableRef } from '@vueuse/core'
|
||||
import type { ElkMasto } from './masto/masto'
|
||||
import type { UserLogin } from '~/types'
|
||||
import type { Overwrite } from '~/types/utils'
|
||||
|
@ -114,7 +114,7 @@ if (process.client) {
|
|||
export function useUsers() {
|
||||
return users
|
||||
}
|
||||
export function useSelfAccount(user: MaybeComputedRef<mastodon.v1.Account | undefined>) {
|
||||
export function useSelfAccount(user: MaybeRefOrGetter<mastodon.v1.Account | undefined>) {
|
||||
return computed(() => currentUser.value && resolveUnref(user)?.id === currentUser.value.account.id)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ export function useHydratedHead<T extends SchemaAugmentations>(input: UseHeadInp
|
|||
(input as any).title = () => isHydrated.value ? typeof title === 'function' ? title() : title : ''
|
||||
}
|
||||
}
|
||||
return useHead(() => {
|
||||
return useHead((() => {
|
||||
if (!isHydrated.value)
|
||||
return {}
|
||||
return resolveUnref(input)
|
||||
}, options)
|
||||
}) as UseHeadInput<T>, options)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue