From 4b1ca9ef619903e9ff1de10101c18569efbe099c Mon Sep 17 00:00:00 2001 From: zyoshoka <107108195+zyoshoka@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:02:57 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix(general):=20`flash/create`=E3=81=A7Play?= =?UTF-8?q?=E3=81=AE=E5=85=AC=E9=96=8B=E7=AF=84=E5=9B=B2=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=81=A8=E7=B7=A8=E9=9B=86=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AE=E8=AA=BF=E6=95=B4=20(#13574)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(backend): param `visibility` wasn't included in `flash/create` * fix(frontend): tweak flash editor ui * Update CHANGELOG.md --- CHANGELOG.md | 2 +- locales/index.d.ts | 4 ++++ locales/ja-JP.yml | 1 + .../src/server/api/endpoints/flash/create.ts | 2 ++ packages/frontend/src/pages/flash/flash-edit.vue | 14 ++++++++------ packages/misskey-js/src/autogen/types.ts | 5 +++++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e863a8f2..fa56f1a268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Unreleased ### General -- +- Fix: Play作成時に設定した公開範囲が機能していない問題を修正 ### Client - Enhance: 自分のノートの添付ファイルから直接ファイルの詳細ページに飛べるように diff --git a/locales/index.d.ts b/locales/index.d.ts index 87065e1d37..7f4ec7ecb0 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -8635,6 +8635,10 @@ export interface Locale extends ILocale { * 説明 */ "summary": string; + /** + * 非公開に設定するとプロフィールに表示されなくなりますが、URLを知っている人は引き続きアクセスできます。 + */ + "visibilityDescription": string; }; "_pages": { /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index f42fd6587a..8b44ac2121 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2280,6 +2280,7 @@ _play: title: "タイトル" script: "スクリプト" summary: "説明" + visibilityDescription: "非公開に設定するとプロフィールに表示されなくなりますが、URLを知っている人は引き続きアクセスできます。" _pages: newPage: "ページの作成" diff --git a/packages/backend/src/server/api/endpoints/flash/create.ts b/packages/backend/src/server/api/endpoints/flash/create.ts index 584d167a29..361496e17e 100644 --- a/packages/backend/src/server/api/endpoints/flash/create.ts +++ b/packages/backend/src/server/api/endpoints/flash/create.ts @@ -44,6 +44,7 @@ export const paramDef = { permissions: { type: 'array', items: { type: 'string', } }, + visibility: { type: 'string', enum: ['public', 'private'], default: 'public' }, }, required: ['title', 'summary', 'script', 'permissions'], } as const; @@ -66,6 +67,7 @@ export default class extends Endpoint { // eslint- summary: ps.summary, script: ps.script, permissions: ps.permissions, + visibility: ps.visibility, }).then(x => this.flashsRepository.findOneByOrFail(x.identifiers[0])); return await this.flashEntityService.pack(flash); diff --git a/packages/frontend/src/pages/flash/flash-edit.vue b/packages/frontend/src/pages/flash/flash-edit.vue index 4418172e62..3625bc1164 100644 --- a/packages/frontend/src/pages/flash/flash-edit.vue +++ b/packages/frontend/src/pages/flash/flash-edit.vue @@ -18,16 +18,17 @@ SPDX-License-Identifier: AGPL-3.0-only + + + + + +
{{ i18n.ts.save }} {{ i18n.ts.show }} {{ i18n.ts.delete }}
- - - - - @@ -367,7 +368,7 @@ const props = defineProps<{ }>(); const flash = ref(null); -const visibility = ref('public'); +const visibility = ref<'private' | 'public'>('public'); if (props.id) { flash.value = await misskeyApi('flash/show', { @@ -420,6 +421,7 @@ async function save() { summary: summary.value, permissions: permissions.value, script: script.value, + visibility: visibility.value, }); router.push('/play/' + created.id + '/edit'); } diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index be3e86bd78..3c862f690e 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -22686,6 +22686,11 @@ export type operations = { summary: string; script: string; permissions: string[]; + /** + * @default public + * @enum {string} + */ + visibility?: 'public' | 'private'; }; }; }; From 7e63ab0f5628bea33e8867d8257779b9ffeb8dd6 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:34:13 +0900 Subject: [PATCH 2/4] refactor(backend): refactor chart engine --- packages/backend/src/core/chart/core.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/chart/core.ts b/packages/backend/src/core/chart/core.ts index aa0cb9dc2b..f10e30ef10 100644 --- a/packages/backend/src/core/chart/core.ts +++ b/packages/backend/src/core/chart/core.ts @@ -459,13 +459,15 @@ export default abstract class Chart { } } - // bake unique count + // bake cardinality for (const [k, v] of Object.entries(finalDiffs)) { if (this.schema[k].uniqueIncrement) { const name = COLUMN_PREFIX + k.replaceAll('.', COLUMN_DELIMITER) as keyof Columns; const tempColumnName = UNIQUE_TEMP_COLUMN_PREFIX + k.replaceAll('.', COLUMN_DELIMITER) as keyof TempColumnsForUnique; - queryForHour[name] = new Set([...(v as string[]), ...(logHour[tempColumnName] as unknown as string[])]).size; - queryForDay[name] = new Set([...(v as string[]), ...(logDay[tempColumnName] as unknown as string[])]).size; + const cardinalityOfHour = new Set([...(v as string[]), ...(logHour[tempColumnName] as unknown as string[])]).size; + const cardinalityOfDay = new Set([...(v as string[]), ...(logDay[tempColumnName] as unknown as string[])]).size; + queryForHour[name] = cardinalityOfHour; + queryForDay[name] = cardinalityOfDay; } } @@ -637,7 +639,7 @@ export default abstract class Chart { // 要求された範囲にログがひとつもなかったら if (logs.length === 0) { // もっとも新しいログを持ってくる - // (すくなくともひとつログが無いと隙間埋めできないため) + // (すくなくともひとつログが無いと補間できないため) const recentLog = await repository.findOne({ where: group ? { group: group, @@ -654,7 +656,7 @@ export default abstract class Chart { // 要求された範囲の最も古い箇所に位置するログが存在しなかったら } else if (!isTimeSame(new Date(logs.at(-1)!.date * 1000), gt)) { // 要求された範囲の最も古い箇所時点での最も新しいログを持ってきて末尾に追加する - // (隙間埋めできないため) + // (補間できないため) const outdatedLog = await repository.findOne({ where: { date: LessThan(Chart.dateToTimestamp(gt)), @@ -683,7 +685,7 @@ export default abstract class Chart { if (log) { chart.unshift(this.convertRawRecord(log)); } else { - // 隙間埋め + // 補間 const latest = logs.find(l => isTimeBefore(new Date(l.date * 1000), current)); const data = latest ? this.convertRawRecord(latest) : null; chart.unshift(this.getNewLog(data)); From dcfab918e9885ffd533f12d7d62e06a5072baa5c Mon Sep 17 00:00:00 2001 From: BackRunner Date: Sun, 17 Mar 2024 17:47:29 +0800 Subject: [PATCH 3/4] feat: send heartbeat right after visibility changed to 'visible' (#13581) --- packages/frontend/src/stream.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/stream.ts b/packages/frontend/src/stream.ts index 0c5ee06197..0d5bd78b09 100644 --- a/packages/frontend/src/stream.ts +++ b/packages/frontend/src/stream.ts @@ -8,7 +8,12 @@ import { markRaw } from 'vue'; import { $i } from '@/account.js'; import { wsOrigin } from '@/config.js'; +// heart beat interval in ms +const HEART_BEAT_INTERVAL = 1000 * 60; + let stream: Misskey.Stream | null = null; +let timeoutHeartBeat: ReturnType | null = null; +let lastHeartbeatCall = 0; export function useStream(): Misskey.Stream { if (stream) return stream; @@ -17,7 +22,18 @@ export function useStream(): Misskey.Stream { token: $i.token, } : null)); - window.setTimeout(heartbeat, 1000 * 60); + if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat); + timeoutHeartBeat = window.setTimeout(heartbeat, HEART_BEAT_INTERVAL); + + // send heartbeat right now when last send time is over HEART_BEAT_INTERVAL + document.addEventListener('visibilitychange', () => { + if ( + !stream + || document.visibilityState !== 'visible' + || Date.now() - lastHeartbeatCall < HEART_BEAT_INTERVAL + ) return; + heartbeat(); + }); return stream; } @@ -26,5 +42,7 @@ function heartbeat(): void { if (stream != null && document.visibilityState === 'visible') { stream.heartbeat(); } - window.setTimeout(heartbeat, 1000 * 60); + lastHeartbeatCall = Date.now(); + if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat); + timeoutHeartBeat = window.setTimeout(heartbeat, HEART_BEAT_INTERVAL); } From b65203c9f852a29a3a6e7ce81c6761e9ac228bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:33:33 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix(frontend):=20WebGL2=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E3=81=AE=E5=88=9D=E6=9C=9F?= =?UTF-8?q?=E5=8C=96=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=99=E3=82=8B=E3=81=A8?= =?UTF-8?q?Misskey=E3=81=8C=E8=B5=B7=E5=8B=95=E3=81=A7=E3=81=8D=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20(#13587)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed startup crash with seasonal effects (cherry picked from commit eba0c2cc61512db22109e2f15604eb65f5b7d2f2) * Update Changelog * Update Changelog --------- Co-authored-by: Leah --- CHANGELOG.md | 2 + packages/frontend/src/boot/main-boot.ts | 44 ++++++++++--------- .../frontend/src/scripts/snowfall-effect.ts | 4 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa56f1a268..cbd190d714 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: ローカルURLのプレビューポップアップが左上に表示される +- Fix: WebGL2をサポートしないブラウザで「季節に応じた画面の演出」が有効になっているとき、Misskeyが起動できなくなる問題を修正 + (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/459) ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index 8016e8b0e0..5cb19f388a 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -75,27 +75,31 @@ export async function mainBoot() { mainRouter.push('/search'); }, }; - - if (defaultStore.state.enableSeasonalScreenEffect) { - const month = new Date().getMonth() + 1; - if (defaultStore.state.hemisphere === 'S') { - // ▼南半球 - if (month === 7 || month === 8) { - const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SnowfallEffect({}).render(); + try { + if (defaultStore.state.enableSeasonalScreenEffect) { + const month = new Date().getMonth() + 1; + if (defaultStore.state.hemisphere === 'S') { + // ▼南半球 + if (month === 7 || month === 8) { + const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SnowfallEffect({}).render(); + } + } else { + // ▼北半球 + if (month === 12 || month === 1) { + const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SnowfallEffect({}).render(); + } else if (month === 3 || month === 4) { + const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SakuraEffect({ + sakura: true, + }).render(); + } } - } else { - // ▼北半球 - if (month === 12 || month === 1) { - const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SnowfallEffect({}).render(); - } else if (month === 3 || month === 4) { - const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SakuraEffect({ - sakura: true, - }).render(); - } - } + } + } catch (error) { + // console.error(error); + console.error('Failed to initialise the seasonal screen effect canvas context:', error); } if ($i) { diff --git a/packages/frontend/src/scripts/snowfall-effect.ts b/packages/frontend/src/scripts/snowfall-effect.ts index 11fcaa0716..d88bdb6660 100644 --- a/packages/frontend/src/scripts/snowfall-effect.ts +++ b/packages/frontend/src/scripts/snowfall-effect.ts @@ -155,7 +155,9 @@ export class SnowfallEffect { max: 0.125, easing: 0.0005, }; - + /** + * @throws {Error} - Thrown when it fails to get WebGL context for the canvas + */ constructor(options: { sakura?: boolean; }) {