fix
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { miLocalStorage } from "@/local-storage.js";
|
||||
import type { Keys } from "@/local-storage.js";
|
||||
import { embedPage } from "@/config.js";
|
||||
|
||||
//#region Embed関連の定義
|
||||
|
||||
/** 埋め込みページかどうか */
|
||||
export function isEmbedPage() {
|
||||
return location.pathname.startsWith('/embed');
|
||||
}
|
||||
|
||||
/** 埋め込みの対象となるエンティティ(/embed/xxx の xxx の部分と対応させる) */
|
||||
const embeddableEntities = [
|
||||
'notes',
|
||||
@@ -36,6 +38,7 @@ export type EmbedParams = {
|
||||
header?: boolean;
|
||||
};
|
||||
|
||||
/** 正規化されたパラメータ */
|
||||
export type ParsedEmbedParams = Required<Omit<EmbedParams, 'maxHeight' | 'colorMode'>> & Pick<EmbedParams, 'maxHeight' | 'colorMode'>;
|
||||
|
||||
/** パラメータのデフォルトの値 */
|
||||
@@ -48,6 +51,8 @@ export const defaultEmbedParams = {
|
||||
header: true,
|
||||
} as const;
|
||||
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
* パラメータを正規化する(埋め込みページ初期化用)
|
||||
* @param searchParams URLSearchParamsもしくはクエリ文字列
|
||||
@@ -84,30 +89,3 @@ export function parseEmbedParams(searchParams: URLSearchParams | string): Parsed
|
||||
...params,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* EmbedページではlocalStorageを使用できないようにしているが、
|
||||
* 動作に必要な値はsafeSessionStorage(miLocalStorage内のやつ)に移動する
|
||||
*/
|
||||
export function initEmbedPageLocalStorage() {
|
||||
if (!embedPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
const keysToDuplicate: Keys[] = [
|
||||
'v',
|
||||
'lastVersion',
|
||||
'instance',
|
||||
'instanceCachedAt',
|
||||
'lang',
|
||||
'locale',
|
||||
'localeVersion',
|
||||
];
|
||||
|
||||
keysToDuplicate.forEach(key => {
|
||||
const value = window.localStorage.getItem(key);
|
||||
if (value && !miLocalStorage.getItem(key)) {
|
||||
miLocalStorage.setItem(key, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ import { miLocalStorage } from '@/local-storage.js';
|
||||
|
||||
const PREFIX = 'idbfallback::';
|
||||
|
||||
let idbAvailable = typeof window !== 'undefined' ? !!(window.indexedDB && typeof window.indexedDB.open === 'function' && !embedPage) : true;
|
||||
let idbAvailable = typeof window !== 'undefined' ? !!(window.indexedDB && typeof window.indexedDB.open === 'function') : true;
|
||||
|
||||
// iframe.contentWindow.indexedDB.deleteDatabase() がchromeのバグで使用できないため、indexedDBを無効化している。
|
||||
// バグが治って再度有効化するのであれば、cypressのコマンド内のコメントアウトを外すこと
|
||||
@@ -27,7 +27,10 @@ if (window.Cypress) {
|
||||
console.log('Cypress detected. It will use localStorage.');
|
||||
}
|
||||
|
||||
if (idbAvailable) {
|
||||
if (embedPage) {
|
||||
idbAvailable = false;
|
||||
console.log('Embed page detected. It will use safeSessionStorage.');
|
||||
} else if (idbAvailable) {
|
||||
await iset('idb-test', 'test')
|
||||
.catch(err => {
|
||||
console.error('idb error', err);
|
||||
|
Reference in New Issue
Block a user