Skip to content

Commit

Permalink
Firefox: Current tab's Toolbar theme fix in Mixed Mode (#78)
Browse files Browse the repository at this point in the history
* Refactor checks for mixed mode;
Fixes incorrect toolbar theme in *mixed mode* when toggling search widget;
Fixes incorrect toolbar theme in *mixed mode* when rapidly creating tabs;
  • Loading branch information
ZimCodes authored Oct 12, 2021
1 parent 7a66771 commit affe407
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changelog
---

# Unreleased
# 15.0.3 [Firefox: Theming Bug Fixes]
- Fixes incorrect toolbar theme in *mixed mode* when rapidly creating tabs.([#77](https://github.com/doki-theme/doki-theme-web/issues/77))
- Fixes incorrect toolbar theme in *mixed mode* when toggling search widget.([#77](https://github.com/doki-theme/doki-theme-web/issues/77))

# 15.0.2 [Firefox History Sidebar Theming]

Expand Down
2 changes: 1 addition & 1 deletion firefoxThemes/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Doki Theme for Firefox",
"short_name": "Doki Theme",
"version": "15.0.2",
"version": "15.0.3",
"description": "A theme collection of girls from various anime, manga, and visual novels series.",
"manifest_version": 2,
"icons": {
Expand Down
28 changes: 21 additions & 7 deletions firefoxThemes/modules/modes/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,21 @@ function setupMixedUpdate(msg) {
});
});
}

/*Checks if tab is added to the local mixedlist.
* If not, then add it in.*/
function localMixedListCheck(tabId,themes){
if (!mixedList.has(tabId)) {
mixedList.set(tabId, getRandomThemeId(themes));
browser.storage.local.set({mixedTabs: mixedList});
}
}
/*Get the Current Tab's Theme from the local mixed list*/
function getCurrentTabTheme(currentThemeId,tabId){
if(currentThemeId !== mixedList.get(tabId)){
browser.storage.local.set({currentThemeId: mixedList.get(tabId)});
}
return mixedList.get(tabId);
}
/*MESSAGE: Send a message to the page to apply theme*/
function pageResponse(msg) {
if (!msg.mixMSG) return;
Expand All @@ -135,20 +149,20 @@ function pageResponse(msg) {
showWidget: storage.showWidget,
});
} else {
if (!mixedList.has(msg.pageTab.id)) {
mixedList.set(msg.pageTab.id, getRandomThemeId(storage.waifuThemes.themes));
browser.storage.local.set({mixedTabs: mixedList});
}
localMixedListCheck(msg.pageTab.id,storage.waifuThemes.themes);
browser.tabs.sendMessage(msg.pageTab.id, {
pageMSG: true,
waifuThemes: storage.waifuThemes,
currentThemeId: storage.currentThemeId,
currentThemeId: getCurrentTabTheme(storage.currentThemeId,msg.pageTab.id),
backgroundType: storage.backgroundType,
showWidget: storage.showWidget,
mixedTabs: mixedList,
pageTab: msg.pageTab
});
loadTheme(storage.waifuThemes.themes, mixedList.get(msg.pageTab.id));
//Load theme for active(currently shown) tab only
if(msg.pageTab.active){
loadTheme(storage.waifuThemes.themes, mixedList.get(msg.pageTab.id));
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion firefoxThemes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doki-theme-firefox",
"version": "15.0.2",
"version": "15.0.3",
"description": "A theme collection of girls from various anime, manga, and visual novels series.",
"main": "index.js",
"repository": "https://github.com/doki-theme/doki-theme-web",
Expand Down

0 comments on commit affe407

Please sign in to comment.