From 02e832cf894b45b5c4412199b72f06f798df9ce1 Mon Sep 17 00:00:00 2001 From: Pierce Morris Date: Thu, 25 Jan 2024 16:08:29 +0000 Subject: [PATCH] changes to welcome page settings --- ext/data/schemas/options-schema.json | 6 +++--- ext/js/background/backend.js | 21 +++++++++++---------- ext/js/data/options-util.js | 6 +++--- ext/settings.html | 2 +- ext/welcome.html | 4 ++-- test/options-util.test.js | 6 +++--- types/ext/settings.d.ts | 2 +- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 8cf0040087..7e2d03b13e 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -97,7 +97,7 @@ "popupScalingFactor", "popupScaleRelativeToPageZoom", "popupScaleRelativeToVisualViewport", - "showGuide", + "showWelcomePage", "compactTags", "glossaryLayoutMode", "mainDictionary", @@ -197,9 +197,9 @@ "type": "boolean", "default": true }, - "showGuide": { + "showWelcomePage": { "type": "boolean", - "default": true + "default": false }, "compactTags": { "type": "boolean", diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index a5a422728c..17fc86cae3 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -293,8 +293,8 @@ export class Backend { this._applyOptions('background'); const options = this._getProfileOptions({current: true}, false); - if (options.general.showGuide) { - this._openWelcomeGuidePageOnce(); + if (options.general.showWelcomePage) { + this._openWelcomePage(); } this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this)); @@ -420,6 +420,7 @@ export class Backend { _onInstalled({reason}) { if (reason !== 'install') { return; } this._requestPersistentStorage(); + this._openWelcomePageOnce(); } // Message handlers @@ -2518,19 +2519,19 @@ export class Backend { /** * @returns {Promise} */ - async _openWelcomeGuidePageOnce() { - chrome.storage.session.get(['openedWelcomePage']).then((result) => { - if (!result.openedWelcomePage) { - this._openWelcomeGuidePage(); - chrome.storage.session.set({'openedWelcomePage': true}); - } - }); + async _openWelcomePageOnce() { + const {openedWelcomePage} = await chrome.storage.local.get(['openedWelcomePage']); + + if (!openedWelcomePage) { + this._openWelcomePage(); + chrome.storage.local.set({'openedWelcomePage': true}); + } } /** * @returns {Promise} */ - async _openWelcomeGuidePage() { + async _openWelcomePage() { await this._createTab(chrome.runtime.getURL('/welcome.html')); } diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index c93e261d0f..4ae1a67802 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -189,7 +189,7 @@ export class OptionsUtil { options.general.audioSource = options.general.audioPlayback ? 'jpod101' : 'disabled'; }, (options) => { - options.general.showGuide = false; + options.general.showWelcomePage = false; }, (options) => { options.scanning.modifier = options.scanning.requireShift ? 'shift' : 'none'; @@ -294,7 +294,7 @@ export class OptionsUtil { popupScalingFactor: 1, popupScaleRelativeToPageZoom: false, popupScaleRelativeToVisualViewport: true, - showGuide: true, + showWelcomePage: false, compactTags: false, compactGlossaries: false, mainDictionary: '', @@ -1129,7 +1129,7 @@ export class OptionsUtil { if (customTemplates && isObject(chrome.storage)) { chrome.storage.session.set({'needsCustomTemplatesWarning': true}); await this._createTab(chrome.runtime.getURL('/welcome.html')); - chrome.storage.session.set({'openedWelcomePage': true}); + chrome.storage.local.set({'openedWelcomePage': true}); } } diff --git a/ext/settings.html b/ext/settings.html index 2cc521d5eb..a0096a50f2 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -211,7 +211,7 @@

Yomitan Settings

Show the welcome guide on browser startup
- +
diff --git a/ext/welcome.html b/ext/welcome.html index 80bd6ab433..5b127164d0 100644 --- a/ext/welcome.html +++ b/ext/welcome.html @@ -133,10 +133,10 @@

Basic customization

-
Show this welcome guide on browser startup
+
Show this welcome page on browser startup
- +
diff --git a/test/options-util.test.js b/test/options-util.test.js index a34cc93a21..a1a49ecc63 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -21,7 +21,7 @@ import fs from 'fs'; import {fileURLToPath} from 'node:url'; import path from 'path'; -import {expect, test, describe, vi} from 'vitest'; +import {describe, expect, test, vi} from 'vitest'; import {OptionsUtil} from '../ext/js/data/options-util.js'; import {TemplatePatcher} from '../ext/js/templates/template-patcher.js'; import {chrome, fetch} from './mocks/common.js'; @@ -56,7 +56,7 @@ function createProfileOptionsTestData1() { popupScalingFactor: 1, popupScaleRelativeToPageZoom: false, popupScaleRelativeToVisualViewport: true, - showGuide: true, + showWelcomePage: true, compactTags: false, compactGlossaries: false, mainDictionary: '', @@ -259,7 +259,7 @@ function createProfileOptionsUpdatedTestData1() { popupScalingFactor: 1, popupScaleRelativeToPageZoom: false, popupScaleRelativeToVisualViewport: true, - showGuide: true, + showWelcomePage: true, compactTags: false, glossaryLayoutMode: 'default', mainDictionary: '', diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index b95691b222..5010bdf8fc 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -117,7 +117,7 @@ export type GeneralOptions = { popupScalingFactor: number; popupScaleRelativeToPageZoom: boolean; popupScaleRelativeToVisualViewport: boolean; - showGuide: boolean; + showWelcomePage: boolean; compactTags: boolean; glossaryLayoutMode: GlossaryLayoutMode; mainDictionary: string;