feat: make notification read more smart
This commit is contained in:
parent
507e9e580f
commit
70045735a7
2
.gitignore
vendored
2
.gitignore
vendored
@ -78,3 +78,5 @@ vite.config.ts.timestamp-*
|
|||||||
|
|
||||||
# VSCode addon
|
# VSCode addon
|
||||||
.favorites.json
|
.favorites.json
|
||||||
|
|
||||||
|
/dump.rdb
|
||||||
|
@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<MkPullToRefresh :refresher="() => reload()">
|
<MkPullToRefresh :refresher="() => reload()">
|
||||||
<MkPagination ref="pagingComponent" :pagination="pagination">
|
<MkPagination ref="pagingComponent" :pagination="pagination" @queue="onQueue">
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="_fullinfo">
|
<div class="_fullinfo">
|
||||||
<img :src="infoImageUrl" class="_ghost"/>
|
<img :src="infoImageUrl" class="_ghost"/>
|
||||||
@ -65,9 +65,26 @@ function onNotification(notification) {
|
|||||||
|
|
||||||
if (!isMuted) {
|
if (!isMuted) {
|
||||||
pagingComponent.value?.prepend(notification);
|
pagingComponent.value?.prepend(notification);
|
||||||
|
onQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let queued = false;
|
||||||
|
|
||||||
|
function checkAllNotificationsCanRead() {
|
||||||
|
queued = false;
|
||||||
|
if (!document.hasFocus()) { onQueue(); return; }
|
||||||
|
if (!(pagingComponent.value?.queue.size) && !(props.excludeTypes?.length)) {
|
||||||
|
misskeyApi('notifications/mark-all-as-read');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onQueue() {
|
||||||
|
if (queued) return;
|
||||||
|
queued = true;
|
||||||
|
setTimeout(() => checkAllNotificationsCanRead(), 2000);
|
||||||
|
}
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
return new Promise<void>((res) => {
|
return new Promise<void>((res) => {
|
||||||
pagingComponent.value?.reload().then(() => {
|
pagingComponent.value?.reload().then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user