Skip to content

Commit

Permalink
feat!: remove utility bar
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Sep 26, 2022
1 parent 05c8fbd commit dc1c2fd
Show file tree
Hide file tree
Showing 20 changed files with 0 additions and 485 deletions.
4 changes: 0 additions & 4 deletions src/components/TabConfigModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@
<label for="tab-sound">Sound:</label>
<Toggle id="tab-sound" bind:value={tabSettings.config.sound} />
</div>
<div class="option">
<label for="tab-utilityBar">Utility Bar:</label>
<Toggle id="tab-utilityBar" bind:value={tabSettings.config.utilityBar} />
</div>
<div class="option">
<label for="tab-color">Color:</label>
<div class="color-input">
Expand Down
1 change: 0 additions & 1 deletion src/components/WebView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
});
}
webviewElement.send("toggle-notifications", tab.config.notifications);
webviewElement.send("set-utility-bar", tab.config.utilityBar);
webviewElement.setAudioMuted(!tab.config.sound);
};
Expand Down
102 changes: 0 additions & 102 deletions src/preload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
const { ipcRenderer } = require("electron");
const dispatchMouseEvents = require("./util/webview/dispatchMouseEvents");
const formatSelectedText = require("./util/webview/formatSelectedText");
const enableUtilityBar = require("./util/webview/utilityBar/enableUtilityBar");
const disableUtilityBar = require("./util/webview/utilityBar/disableUtilityBar");
const Store = require("electron-store");
const elementSelectors = require("./util/webview/utilityBar/elementSelectors");

let quickRepliesStore = new Store({
name: "quick_replies",
defaults: {},
});

ipcRenderer.send("flush-session-data");

Expand Down Expand Up @@ -101,7 +92,6 @@ window.onload = () => {

new MutationObserver((mutations) => {
// Check when WhatsApp is done loading

if (mutations[0].removedNodes[0]?.innerHTML.includes("progress")) {
// Remove "Update available" message
if (
Expand All @@ -110,80 +100,6 @@ window.onload = () => {
document.querySelector("._3z9_h").firstChild.remove();
}
}

if (document.querySelector(".two")) {
new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes.length > 0) {
if (
Array.from(mutation.addedNodes).find((node) => node.id === "main")
) {
if (window.utilityBar) {
if (document.querySelector(".utility-bar"))
document.querySelector(".utility-bar").remove();
if (!document.querySelector(".utility-bar")) enableUtilityBar();
} else {
if (document.querySelector(".utility-bar")) disableUtilityBar();
}
}

if (
Array.from(mutation.addedNodes).find(
(node) =>
node.classList &&
node.classList.length > 0 &&
node.classList.contains(elementSelectors.emojiPanel)
)
) {
if (document.querySelector(".utility-bar")) disableUtilityBar();
}

if (
Array.from(mutation.addedNodes).find(
(node) =>
node.classList &&
node.classList.length > 0 &&
node.classList.contains(elementSelectors.replyPanel)
)
) {
let replyHeight = document.querySelector(
`.${elementSelectors.replyPanel}`
).scrollHeight;
document.querySelector(
"footer"
).previousElementSibling.style.height = `${replyHeight + 47}px`;
document.querySelector(
".utility-bar"
).style.transform = `translateY(-${replyHeight}px)`;
}
}

if (mutation.removedNodes.length > 0) {
if (
Array.from(mutation.removedNodes).find(
(node) =>
(node.classList &&
node.classList.length > 0 &&
node.classList.contains(elementSelectors.emojiPanel)) ||
node.classList.contains(elementSelectors.replyPanel)
)
) {
if (!document.querySelector(".utility-bar")) {
enableUtilityBar();
} else {
document.querySelector(
"footer"
).previousElementSibling.style.height = "47px";
document.querySelector(".utility-bar").style.transform = "";
}
}
}
});
}).observe(document.querySelector(".two"), {
subtree: true,
childList: true,
});
}
}).observe(document.querySelector("#app"), {
subtree: true,
childList: true,
Expand All @@ -201,14 +117,6 @@ const appendTheme = (css) => {
}
};

ipcRenderer.on("set-id", (e, id) => {
document.body.id = id;
let quickReplies = quickRepliesStore.get(id);
if (!quickReplies || quickReplies.length === 0) {
quickRepliesStore.set(id, []);
}
});

ipcRenderer.on("set-theme", (e, theme) => {
// Reset classes
document.body.className = "web";
Expand All @@ -229,16 +137,6 @@ ipcRenderer.on("set-theme", (e, theme) => {
appendTheme(theme.css ? theme.css : "");
});

ipcRenderer.on("set-utility-bar", (e, utilityBarEnabled) => {
if (utilityBarEnabled) {
window.utilityBar = true;
if (!document.querySelector(".utility-bar")) enableUtilityBar();
} else {
window.utilityBar = false;
disableUtilityBar();
}
});

ipcRenderer.on("toggle-notifications", (_, setting) => {
if (!setting) {
window.Notification = "";
Expand Down
1 change: 0 additions & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type TabType = {
theme: string;
notifications: boolean;
sound: boolean;
utilityBar: boolean;
color: string;
spellChecker: boolean;
};
Expand Down
1 change: 0 additions & 1 deletion src/util/defaultTabSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const defaultTabSettings = () => {
theme: "default",
notifications: true,
sound: true,
utilityBar: false,
color: "#2A3440",
spellChecker: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/util/migrateTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const migrateTab = (tab) => {
theme: tab.theme,
notifications: tab.notifications,
sound: tab.sound,
utilityBar: tab.utility_bar,
color: tab.tab_color,
spellChecker: tab.spellcheck,
},
Expand Down
17 changes: 0 additions & 17 deletions src/util/webview/utilityBar/addQuickReply.js

This file was deleted.

64 changes: 0 additions & 64 deletions src/util/webview/utilityBar/clickHandler.js

This file was deleted.

33 changes: 0 additions & 33 deletions src/util/webview/utilityBar/confirmRemoveQuickReply.js

This file was deleted.

23 changes: 0 additions & 23 deletions src/util/webview/utilityBar/createAddReplyContainer.js

This file was deleted.

19 changes: 0 additions & 19 deletions src/util/webview/utilityBar/createFormattingContainer.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/util/webview/utilityBar/createQuickReplyContainer.js

This file was deleted.

Loading

0 comments on commit dc1c2fd

Please sign in to comment.