Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to welcome page configuration #579

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/data/schemas/options-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"popupScalingFactor",
"popupScaleRelativeToPageZoom",
"popupScaleRelativeToVisualViewport",
"showGuide",
"showWelcomePage",
"compactTags",
"glossaryLayoutMode",
"mainDictionary",
Expand Down Expand Up @@ -197,9 +197,9 @@
"type": "boolean",
"default": true
},
"showGuide": {
"showWelcomePage": {
"type": "boolean",
"default": true
"default": false
},
"compactTags": {
"type": "boolean",
Expand Down
21 changes: 11 additions & 10 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -420,6 +420,7 @@ export class Backend {
_onInstalled({reason}) {
if (reason !== 'install') { return; }
this._requestPersistentStorage();
this._openWelcomePageOnce();
}

// Message handlers
Expand Down Expand Up @@ -2518,19 +2519,19 @@ export class Backend {
/**
* @returns {Promise<void>}
*/
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<void>}
*/
async _openWelcomeGuidePage() {
async _openWelcomePage() {
await this._createTab(chrome.runtime.getURL('/welcome.html'));
}

Expand Down
6 changes: 3 additions & 3 deletions ext/js/data/options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -294,7 +294,7 @@ export class OptionsUtil {
popupScalingFactor: 1,
popupScaleRelativeToPageZoom: false,
popupScaleRelativeToVisualViewport: true,
showGuide: true,
showWelcomePage: false,
compactTags: false,
compactGlossaries: false,
mainDictionary: '',
Expand Down Expand Up @@ -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});
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ <h1>Yomitan Settings</h1>
<div class="settings-item-label">Show the <a href="/welcome.html" target="_blank" rel="noopener">welcome guide</a> on browser startup</div>
</div>
<div class="settings-item-right">
<label class="toggle"><input type="checkbox" data-setting="general.showGuide"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
<label class="toggle"><input type="checkbox" data-setting="general.showWelcomePage"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
</div>
</div></div>
<div class="settings-item">
Expand Down
4 changes: 2 additions & 2 deletions ext/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ <h2>Basic customization</h2>
<div class="settings-group">
<div class="settings-item"><div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Show this welcome guide on browser startup</div>
<div class="settings-item-label">Show this welcome page on browser startup</div>
</div>
<div class="settings-item-right">
<label class="toggle"><input type="checkbox" data-setting="general.showGuide"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
<label class="toggle"><input type="checkbox" data-setting="general.showWelcomePage"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
</div>
</div></div>
<div class="settings-item">
Expand Down
6 changes: 3 additions & 3 deletions test/options-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -56,7 +56,7 @@ function createProfileOptionsTestData1() {
popupScalingFactor: 1,
popupScaleRelativeToPageZoom: false,
popupScaleRelativeToVisualViewport: true,
showGuide: true,
showWelcomePage: true,
compactTags: false,
compactGlossaries: false,
mainDictionary: '',
Expand Down Expand Up @@ -259,7 +259,7 @@ function createProfileOptionsUpdatedTestData1() {
popupScalingFactor: 1,
popupScaleRelativeToPageZoom: false,
popupScaleRelativeToVisualViewport: true,
showGuide: true,
showWelcomePage: true,
compactTags: false,
glossaryLayoutMode: 'default',
mainDictionary: '',
Expand Down
2 changes: 1 addition & 1 deletion types/ext/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export type GeneralOptions = {
popupScalingFactor: number;
popupScaleRelativeToPageZoom: boolean;
popupScaleRelativeToVisualViewport: boolean;
showGuide: boolean;
showWelcomePage: boolean;
compactTags: boolean;
glossaryLayoutMode: GlossaryLayoutMode;
mainDictionary: string;
Expand Down
Loading