From 3143cf388e6dd68c3a6a24972db1e68ef6703798 Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Mon, 26 Aug 2024 09:15:46 +0900
Subject: [PATCH] wip
---
packages/frontend-embed/src/style.scss | 18 -------
packages/frontend/src/account.ts | 7 +--
packages/frontend/src/components/MkNotes.vue | 9 ++--
packages/frontend/src/pizzax.ts | 50 +++++--------------
packages/frontend/src/scripts/please-login.ts | 2 +-
packages/frontend/src/scripts/post-message.ts | 32 +++---------
packages/frontend/src/style.scss | 24 ++++-----
7 files changed, 35 insertions(+), 107 deletions(-)
diff --git a/packages/frontend-embed/src/style.scss b/packages/frontend-embed/src/style.scss
index b5cb394114..ee3b5c53c8 100644
--- a/packages/frontend-embed/src/style.scss
+++ b/packages/frontend-embed/src/style.scss
@@ -45,24 +45,6 @@ html {
}
}
}
-
- &:not(.embed) {
- &.f-1 {
- font-size: 15px;
- }
-
- &.f-2 {
- font-size: 16px;
- }
-
- &.f-3 {
- font-size: 17px;
- }
-
- &.useSystemFont {
- font-family: system-ui;
- }
- }
}
html, body {
diff --git a/packages/frontend/src/account.ts b/packages/frontend/src/account.ts
index fb1d8e9a44..4172016f89 100644
--- a/packages/frontend/src/account.ts
+++ b/packages/frontend/src/account.ts
@@ -21,13 +21,8 @@ type Account = Misskey.entities.MeDetailed & { token: string };
const accountData = miLocalStorage.getItem('account');
-function initAccount() {
- if (accountData) return reactive(JSON.parse(accountData) as Account);
- return null;
-}
-
// TODO: 外部からはreadonlyに
-export const $i = initAccount();
+export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
export const iAmAdmin = $i != null && $i.isAdmin;
diff --git a/packages/frontend/src/components/MkNotes.vue b/packages/frontend/src/components/MkNotes.vue
index c4387a0ec6..0856c146ba 100644
--- a/packages/frontend/src/components/MkNotes.vue
+++ b/packages/frontend/src/components/MkNotes.vue
@@ -21,7 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:direction="pagination.reversed ? 'up' : 'down'"
:reversed="pagination.reversed"
:noGap="noGap"
- :ad="ad"
+ :ad="true"
:class="$style.notes"
>
@@ -39,14 +39,11 @@ import MkPagination, { Paging } from '@/components/MkPagination.vue';
import { i18n } from '@/i18n.js';
import { infoImageUrl } from '@/instance.js';
-const props = withDefaults(defineProps<{
+const props = defineProps<{
pagination: Paging;
noGap?: boolean;
disableAutoLoad?: boolean;
- ad?: boolean;
-}>(), {
- ad: true,
-});
+}>();
const pagingComponent = shallowRef>();
diff --git a/packages/frontend/src/pizzax.ts b/packages/frontend/src/pizzax.ts
index 0bf6411b7b..ac325e923f 100644
--- a/packages/frontend/src/pizzax.ts
+++ b/packages/frontend/src/pizzax.ts
@@ -32,10 +32,6 @@ type PizzaxChannelMessage = {
userId?: string;
};
-export type PizzaxConfig = {
- disableMessageChannel: boolean;
-};
-
export class Storage {
public readonly ready: Promise;
public readonly loaded: Promise;
@@ -51,10 +47,6 @@ export class Storage {
public readonly state: State;
public readonly reactiveState: ReactiveState;
- private options: PizzaxConfig = {
- disableMessageChannel: false,
- };
-
private pizzaxChannel: BroadcastChannel>;
// 簡易的にキューイングして占有ロックとする
@@ -68,13 +60,12 @@ export class Storage {
return promise;
}
- constructor(key: string, def: T, options?: Partial) {
+ constructor(key: string, def: T) {
this.key = key;
this.deviceStateKeyName = `pizzax::${key}`;
this.deviceAccountStateKeyName = $i ? `pizzax::${key}::${$i.id}` : '';
this.registryCacheKeyName = $i ? `pizzax::${key}::cache::${$i.id}` : '';
this.def = def;
- this.options = Object.assign(this.options, options);
this.pizzaxChannel = new BroadcastChannel(`pizzax::${key}`);
@@ -128,7 +119,7 @@ export class Storage {
this.pizzaxChannel.addEventListener('message', ({ where, key, value, userId }) => {
// アカウント変更すればunisonReloadが効くため、このreturnが発火することは
// まずないと思うけど一応弾いておく
- if ((where === 'deviceAccount' && !($i && userId !== $i.id) || this.options.disableMessageChannel)) return;
+ if (where === 'deviceAccount' && !($i && userId !== $i.id)) return;
this.reactiveState[key].value = this.state[key] = value;
});
@@ -183,17 +174,6 @@ export class Storage {
});
}
- /**
- * Sets the configuration options for Pizzax.
- *
- * 特にinitを待ったりとかはしないので、boot.jsなど、ロード初期段階で呼ぶ必要がある
- *
- * @param config - The partial configuration object.
- */
- public setConfig(config: Partial) {
- this.options = Object.assign(this.options, config);
- }
-
public set(key: K, value: T[K]['default']): Promise {
// IndexedDBやBroadcastChannelで扱うために単純なオブジェクトにする
// (JSON.parse(JSON.stringify(value))の代わり)
@@ -207,13 +187,11 @@ export class Storage {
if (_DEV_) console.log(`set ${String(key)} start`);
switch (this.def[key].where) {
case 'device': {
- if (!this.options.disableMessageChannel) {
- this.pizzaxChannel.postMessage({
- where: 'device',
- key,
- value: rawValue,
- });
- }
+ this.pizzaxChannel.postMessage({
+ where: 'device',
+ key,
+ value: rawValue,
+ });
const deviceState = await get(this.deviceStateKeyName) || {};
deviceState[key] = rawValue;
await set(this.deviceStateKeyName, deviceState);
@@ -221,14 +199,12 @@ export class Storage {
}
case 'deviceAccount': {
if ($i == null) break;
- if (!this.options.disableMessageChannel) {
- this.pizzaxChannel.postMessage({
- where: 'deviceAccount',
- key,
- value: rawValue,
- userId: $i.id,
- });
- }
+ this.pizzaxChannel.postMessage({
+ where: 'deviceAccount',
+ key,
+ value: rawValue,
+ userId: $i.id,
+ });
const deviceAccountState = await get(this.deviceAccountStateKeyName) || {};
deviceAccountState[key] = rawValue;
await set(this.deviceAccountStateKeyName, deviceAccountState);
diff --git a/packages/frontend/src/scripts/please-login.ts b/packages/frontend/src/scripts/please-login.ts
index 5a28852245..18f05bc7f4 100644
--- a/packages/frontend/src/scripts/please-login.ts
+++ b/packages/frontend/src/scripts/please-login.ts
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-import { defineAsyncComponent, inject } from 'vue';
+import { defineAsyncComponent } from 'vue';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
diff --git a/packages/frontend/src/scripts/post-message.ts b/packages/frontend/src/scripts/post-message.ts
index 6a0028960a..31a9ac1ad9 100644
--- a/packages/frontend/src/scripts/post-message.ts
+++ b/packages/frontend/src/scripts/post-message.ts
@@ -9,37 +9,17 @@ export const postMessageEventTypes = [
export type PostMessageEventType = typeof postMessageEventTypes[number];
-export interface PostMessageEventPayload extends Record {
- 'misskey:shareForm:shareCompleted': undefined;
-}
-
-export type MiPostMessageEvent = {
- type: T;
- iframeId?: string;
- payload?: PostMessageEventPayload[T];
-}
-
-let defaultIframeId: string | null = null;
-
-export function setIframeId(id: string): void {
- if (defaultIframeId != null) return;
-
- if (_DEV_) console.log('setIframeId', id);
- defaultIframeId = id;
-}
+export type MiPostMessageEvent = {
+ type: PostMessageEventType;
+ payload?: any;
+};
/**
* 親フレームにイベントを送信
*/
-export function postMessageToParentWindow(type: T, payload?: PostMessageEventPayload[T], iframeId: string | null = null): void {
- let _iframeId = iframeId;
- if (_iframeId == null) {
- _iframeId = defaultIframeId;
- }
- if (_DEV_) console.log('postMessageToParentWindow', type, _iframeId, payload);
- window.parent.postMessage({
+export function postMessageToParentWindow(type: PostMessageEventType, payload?: any): void {
+ window.postMessage({
type,
- iframeId: _iframeId,
payload,
}, '*');
}
diff --git a/packages/frontend/src/style.scss b/packages/frontend/src/style.scss
index 400fb0c552..44ef740a2e 100644
--- a/packages/frontend/src/style.scss
+++ b/packages/frontend/src/style.scss
@@ -75,22 +75,20 @@ html {
}
}
- &:not(.embed) {
- &.f-1 {
- font-size: 15px;
- }
+ &.f-1 {
+ font-size: 15px;
+ }
- &.f-2 {
- font-size: 16px;
- }
+ &.f-2 {
+ font-size: 16px;
+ }
- &.f-3 {
- font-size: 17px;
- }
+ &.f-3 {
+ font-size: 17px;
+ }
- &.useSystemFont {
- font-family: system-ui;
- }
+ &.useSystemFont {
+ font-family: system-ui;
}
}