mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
refactor(frontend): tweak MkNotes and MkNotifications
This commit is contained in:
parent
3682c0069c
commit
fc88410c0d
2 changed files with 38 additions and 40 deletions
|
@ -13,32 +13,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #default="{ items: notes }">
|
<template #default="{ items: notes }">
|
||||||
<div :class="[$style.root, { [$style.noGap]: noGap }]">
|
<div :class="[$style.root, { [$style.noGap]: noGap, '_gaps': !noGap }]">
|
||||||
<MkDateSeparatedList
|
<template v-for="(note, i) in notes" :key="note.id">
|
||||||
ref="notes"
|
<MkNote :class="$style.note" :note="note" :withHardMute="true"/>
|
||||||
v-slot="{ item: note }"
|
<div v-if="note._shouldInsertAd_" :class="$style.ad">
|
||||||
:items="notes"
|
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
||||||
:direction="pagination.reversed ? 'up' : 'down'"
|
</div>
|
||||||
:reversed="pagination.reversed"
|
</template>
|
||||||
:noGap="noGap"
|
|
||||||
:ad="true"
|
|
||||||
:class="$style.notes"
|
|
||||||
>
|
|
||||||
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note" :withHardMute="true"/>
|
|
||||||
</MkDateSeparatedList>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useTemplateRef } from 'vue';
|
import { useTemplateRef, TransitionGroup } from 'vue';
|
||||||
import type { Paging } from '@/components/MkPagination.vue';
|
import type { Paging } from '@/components/MkPagination.vue';
|
||||||
import MkNote from '@/components/MkNote.vue';
|
import MkNote from '@/components/MkNote.vue';
|
||||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination from '@/components/MkPagination.vue';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
|
import { prefer } from '@/preferences.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
pagination: Paging;
|
pagination: Paging;
|
||||||
|
@ -55,14 +49,24 @@ defineExpose({
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.root {
|
.root {
|
||||||
|
container-type: inline-size;
|
||||||
|
|
||||||
&.noGap {
|
&.noGap {
|
||||||
> .notes {
|
|
||||||
background: var(--MI_THEME-panel);
|
background: var(--MI_THEME-panel);
|
||||||
|
|
||||||
|
.note {
|
||||||
|
border-bottom: solid 0.5px var(--MI_THEME-divider);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ad {
|
||||||
|
padding: 8px;
|
||||||
|
background-size: auto auto;
|
||||||
|
background-image: repeating-linear-gradient(45deg, transparent, transparent 8px, var(--MI_THEME-bg) 8px, var(--MI_THEME-bg) 14px);
|
||||||
|
border-bottom: solid 0.5px var(--MI_THEME-divider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.noGap) {
|
&:not(.noGap) {
|
||||||
> .notes {
|
|
||||||
background: var(--MI_THEME-bg);
|
background: var(--MI_THEME-bg);
|
||||||
|
|
||||||
.note {
|
.note {
|
||||||
|
@ -71,5 +75,4 @@ defineExpose({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -14,10 +14,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #default="{ items: notifications }">
|
<template #default="{ items: notifications }">
|
||||||
<MkDateSeparatedList v-slot="{ item: notification }" :class="$style.list" :items="notifications" :noGap="true">
|
<div :class="$style.notifications">
|
||||||
<MkNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id + ':note'" :note="notification.note" :withHardMute="true"/>
|
<template v-for="(notification, i) in notifications" :key="notification.id">
|
||||||
<XNotification v-else :key="notification.id" :notification="notification" :withTime="true" :full="true" class="_panel"/>
|
<MkNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :class="$style.item" :note="notification.note" :withHardMute="true"/>
|
||||||
</MkDateSeparatedList>
|
<XNotification v-else :class="$style.item" :notification="notification" :withTime="true" :full="true"/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</MkPullToRefresh>
|
</MkPullToRefresh>
|
||||||
|
@ -29,7 +31,6 @@ import * as Misskey from 'misskey-js';
|
||||||
import type { notificationTypes } from '@@/js/const.js';
|
import type { notificationTypes } from '@@/js/const.js';
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination from '@/components/MkPagination.vue';
|
||||||
import XNotification from '@/components/MkNotification.vue';
|
import XNotification from '@/components/MkNotification.vue';
|
||||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
|
||||||
import MkNote from '@/components/MkNote.vue';
|
import MkNote from '@/components/MkNote.vue';
|
||||||
import { useStream } from '@/stream.js';
|
import { useStream } from '@/stream.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
@ -84,28 +85,22 @@ onMounted(() => {
|
||||||
connection.on('notificationFlushed', reload);
|
connection.on('notificationFlushed', reload);
|
||||||
});
|
});
|
||||||
|
|
||||||
onActivated(() => {
|
|
||||||
pagingComponent.value?.reload();
|
|
||||||
connection = useStream().useChannel('main');
|
|
||||||
connection.on('notification', onNotification);
|
|
||||||
connection.on('notificationFlushed', reload);
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (connection) connection.dispose();
|
if (connection) connection.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
onDeactivated(() => {
|
|
||||||
if (connection) connection.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
reload,
|
reload,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.list {
|
.notifications {
|
||||||
|
container-type: inline-size;
|
||||||
background: var(--MI_THEME-panel);
|
background: var(--MI_THEME-panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
border-bottom: solid 0.5px var(--MI_THEME-divider);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Reference in a new issue