feat: move timelines to components (#514)

pull/443/head
patak 2022-12-22 18:48:41 +01:00 zatwierdzone przez GitHub
rodzic 6b7a8baa8e
commit fef082af13
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
23 zmienionych plików z 123 dodań i 68 usunięć

Wyświetl plik

@ -5,12 +5,15 @@ provideGlobalCommands()
// We want to trigger rerendering the page when account changes
const key = computed(() => `${currentUser.value?.server ?? currentServer.value}:${currentUser.value?.account.id || ''}`)
const { params } = useRoute()
</script>
<template>
<NuxtLoadingIndicator color="repeating-linear-gradient(to right,var(--c-primary) 0%,var(--c-primary-active) 100%)" />
<NuxtLayout :key="key">
<NuxtPage v-if="isMastoInitialised" />
<!-- TODO: rework the /[account] routes to remove conditional loading -->
<NuxtPage v-if="!params.server || isMastoInitialised" />
</NuxtLayout>
<PWAPrompt />
</template>

Wyświetl plik

@ -0,0 +1,7 @@
<script setup lang="ts">
const paginator = useMasto().blocks.iterate()
</script>
<template>
<AccountPaginator :paginator="paginator" />
</template>

Wyświetl plik

@ -0,0 +1,7 @@
<script setup lang="ts">
const paginator = useMasto().bookmarks.iterate()
</script>
<template>
<TimelinePaginator :paginator="paginator" />
</template>

Wyświetl plik

@ -0,0 +1,7 @@
<script setup lang="ts">
const paginator = useMasto().conversations.iterate()
</script>
<template>
<ConversationPaginator :paginator="paginator" />
</template>

Wyświetl plik

@ -0,0 +1,21 @@
<script setup lang="ts">
const masto = useMasto()
const paginator = masto.domainBlocks.iterate()
const unblock = async (domain: string) => {
await masto.domainBlocks.unblock(domain)
}
</script>
<template>
<CommonPaginator :paginator="paginator">
<template #default="{ item }">
<CommonDropdownItem class="!cursor-auto">
{{ item }}
<template #actions>
<div i-ri:lock-unlock-line text-primary cursor-pointer @click="unblock(item)" />
</template>
</CommonDropdownItem>
</template>
</CommonPaginator>
</template>

Wyświetl plik

@ -0,0 +1,7 @@
<script setup lang="ts">
const paginator = useMasto().favourites.iterate()
</script>
<template>
<TimelinePaginator :paginator="paginator" />
</template>

Wyświetl plik

@ -0,0 +1,12 @@
<script setup lang="ts">
const paginator = useMasto().timelines.iterateHome()
const stream = await useMasto().stream.streamUser()
onBeforeUnmount(() => stream.disconnect())
</script>
<template>
<div>
<PublishWidget draft-key="home" border="b base" />
<TimelinePaginator v-bind="{ paginator, stream }" context="home" />
</div>
</template>

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,7 @@
<script setup lang="ts">
const paginator = useMasto().mutes.iterate()
</script>
<template>
<AccountPaginator :paginator="paginator" />
</template>

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -41,6 +41,6 @@ const tabs = $computed(() => [
<template #header>
<CommonRouteTabs replace :options="tabs" />
</template>
<NuxtPage />
<NuxtPage v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -3,8 +3,6 @@ definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().blocks.iterate()
useHeadFixed({
title: 'Blocked users',
})
@ -15,6 +13,7 @@ useHeadFixed({
<template #title>
<span text-lg font-bold>{{ $t('account.blocked_users') }}</span>
</template>
<AccountPaginator :paginator="paginator" />
<TimelineBlocks v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -3,8 +3,6 @@ definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().bookmarks.iterate()
const { t } = useI18n()
useHeadFixed({
@ -21,8 +19,6 @@ useHeadFixed({
</NuxtLink>
</template>
<slot>
<TimelinePaginator :paginator="paginator" />
</slot>
<TimelineBookmarks v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -3,8 +3,6 @@ definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().conversations.iterate()
const { t } = useI18n()
useHeadFixed({
@ -21,8 +19,6 @@ useHeadFixed({
</NuxtLink>
</template>
<slot>
<ConversationPaginator :paginator="paginator" />
</slot>
<TimelineConversations v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -1,17 +1,13 @@
<script setup lang="ts">
import TimelineDomainBlocks from '~~/components/timeline/TimelineDomainBlocks.vue'
definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().domainBlocks.iterate()
useHeadFixed({
title: 'Blocked domains',
})
const unblock = async (domain: string) => {
await useMasto().domainBlocks.unblock(domain)
}
</script>
<template>
@ -20,15 +16,6 @@ const unblock = async (domain: string) => {
<span text-lg font-bold>{{ $t('account.blocked_domains') }}</span>
</template>
<CommonPaginator :paginator="paginator">
<template #default="{ item }">
<CommonDropdownItem class="!cursor-auto">
{{ item }}
<template #actions>
<div i-ri:lock-unlock-line text-primary cursor-pointer @click="unblock(item)" />
</template>
</CommonDropdownItem>
</template>
</CommonPaginator>
<TimelineDomainBlocks v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -3,7 +3,6 @@ definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().favourites.iterate()
const { t } = useI18n()
useHeadFixed({
@ -19,8 +18,7 @@ useHeadFixed({
<span>{{ t('nav_side.favourites') }}</span>
</NuxtLink>
</template>
<slot>
<TimelinePaginator :paginator="paginator" />
</slot>
<TimelineFavourites v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -11,10 +11,6 @@ if (useRoute().path === '/signin/callback') {
useRouter().push('/home')
}
const paginator = useMasto().timelines.iterateHome()
const stream = await useMasto().stream.streamUser()
onBeforeUnmount(() => stream.disconnect())
const { t } = useI18n()
useHeadFixed({
title: () => t('nav_side.home'),
@ -29,9 +25,7 @@ useHeadFixed({
<span>{{ $t('nav_side.home') }}</span>
</NuxtLink>
</template>
<slot>
<PublishWidget draft-key="home" border="b base" />
<TimelinePaginator v-bind="{ paginator, stream }" context="home" />
</slot>
<TimelineHome v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -2,9 +2,6 @@
definePageMeta({
middleware: 'auth',
})
const paginator = useMasto().mutes.iterate()
useHeadFixed({
title: 'Muted users',
})
@ -15,6 +12,7 @@ useHeadFixed({
<template #title>
<span text-lg font-bold>{{ $t('account.muted_users') }}</span>
</template>
<AccountPaginator :paginator="paginator" />
<TimelineMutes v-if="isMastoInitialised" />
</MainContent>
</template>

Wyświetl plik

@ -53,6 +53,7 @@ onActivated(() => {
<template v-if="pwaEnabled">
<NotificationPreferences :show="showSettings" />
</template>
<NuxtPage />
</slot>
</MainContent>

Wyświetl plik

@ -1,19 +1,10 @@
<script setup lang="ts">
const { t } = useI18n()
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMasto().notifications.iterate({ limit: 30 })
const { clearNotifications } = useNotifications()
onActivated(clearNotifications)
const stream = await useMasto().stream.streamUser()
useHeadFixed({
title: () => `${t('tab.notifications_all')} | ${t('nav_side.notifications')}`,
})
</script>
<template>
<NotificationPaginator v-bind="{ paginator, stream }" />
<TimelineNotifications v-if="isMastoInitialised" />
</template>

Wyświetl plik

@ -1,19 +1,10 @@
<script setup lang="ts">
const { t } = useI18n()
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMasto().notifications.iterate({ limit: 30, types: ['mention'] })
const { clearNotifications } = useNotifications()
onActivated(clearNotifications)
const stream = await useMasto().stream.streamUser()
useHeadFixed({
title: () => `${t('tab.notifications_mention')} | ${t('nav_side.notifications')}`,
})
</script>
<template>
<NotificationPaginator v-bind="{ paginator, stream }" />
<TimelineNotifications v-if="isMastoInitialised" />
</template>

Wyświetl plik

@ -18,6 +18,6 @@ useHeadFixed({
<span>{{ t('account.pinned') }}</span>
</template>
<TimelinePaginator :paginator="paginator" />
<TimelinePinned v-if="isMastoInitialised" />
</MainContent>
</template>