summaryrefslogtreecommitdiff
path: root/packages/frontend/src/boot
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-11-22 12:29:04 +0000
committerdakkar <dakkar@thenautilus.net>2024-11-22 12:29:04 +0000
commitbc816cb166d907d38eb096a02c5f4f57d9a2f1a0 (patch)
treea0e6b1dfeed8aa2b0543846eb65b8aae0ce631ad /packages/frontend/src/boot
parentbetter wording for moderator inactivity messages (diff)
parentRelease: 2024.11.0 (diff)
downloadsharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.tar.gz
sharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.tar.bz2
sharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.zip
Merge tag '2024.11.0' into feature/2024.10
Diffstat (limited to 'packages/frontend/src/boot')
-rw-r--r--packages/frontend/src/boot/common.ts29
-rw-r--r--packages/frontend/src/boot/main-boot.ts58
2 files changed, 71 insertions, 16 deletions
diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts
index 6102f88ae5..d43a2b0799 100644
--- a/packages/frontend/src/boot/common.ts
+++ b/packages/frontend/src/boot/common.ts
@@ -11,11 +11,11 @@ import directives from '@/directives/index.js';
import components from '@/components/index.js';
import { applyTheme } from '@/scripts/theme.js';
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode.js';
-import { updateI18n } from '@/i18n.js';
+import { updateI18n, i18n } from '@/i18n.js';
import { $i, refreshAccount, login } from '@/account.js';
import { defaultStore, ColdDeviceStorage } from '@/store.js';
import { fetchInstance, instance } from '@/instance.js';
-import { deviceKind } from '@/scripts/device-kind.js';
+import { deviceKind, updateDeviceKind } from '@/scripts/device-kind.js';
import { reloadChannel } from '@/scripts/unison-reload.js';
import { getUrlWithoutLoginId } from '@/scripts/login-id.js';
import { getAccountFromId } from '@/scripts/get-account-from-id.js';
@@ -186,6 +186,10 @@ export async function common(createVue: () => App<Element>) {
}
});
+ watch(defaultStore.reactiveState.overridedDeviceKind, (kind) => {
+ updateDeviceKind(kind);
+ }, { immediate: true });
+
watch(defaultStore.reactiveState.useBlurEffectForModal, v => {
document.documentElement.style.setProperty('--MI-modalBgFilter', v ? 'blur(4px)' : 'none');
}, { immediate: true });
@@ -274,6 +278,27 @@ export async function common(createVue: () => App<Element>) {
removeSplash();
+ //#region Self-XSS 対策メッセージ
+ console.log(
+ `%c${i18n.ts._selfXssPrevention.warning}`,
+ 'color: #f00; background-color: #ff0; font-size: 36px; padding: 4px;',
+ );
+ console.log(
+ `%c${i18n.ts._selfXssPrevention.title}`,
+ 'color: #f00; font-weight: 900; font-family: "Hiragino Sans W9", "Hiragino Kaku Gothic ProN", sans-serif; font-size: 24px;',
+ );
+ console.log(
+ `%c${i18n.ts._selfXssPrevention.description1}`,
+ 'font-size: 16px; font-weight: 700;',
+ );
+ console.log(
+ `%c${i18n.ts._selfXssPrevention.description2}`,
+ 'font-size: 16px;',
+ 'font-size: 20px; font-weight: 700; color: #f00;',
+ );
+ console.log(i18n.tsx._selfXssPrevention.description3({ link: 'https://misskey-hub.net/docs/for-users/resources/self-xss/' }));
+ //#endregion
+
return {
isClientUpdated,
app,
diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts
index 395d7d9ad1..eb8a4d30d2 100644
--- a/packages/frontend/src/boot/main-boot.ts
+++ b/packages/frontend/src/boot/main-boot.ts
@@ -4,14 +4,14 @@
*/
import { createApp, defineAsyncComponent, markRaw } from 'vue';
+import { ui } from '@@/js/config.js';
import { common } from './common.js';
import type * as Misskey from 'misskey-js';
-import { ui } from '@@/js/config.js';
import { i18n } from '@/i18n.js';
import { alert, confirm, popup, post, toast } from '@/os.js';
import { useStream } from '@/stream.js';
import * as sound from '@/scripts/sound.js';
-import { $i, signout, updateAccount } from '@/account.js';
+import { $i, signout, updateAccountPartial } from '@/account.js';
import { instance } from '@/instance.js';
import { ColdDeviceStorage, defaultStore } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js';
@@ -230,11 +230,41 @@ export async function mainBoot() {
}
if (!claimedAchievements.includes('justPlainLucky')) {
- window.setInterval(() => {
+ let justPlainLuckyTimer: number | null = null;
+ let lastVisibilityChangedAt = Date.now();
+
+ function claimPlainLucky() {
+ if (document.visibilityState !== 'visible') {
+ if (justPlainLuckyTimer != null) window.clearTimeout(justPlainLuckyTimer);
+ return;
+ }
+
if (Math.floor(Math.random() * 20000) === 0) {
claimAchievement('justPlainLucky');
+ } else {
+ justPlainLuckyTimer = window.setTimeout(claimPlainLucky, 1000 * 10);
}
- }, 1000 * 10);
+ }
+
+ window.addEventListener('visibilitychange', () => {
+ const now = Date.now();
+
+ if (document.visibilityState === 'visible') {
+ // タブを高速で切り替えたら取得処理が何度も走るのを防ぐ
+ if ((now - lastVisibilityChangedAt) < 1000 * 10) {
+ justPlainLuckyTimer = window.setTimeout(claimPlainLucky, 1000 * 10);
+ } else {
+ claimPlainLucky();
+ }
+ } else if (justPlainLuckyTimer != null) {
+ window.clearTimeout(justPlainLuckyTimer);
+ justPlainLuckyTimer = null;
+ }
+
+ lastVisibilityChangedAt = now;
+ }, { passive: true });
+
+ claimPlainLucky();
}
if (!claimedAchievements.includes('client30min')) {
@@ -298,13 +328,13 @@ export async function mainBoot() {
// 自分の情報が更新されたとき
main.on('meUpdated', i => {
- updateAccount(i);
+ updateAccountPartial(i);
});
main.on('readAllNotifications', () => {
setFavIconDot(false);
- updateAccount({
+ updateAccountPartial({
hasUnreadNotification: false,
unreadNotificationsCount: 0,
});
@@ -314,39 +344,39 @@ export async function mainBoot() {
attemptShowNotificationDot();
const unreadNotificationsCount = ($i?.unreadNotificationsCount ?? 0) + 1;
- updateAccount({
+ updateAccountPartial({
hasUnreadNotification: true,
unreadNotificationsCount,
});
});
main.on('unreadMention', () => {
- updateAccount({ hasUnreadMentions: true });
+ updateAccountPartial({ hasUnreadMentions: true });
});
main.on('readAllUnreadMentions', () => {
- updateAccount({ hasUnreadMentions: false });
+ updateAccountPartial({ hasUnreadMentions: false });
});
main.on('unreadSpecifiedNote', () => {
- updateAccount({ hasUnreadSpecifiedNotes: true });
+ updateAccountPartial({ hasUnreadSpecifiedNotes: true });
});
main.on('readAllUnreadSpecifiedNotes', () => {
- updateAccount({ hasUnreadSpecifiedNotes: false });
+ updateAccountPartial({ hasUnreadSpecifiedNotes: false });
});
main.on('readAllAntennas', () => {
- updateAccount({ hasUnreadAntenna: false });
+ updateAccountPartial({ hasUnreadAntenna: false });
});
main.on('unreadAntenna', () => {
- updateAccount({ hasUnreadAntenna: true });
+ updateAccountPartial({ hasUnreadAntenna: true });
sound.playMisskeySfx('antenna');
});
main.on('readAllAnnouncements', () => {
- updateAccount({ hasUnreadAnnouncement: false });
+ updateAccountPartial({ hasUnreadAnnouncement: false });
});
// 個人宛てお知らせが発行されたとき