forked from Mirrors/elk
Merge branch 'main' into userquin/feat-remember-last-position
This commit is contained in:
commit
6ce5eadcac
17 changed files with 110 additions and 88 deletions
|
@ -8,5 +8,11 @@
|
|||
"jsonc/sort-keys": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"vue/no-restricted-syntax":["error", {
|
||||
"selector": "VElement[name='a']",
|
||||
"message": "Use NuxtLink instead."
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ defineOptions({
|
|||
<div w-17 h-17 rounded-full border-4 border-bg-base z-2 mt--2 ms--1>
|
||||
<AccountAvatar :account="account" />
|
||||
</div>
|
||||
<a block sm:hidden href="javascript:;" @click.stop>
|
||||
<NuxtLink block sm:hidden href="javascript:;" @click.stop>
|
||||
<AccountFollowButton :account="account" />
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div sm:mt-2>
|
||||
<AccountDisplayName :account="account" font-bold text-lg line-clamp-1 ws-pre-wrap break-all />
|
||||
|
@ -46,9 +46,9 @@ defineOptions({
|
|||
<!-- Follow info -->
|
||||
<div flex justify-between items-center>
|
||||
<AccountPostsFollowers text-sm :account="account" />
|
||||
<a sm:block hidden href="javascript:;" @click.stop>
|
||||
<NuxtLink sm:block hidden href="javascript:;" @click.stop>
|
||||
<AccountFollowButton :account="account" />
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</component>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<script setup lang="ts" generic="T, O">
|
||||
<script setup lang="ts" generic="T, O, U = T">
|
||||
// @ts-expect-error missing types
|
||||
import { DynamicScroller } from 'vue-virtual-scroller'
|
||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
||||
|
@ -10,7 +10,6 @@ const {
|
|||
keyProp = 'id',
|
||||
virtualScroller = false,
|
||||
eventType = 'update',
|
||||
buffer = 10,
|
||||
preprocess,
|
||||
} = defineProps<{
|
||||
paginator: Paginator<T[], O>
|
||||
|
@ -18,24 +17,20 @@ const {
|
|||
virtualScroller?: boolean
|
||||
stream?: Promise<WsEvents>
|
||||
eventType?: 'notification' | 'update'
|
||||
// When preprocess is used, buffer is the number of items that will be hidden
|
||||
// until the next pagination to avoid border effect between pages when reordering
|
||||
// and grouping items
|
||||
buffer?: number
|
||||
preprocess?: (items: T[]) => any[]
|
||||
preprocess?: (items: (U | T)[]) => U[]
|
||||
}>()
|
||||
|
||||
defineSlots<{
|
||||
default: {
|
||||
items: T[]
|
||||
item: T
|
||||
items: U[]
|
||||
item: U
|
||||
index: number
|
||||
active?: boolean
|
||||
older?: T
|
||||
newer?: T // newer is undefined when index === 0
|
||||
older?: U
|
||||
newer?: U // newer is undefined when index === 0
|
||||
}
|
||||
items: {
|
||||
items: T[]
|
||||
items: U[]
|
||||
}
|
||||
updater: {
|
||||
number: number
|
||||
|
|
|
@ -23,17 +23,17 @@ const emit = defineEmits<{
|
|||
</p>
|
||||
<p>
|
||||
{{ $t('help.desc_para4') }}
|
||||
<a font-bold text-primary href="/m.webtoo.ls/@elk" target="_blank">
|
||||
<NuxtLink font-bold text-primary href="/m.webtoo.ls/@elk" target="_blank">
|
||||
{{ $t('help.desc_para5') }}
|
||||
</a>
|
||||
</NuxtLink>
|
||||
{{ $t('help.desc_para6') }}
|
||||
</p>
|
||||
{{ $t('help.desc_para3') }}
|
||||
<p flex="~ gap-2 wrap" mxa>
|
||||
<template v-for="team of teams" :key="team.github">
|
||||
<a :href="`https://github.com/sponsors/${team.github}`" target="_blank" rounded-full transition duration-300 border="~ transparent" hover="scale-105 border-primary">
|
||||
<NuxtLink :href="`https://github.com/sponsors/${team.github}`" target="_blank" external rounded-full transition duration-300 border="~ transparent" hover="scale-105 border-primary">
|
||||
<img :src="`/avatars/${team.github}-100x100.png`" :alt="team.display" rounded-full w-15 h-15 height="60" width="60">
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
</p>
|
||||
<p italic flex justify-center w-full>
|
||||
|
|
|
@ -55,11 +55,17 @@ function toggleDark() {
|
|||
{{ $t('settings.about.label') }}
|
||||
</NuxtLink>
|
||||
·
|
||||
<a href="/m.webtoo.ls/@elk" target="_blank">Mastodon</a>
|
||||
<NuxtLink href="/m.webtoo.ls/@elk" target="_blank">
|
||||
Mastodon
|
||||
</NuxtLink>
|
||||
·
|
||||
<a href="https://chat.elk.zone" target="_blank">Discord</a>
|
||||
<NuxtLink href="https://chat.elk.zone" target="_blank" external>
|
||||
Discord
|
||||
</NuxtLink>
|
||||
·
|
||||
<a href="https://github.com/elk-zone" target="_blank">GitHub</a>
|
||||
<NuxtLink href="https://github.com/elk-zone" target="_blank" external>
|
||||
GitHub
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { mastodon } from 'masto'
|
||||
import type { Paginator, WsEvents } from 'masto'
|
||||
// type used in <template>
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
import type { GroupedAccountLike, GroupedLikeNotifications, GroupedNotifications, NotificationSlot } from '~/types'
|
||||
import type { Paginator, WsEvents, mastodon } from 'masto'
|
||||
import type { GroupedAccountLike, NotificationSlot } from '~/types'
|
||||
|
||||
const { paginator, stream } = defineProps<{
|
||||
paginator: Paginator<NotificationSlot[], mastodon.v1.ListNotificationsParams>
|
||||
paginator: Paginator<mastodon.v1.Notification[], mastodon.v1.ListNotificationsParams>
|
||||
stream?: Promise<WsEvents>
|
||||
}>()
|
||||
|
||||
|
@ -43,21 +40,31 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
|
|||
// This normally happens when you transfer an account, if not, show
|
||||
// a big profile card for each follow
|
||||
if (group[0].type === 'follow') {
|
||||
const toGroup = []
|
||||
let groups: mastodon.v1.Notification[] = []
|
||||
|
||||
function newGroup() {
|
||||
if (groups.length > 0) {
|
||||
results.push({
|
||||
id: `grouped-${id++}`,
|
||||
type: 'grouped-follow',
|
||||
items: groups,
|
||||
})
|
||||
groups = []
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of group) {
|
||||
const hasHeader = !item.account.header.endsWith('/original/missing.png')
|
||||
if (hasHeader && (item.account.followersCount > 250 || (group.length === 1 && item.account.followersCount > 25)))
|
||||
if (hasHeader && (item.account.followersCount > 250 || (group.length === 1 && item.account.followersCount > 25))) {
|
||||
newGroup()
|
||||
results.push(item)
|
||||
else
|
||||
toGroup.push(item)
|
||||
}
|
||||
if (toGroup.length > 0) {
|
||||
results.push({
|
||||
id: `grouped-${id++}`,
|
||||
type: `grouped-${group[0].type}`,
|
||||
items: toGroup,
|
||||
})
|
||||
}
|
||||
else {
|
||||
groups.push(item)
|
||||
}
|
||||
}
|
||||
|
||||
newGroup()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -105,7 +112,7 @@ function preprocess(items: NotificationSlot[]): NotificationSlot[] {
|
|||
const flattenedNotifications: mastodon.v1.Notification[] = []
|
||||
for (const item of items) {
|
||||
if (item.type === 'grouped-reblogs-and-favourites') {
|
||||
const group = item as GroupedLikeNotifications
|
||||
const group = item
|
||||
for (const like of group.likes) {
|
||||
if (like.reblog)
|
||||
flattenedNotifications.push(like.reblog)
|
||||
|
@ -113,11 +120,11 @@ function preprocess(items: NotificationSlot[]): NotificationSlot[] {
|
|||
flattenedNotifications.push(like.favourite)
|
||||
}
|
||||
}
|
||||
else if (item.type.startsWith('grouped-')) {
|
||||
flattenedNotifications.push(...(item as GroupedNotifications).items)
|
||||
else if (item.type === 'grouped-follow') {
|
||||
flattenedNotifications.push(...item.items)
|
||||
}
|
||||
else {
|
||||
flattenedNotifications.push(item as mastodon.v1.Notification)
|
||||
flattenedNotifications.push(item)
|
||||
}
|
||||
}
|
||||
return groupItems(flattenedNotifications)
|
||||
|
@ -143,12 +150,12 @@ const { formatNumber } = useHumanReadableNumber()
|
|||
/>
|
||||
<NotificationGroupedLikes
|
||||
v-else-if="item.type === 'grouped-reblogs-and-favourites'"
|
||||
:group="item as GroupedLikeNotifications"
|
||||
:group="item"
|
||||
border="b base"
|
||||
/>
|
||||
<NotificationCard
|
||||
v-else
|
||||
:notification="item as mastodon.v1.Notification"
|
||||
:notification="item"
|
||||
hover:bg-active
|
||||
border="b base"
|
||||
/>
|
||||
|
|
|
@ -364,7 +364,9 @@ const isPublishDisabled = computed(() => {
|
|||
aria-describedby="publish-tooltip"
|
||||
@click="publish"
|
||||
>
|
||||
{{ !draft.editingStatus ? $t('action.publish') : $t('action.save_changes') }}
|
||||
<span v-if="draft.editingStatus">{{ $t('action.save_changes') }}</span>
|
||||
<span v-else-if="draft.params.inReplyToId">{{ $t('action.reply') }}</span>
|
||||
<span v-else>{{ $t('action.publish') }}</span>
|
||||
</button>
|
||||
</CommonTooltip>
|
||||
</div>
|
||||
|
|
|
@ -170,11 +170,11 @@ const showReplyTo = $computed(() => !replyToMain && !directReply)
|
|||
<AccountBotIndicator v-if="status.account.bot" me-2 />
|
||||
<div flex>
|
||||
<CommonTooltip :content="createdAt">
|
||||
<a :title="status.createdAt" :href="statusRoute.href" @click.prevent="go($event)">
|
||||
<NuxtLink :title="status.createdAt" :href="statusRoute.href" @click.prevent="go($event)">
|
||||
<time text-sm ws-nowrap hover:underline :datetime="status.createdAt">
|
||||
{{ timeago }}
|
||||
</time>
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</CommonTooltip>
|
||||
<StatusEditIndicator :status="status" inline />
|
||||
</div>
|
||||
|
|
|
@ -46,6 +46,7 @@ const cardTypeIconMap: Record<mastodon.v1.PreviewCardType, string> = {
|
|||
'rounded-lg border border-base': !root,
|
||||
}"
|
||||
target="_blank"
|
||||
external
|
||||
>
|
||||
<div
|
||||
v-if="card.image"
|
||||
|
|
|
@ -99,13 +99,13 @@ const meta = $computed(() => {
|
|||
<div p4 sm:px-8 flex flex-col justify-between min-h-50 md:min-h-60 h-full>
|
||||
<div flex justify-between items-center gap-2 sm:gap-6 h-full mb-2 min-h-35 md:min-h-45>
|
||||
<div flex flex-col gap-2>
|
||||
<a flex gap-1 text-xl sm:text-3xl flex-wrap leading-none :href="meta.titleUrl" target="_blank">
|
||||
<NuxtLink flex gap-1 text-xl sm:text-3xl flex-wrap leading-none :href="meta.titleUrl" target="_blank" external>
|
||||
<template v-if="meta.repo">
|
||||
<span>{{ meta.user }}</span><span text-secondary-light>/</span><span text-primary font-bold>{{ meta.repo }}</span>
|
||||
</template>
|
||||
<span v-else>{{ meta.user }}</span>
|
||||
</a>
|
||||
<a sm:text-lg :href="card.url" target="_blank">
|
||||
</NuxtLink>
|
||||
<NuxtLink sm:text-lg :href="card.url" target="_blank" external>
|
||||
<span v-if="meta.type === 'issue'" text-secondary-light me-2>
|
||||
#{{ meta.number }}
|
||||
</span>
|
||||
|
@ -113,12 +113,12 @@ const meta = $computed(() => {
|
|||
PR #{{ meta.number }}
|
||||
</span>
|
||||
<span text-secondary leading-tight>{{ meta.details }}</span>
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<div>
|
||||
<a :href="meta.titleUrl" target="_blank">
|
||||
<NuxtLink :href="meta.titleUrl" target="_blank" external>
|
||||
<img w-30 aspect-square width="20" height="20" rounded-2 :src="meta.avatar">
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
<div flex justify-between>
|
||||
|
|
|
@ -41,14 +41,14 @@ const showOriginSite = $computed(() =>
|
|||
<template v-if="context === 'account' && showOriginSite" #done>
|
||||
<div p5 text-secondary text-center flex flex-col items-center gap1>
|
||||
<span italic>{{ $t('timeline.view_older_posts') }}</span>
|
||||
<a
|
||||
:href="account!.url" target="_blank"
|
||||
<NuxtLink
|
||||
:href="account!.url" target="_blank" external
|
||||
flex="~ gap-1" items-center text-primary
|
||||
hover="underline text-primary-active"
|
||||
>
|
||||
<div i-ri:external-link-fill />
|
||||
{{ $t('menu.open_in_original_site') }}
|
||||
</a>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
</CommonPaginator>
|
||||
|
|
|
@ -175,7 +175,7 @@ onClickOutside($$(input), () => {
|
|||
<div i-ri:lightbulb-line me-1 />
|
||||
<span>
|
||||
<i18n-t keypath="user.tip_no_account">
|
||||
<a href="https://joinmastodon.org/servers" target="_blank" hover="underline text-primary">{{ $t('user.tip_register_account') }}</a>
|
||||
<NuxtLink href="https://joinmastodon.org/servers" target="_blank" external hover="underline text-primary">{{ $t('user.tip_register_account') }}</NuxtLink>
|
||||
</i18n-t>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -322,7 +322,7 @@ const _markdownReplacements: [RegExp, (c: (string | Node)[]) => Node][] = [
|
|||
[/~~(.*?)~~/g, c => h('del', null, c)],
|
||||
[/`([^`]+?)`/g, c => h('code', null, c)],
|
||||
// transform @username@twitter.com as links
|
||||
[/\B@([a-zA-Z0-9_]+)@twitter\.com\b/gi, c => h('a', { href: `https://twitter.com/${c}`, target: '_blank', class: 'mention external' }, `@${c}@twitter.com`)],
|
||||
[/\B@([a-zA-Z0-9_]+)@twitter\.com\b/gi, c => h('a', { href: `https://twitter.com/${c}`, target: '_blank', rel: 'nofollow noopener noreferrer', class: 'mention external' }, `@${c}@twitter.com`)],
|
||||
]
|
||||
|
||||
function _markdownProcess(value: string) {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import type { Paginator, WsEvents } from 'masto'
|
||||
import type { Paginator, WsEvents, mastodon } from 'masto'
|
||||
import type { PaginatorState } from '~/types'
|
||||
import { onReactivated } from '~/composables/vue'
|
||||
|
||||
export function usePaginator<T, P>(
|
||||
export function usePaginator<T, P, U = T>(
|
||||
paginator: Paginator<T[], P>,
|
||||
stream?: Promise<WsEvents>,
|
||||
eventType: 'notification' | 'update' = 'update',
|
||||
preprocess: (items: T[]) => T[] = (items: T[]) => items,
|
||||
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
|
||||
buffer = 10,
|
||||
) {
|
||||
const state = ref<PaginatorState>(isMastoInitialised.value ? 'idle' : 'loading')
|
||||
const items = ref<T[]>([])
|
||||
const nextItems = ref<T[]>([])
|
||||
const items = ref<U[]>([])
|
||||
const nextItems = ref<U[]>([])
|
||||
const prevItems = ref<T[]>([])
|
||||
|
||||
const endAnchor = ref<HTMLDivElement>()
|
||||
|
@ -24,7 +24,7 @@ export function usePaginator<T, P>(
|
|||
const nuxtApp = useNuxtApp()
|
||||
|
||||
async function update() {
|
||||
items.value.unshift(...preprocess(prevItems.value as any) as any)
|
||||
(items.value as U[]).unshift(...preprocess(prevItems.value as T[]))
|
||||
prevItems.value = []
|
||||
}
|
||||
|
||||
|
@ -44,17 +44,19 @@ export function usePaginator<T, P>(
|
|||
s.on('status.update', (status) => {
|
||||
cacheStatus(status, undefined, true)
|
||||
|
||||
const index = items.value.findIndex((s: any) => s.id === status.id)
|
||||
const data = items.value as mastodon.v1.Status[]
|
||||
const index = data.findIndex(s => s.id === status.id)
|
||||
if (index >= 0)
|
||||
items.value[index] = status as any
|
||||
data[index] = status
|
||||
})
|
||||
|
||||
s.on('delete', (id) => {
|
||||
removeCachedStatus(id)
|
||||
|
||||
const index = items.value.findIndex((s: any) => s.id === id)
|
||||
const data = items.value as mastodon.v1.Status[]
|
||||
const index = data.findIndex(s => s.id === id)
|
||||
if (index >= 0)
|
||||
items.value.splice(index, 1)
|
||||
data.splice(index, 1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -66,11 +68,14 @@ export function usePaginator<T, P>(
|
|||
try {
|
||||
const result = await paginator.next()
|
||||
|
||||
if (result.value?.length) {
|
||||
const preprocessedItems = preprocess([...nextItems.value, ...result.value]) as any
|
||||
const itemsToShowCount = preprocessedItems.length - buffer
|
||||
nextItems.value = preprocessedItems.slice(itemsToShowCount)
|
||||
items.value.push(...preprocessedItems.slice(0, itemsToShowCount))
|
||||
if (!result.done && result.value.length) {
|
||||
const preprocessedItems = preprocess([...nextItems.value, ...result.value] as (U | T)[])
|
||||
const itemsToShowCount
|
||||
= preprocessedItems.length < buffer
|
||||
? preprocessedItems.length
|
||||
: preprocessedItems.length - buffer
|
||||
;(nextItems.value as U[]) = preprocessedItems.slice(itemsToShowCount)
|
||||
;(items.value as U[]).push(...preprocessedItems.slice(0, itemsToShowCount))
|
||||
state.value = 'idle'
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
diff --git a/dist/shared/nitro.c8278d90.mjs b/dist/shared/nitro.c8278d90.mjs
|
||||
index 9ba312fc248da3731720ee7e3b38ba2a85537657..3cd508f0720adb959d94e40c124382ec0110d92c 100644
|
||||
index 9ba312fc248da3731720ee7e3b38ba2a85537657..5ec9f06ccf60259820586715d73d41466daa8cff 100644
|
||||
--- a/dist/shared/nitro.c8278d90.mjs
|
||||
+++ b/dist/shared/nitro.c8278d90.mjs
|
||||
@@ -1298,7 +1298,7 @@ async function copyPublicAssets(nitro) {
|
||||
@@ -1296,7 +1296,7 @@ async function copyPublicAssets(nitro) {
|
||||
if (nitro.options.noPublicDir) {
|
||||
return;
|
||||
}
|
||||
for (const asset of nitro.options.publicAssets) {
|
||||
- for (const asset of nitro.options.publicAssets) {
|
||||
+ for (const asset of [...nitro.options.publicAssets].reverse()) {
|
||||
if (await isDirectory(asset.dir)) {
|
||||
- await fse.copy(asset.dir, join(nitro.options.output.publicDir, asset.baseURL));
|
||||
+ await fse.copy(asset.dir, join(nitro.options.output.publicDir, asset.baseURL), { override: false });
|
||||
await fse.copy(asset.dir, join(nitro.options.output.publicDir, asset.baseURL));
|
||||
}
|
||||
}
|
||||
if (nitro.options.compressPublicAssets) {
|
|
@ -5,7 +5,7 @@ patchedDependencies:
|
|||
hash: afe7v34zn4lohdq7767l3tlrje
|
||||
path: patches/mlly@1.0.0.patch
|
||||
nitropack@1.0.0:
|
||||
hash: 5rbw6wsrpkguwhgdzu2jwggidq
|
||||
hash: k66pyfgyevhmomc3yledfrjhru
|
||||
path: patches/nitropack@1.0.0.patch
|
||||
|
||||
importers:
|
||||
|
@ -8581,7 +8581,7 @@ packages:
|
|||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/nitropack/1.0.0_5rbw6wsrpkguwhgdzu2jwggidq:
|
||||
/nitropack/1.0.0_k66pyfgyevhmomc3yledfrjhru:
|
||||
resolution: {integrity: sha512-788lHgNgC+NKqecwFgMkAQTuTXwuh2hEgOk2sLwV3qPVUogxrl6P3m5eKdt6Mtzx+mlXIw0G/P90B5TNWEqDSQ==}
|
||||
engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0}
|
||||
hasBin: true
|
||||
|
@ -8911,7 +8911,7 @@ packages:
|
|||
knitwork: 1.0.0
|
||||
magic-string: 0.26.7
|
||||
mlly: 1.0.0_afe7v34zn4lohdq7767l3tlrje
|
||||
nitropack: 1.0.0_5rbw6wsrpkguwhgdzu2jwggidq
|
||||
nitropack: 1.0.0_k66pyfgyevhmomc3yledfrjhru
|
||||
nuxi: 3.0.0
|
||||
ofetch: 1.0.0
|
||||
ohash: 1.0.0
|
||||
|
|
|
@ -29,7 +29,7 @@ export type PaginatorState = 'idle' | 'loading' | 'done' | 'error'
|
|||
|
||||
export interface GroupedNotifications {
|
||||
id: string
|
||||
type: Exclude<string, 'grouped-reblogs-and-favourites'>
|
||||
type: 'grouped-follow'
|
||||
items: mastodon.v1.Notification[]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue