From 11a6bd890cc752ee7abd2890773054743433eae1 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 12 Jun 2022 19:28:13 +0900 Subject: [PATCH 1/8] fix: some fixes of multiple notification read (#8819) * fix: limit multiple notification read * fix * fix --- .../src/server/api/common/read-notification.ts | 2 ++ .../src/server/api/endpoints/notifications/read.ts | 6 +++++- packages/sw/src/scripts/notification-read.ts | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index 0dad35bcc..8c4ba41a3 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -9,6 +9,8 @@ export async function readNotification( userId: User['id'], notificationIds: Notification['id'][] ) { + if (notificationIds.length === 0) return; + // Update documents await Notifications.update({ id: In(notificationIds), diff --git a/packages/backend/src/server/api/endpoints/notifications/read.ts b/packages/backend/src/server/api/endpoints/notifications/read.ts index 65e96d486..e7839b246 100644 --- a/packages/backend/src/server/api/endpoints/notifications/read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/read.ts @@ -34,7 +34,11 @@ export const paramDef = { { type: 'object', properties: { - notificationIds: { type: 'array', items: { type: 'string', format: 'misskey:id' } }, + notificationIds: { + type: 'array', + items: { type: 'string', format: 'misskey:id' }, + maxItems: 100, + }, }, required: ['notificationIds'], }, diff --git a/packages/sw/src/scripts/notification-read.ts b/packages/sw/src/scripts/notification-read.ts index 8433f902b..5c1de8908 100644 --- a/packages/sw/src/scripts/notification-read.ts +++ b/packages/sw/src/scripts/notification-read.ts @@ -37,12 +37,22 @@ class SwNotificationReadManager { account.queue.push(data.body.id as string); + if (account.queue.length >= 20) { + if (account.timeout) clearTimeout(account.timeout); + const notificationIds = account.queue; + account.queue = []; + await api('notifications/read', data.userId, { notificationIds }); + return; + } + // 最後の呼び出しから200ms待ってまとめて処理する if (account.timeout) clearTimeout(account.timeout); account.timeout = setTimeout(() => { account.timeout = null; - api('notifications/read', data.userId, { notificationIds: account.queue }); + const notificationIds = account.queue; + account.queue = []; + api('notifications/read', data.userId, { notificationIds }); }, 200); } } From a8e7b1a303234b14f2ed2758efde649d7c5bf607 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 12 Jun 2022 19:50:43 +0900 Subject: [PATCH 2/8] =?UTF-8?q?fix(client):=20=E3=83=87=E3=83=83=E3=82=AD?= =?UTF-8?q?=E3=81=A7=E3=82=A6=E3=82=A3=E3=82=B8=E3=82=A7=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=81=AE=E6=83=85=E5=A0=B1=E3=81=8C=E4=BF=9D=E5=AD=98=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #8818 --- CHANGELOG.md | 7 +++++++ packages/client/src/ui/deck/deck-store.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb16a1675..3035e8d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ You should also include the user name that made the change. --> +## 12.x.x (unreleased) + +### Improvements + +### Bugfixes +- Client: デッキでウィジェットの情報が保存されない問題を修正 @syuilo + ## 12.111.0 (2022/06/11) ### Improvements - Supports Unicode Emoji 14.0 @mei23 diff --git a/packages/client/src/ui/deck/deck-store.ts b/packages/client/src/ui/deck/deck-store.ts index c847bf2b4..b9bbbb96f 100644 --- a/packages/client/src/ui/deck/deck-store.ts +++ b/packages/client/src/ui/deck/deck-store.ts @@ -276,7 +276,7 @@ export function setColumnWidgets(id: Column['id'], widgets: ColumnWidget[]) { saveDeck(); } -export function updateColumnWidget(id: Column['id'], widgetId: string, WidgetData: any) { +export function updateColumnWidget(id: Column['id'], widgetId: string, widgetData: any) { const columns = copy(deckStore.state.columns); const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); const column = copy(deckStore.state.columns[columnIndex]); From 4e89d41f048beb6c962155e599acf21af8cda0fe Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 12 Jun 2022 19:50:47 +0900 Subject: [PATCH 3/8] lint --- packages/client/src/ui/deck/deck-store.ts | 24 +++++++++---------- .../client/src/ui/deck/widgets-column.vue | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/client/src/ui/deck/deck-store.ts b/packages/client/src/ui/deck/deck-store.ts index b9bbbb96f..03d57c346 100644 --- a/packages/client/src/ui/deck/deck-store.ts +++ b/packages/client/src/ui/deck/deck-store.ts @@ -1,9 +1,9 @@ import { throttle } from 'throttle-debounce'; +import { markRaw } from 'vue'; +import { notificationTypes } from 'misskey-js'; +import { Storage } from '../../pizzax'; import { i18n } from '@/i18n'; import { api } from '@/os'; -import { markRaw } from 'vue'; -import { Storage } from '../../pizzax'; -import { notificationTypes } from 'misskey-js'; type ColumnWidget = { name: string; @@ -32,35 +32,35 @@ function copy(x: T): T { export const deckStore = markRaw(new Storage('deck', { profile: { where: 'deviceAccount', - default: 'default' + default: 'default', }, columns: { where: 'deviceAccount', - default: [] as Column[] + default: [] as Column[], }, layout: { where: 'deviceAccount', - default: [] as Column['id'][][] + default: [] as Column['id'][][], }, columnAlign: { where: 'deviceAccount', - default: 'left' as 'left' | 'right' | 'center' + default: 'left' as 'left' | 'right' | 'center', }, alwaysShowMainColumn: { where: 'deviceAccount', - default: true + default: true, }, navWindow: { where: 'deviceAccount', - default: true + default: true, }, columnMargin: { where: 'deviceAccount', - default: 16 + default: 16, }, columnHeaderHeight: { where: 'deviceAccount', - default: 42 + default: 42, }, })); @@ -109,7 +109,7 @@ export const saveDeck = throttle(1000, () => { value: { columns: deckStore.reactiveState.columns.value, layout: deckStore.reactiveState.layout.value, - } + }, }); }); diff --git a/packages/client/src/ui/deck/widgets-column.vue b/packages/client/src/ui/deck/widgets-column.vue index 10c6f5adf..9b10f602f 100644 --- a/packages/client/src/ui/deck/widgets-column.vue +++ b/packages/client/src/ui/deck/widgets-column.vue @@ -10,9 +10,9 @@