refactor: add onMastoInit

This commit is contained in:
三咲智子 2023-01-03 17:53:31 +08:00
parent 6092b27da6
commit 6729666170
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
5 changed files with 15 additions and 22 deletions

View file

@ -7,6 +7,12 @@ export const useMasto = () => useNuxtApp().$masto as ElkMasto
export const isMastoInitialised = computed(() => process.client && useMasto().loggedIn.value)
export const onMastoInit = (cb: () => unknown) => {
watchOnce(isMastoInitialised, () => {
cb()
}, { immediate: isMastoInitialised.value })
}
// @unocss-include
export const STATUS_VISIBILITIES = [
{

View file

@ -86,7 +86,7 @@ export function usePaginator<T>(
}, 1000)
if (!isMastoInitialised.value) {
watchOnce(isMastoInitialised, () => {
onMastoInit(() => {
state.value = 'idle'
loadNext()
})