Enable override color if user has custom colors when updating to 2.8.0

This commit is contained in:
sienori 2022-08-30 21:25:41 +09:00
parent 309465898a
commit 4d250e84bc

View file

@ -2,7 +2,14 @@ import browser from "webextension-polyfill";
import log from "loglevel"; import log from "loglevel";
import { initSettings, getSettings, setSettings } from "src/settings/settings"; import { initSettings, getSettings, setSettings } from "src/settings/settings";
import { initShortcuts } from "./keyboardShortcuts"; import { initShortcuts } from "./keyboardShortcuts";
import {
RESULT_FONT_COLOR_LIGHT,
RESULT_FONT_COLOR_DARK,
CANDIDATE_FONT_COLOR_LIGHT,
CANDIDATE_FONT_COLOR_DARK,
BG_COLOR_LIGHT,
BG_COLOR_DARK
} from "src/settings/defaultColors";
const logDir = "background/onInstalledListener"; const logDir = "background/onInstalledListener";
const openOptionsPage = active => { const openOptionsPage = active => {
@ -22,4 +29,17 @@ export default async details => {
const isShowOptionsPage = getSettings("isShowOptionsPageWhenUpdated"); const isShowOptionsPage = getSettings("isShowOptionsPageWhenUpdated");
if (isShowOptionsPage) openOptionsPage(false); if (isShowOptionsPage) openOptionsPage(false);
setSettings("isShowUpdated", true); setSettings("isShowUpdated", true);
// Version 2.8.0以前からのアップデート
if (details.reason == "update" && details.previousVersion.replaceAll(".", "") < 280) {
//ユーザーが独自の色を設定していた場合、色の置き換えを有効にする
const isSetUserColor =
getSettings("resultFontColor") !== RESULT_FONT_COLOR_LIGHT && getSettings("resultFontColor") !== RESULT_FONT_COLOR_DARK ||
getSettings("candidateFontColor") !== CANDIDATE_FONT_COLOR_LIGHT && getSettings("candidateFontColor") !== CANDIDATE_FONT_COLOR_DARK ||
getSettings("bgColor") !== BG_COLOR_LIGHT && getSettings("bgColor") !== BG_COLOR_DARK;
if (isSetUserColor) {
setSettings("isOverrideColors", true);
}
}
}; };