Changelog opening no longer active tab + default to off

pull/367/head
Kevin Payravi 2023-11-27 03:19:14 -05:00
parent 9e86f6c5fe
commit 661875ceb8
4 changed files with 39 additions and 4 deletions

View File

@ -40,9 +40,9 @@ chrome.runtime.onInstalled.addListener(async function (detail) {
} }
// If update, open changelog if setting is enabled // If update, open changelog if setting is enabled
chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) {
if (item.openChangelog === 'on' && detail.reason === 'update') { if (item.openChangelog === 'on' && detail.reason === 'update') {
chrome.tabs.create({ url: 'https://getindie.wiki/changelog/?updated=true' }); chrome.tabs.create({ url: 'https://getindie.wiki/changelog/?updated=true', active: false });
} }
}); });

View File

@ -357,6 +357,13 @@
independent English wikis when no same-language wiki exists independent English wikis when no same-language wiki exists
</label> </label>
</div> </div>
<div class="settingToggle">
<label>
<input id="openChangelogCheckbox" type="checkbox" />
<span id="openChangelogIcon" aria-hidden="true"></span>
Open changelog when Indie Wiki Buddy is updated
</label>
</div>
</fieldset> </fieldset>
<fieldset id="breezewikiSettings"> <fieldset id="breezewikiSettings">
<legend> <legend>

View File

@ -250,6 +250,22 @@ function setCrossLanguage(setting, storeSetting = true) {
} }
} }
// Set open changelog setting
function setOpenChangelog(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'openChangelog': setting });
}
const openChangelogIcon = document.getElementById('openChangelogIcon');
if (setting === 'on') {
document.getElementById('openChangelogCheckbox').checked = true;
openChangelogIcon.innerText = '📂';
} else {
document.getElementById('openChangelogCheckbox').checked = false;
openChangelogIcon.innerText = '📁';
}
}
// Set default action setting // Set default action setting
chrome.storage.sync.get(['defaultWikiAction'], function (item) { chrome.storage.sync.get(['defaultWikiAction'], function (item) {
if (item.defaultWikiAction === 'disabled') { if (item.defaultWikiAction === 'disabled') {
@ -380,6 +396,9 @@ document.addEventListener('DOMContentLoaded', function () {
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) { chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
setCrossLanguage(item.crossLanguage, false); setCrossLanguage(item.crossLanguage, false);
}); });
chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) {
setOpenChangelog(item.openChangelog, false);
});
chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) { chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) {
setBreezeWiki(item.breezewiki, false); setBreezeWiki(item.breezewiki, false);
@ -417,6 +436,15 @@ document.addEventListener('DOMContentLoaded', function () {
} }
}); });
}); });
document.getElementById('openChangelogCheckbox').addEventListener('change', function () {
chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) {
if (item.openChangelog === 'on') {
setOpenChangelog('off');
} else {
setOpenChangelog('on');
}
});
});
// Add event listeners for BreezeWiki settings // Add event listeners for BreezeWiki settings
document.getElementById('breezewikiCheckbox').addEventListener('change', function () { document.getElementById('breezewikiCheckbox').addEventListener('change', function () {

View File

@ -777,7 +777,7 @@ document.addEventListener('DOMContentLoaded', function () {
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) { chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
setCrossLanguage(item.crossLanguage, false); setCrossLanguage(item.crossLanguage, false);
}); });
chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) {
setOpenChangelog(item.openChangelog, false); setOpenChangelog(item.openChangelog, false);
}); });
chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) { chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) {
@ -818,7 +818,7 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
}); });
document.getElementById('openChangelogCheckbox').addEventListener('change', function () { document.getElementById('openChangelogCheckbox').addEventListener('change', function () {
chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) {
if (item.openChangelog === 'on') { if (item.openChangelog === 'on') {
setOpenChangelog('off'); setOpenChangelog('off');
} else { } else {