Skip to content

Commit c467ea2

Browse files
committed
Refactor background.js: Remove duplicate onMessage listeners
1 parent 1b46a68 commit c467ea2

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

scripts/background.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ chrome.webNavigation.onHistoryStateUpdated.addListener(({ url, tabId }) => {
4141
}
4242
});
4343

44-
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
44+
chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
4545
if (request.action === "authenticateUser") {
4646
chrome.tabs.create({ url: authUrl, active: true });
4747
chrome.tabs.onUpdated.addListener(onTabUpdate);
4848
}
49-
});
5049

51-
chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
5250
if (request.action === "connectExistingRepo") {
5351
const { userInput } = request;
5452
if (userInput.length === 0 || userInput.length > 100) {
@@ -99,9 +97,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
9997
});
10098
chrome.runtime.sendMessage({ action: "updateUI" });
10199
}
102-
});
103100

104-
chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
105101
if (request.action === "createRepo") {
106102
const { userInput } = request;
107103
if (userInput.length === 0 || userInput.length > 100) {
@@ -159,17 +155,13 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
159155
});
160156
chrome.runtime.sendMessage({ action: "updateUI" });
161157
}
162-
});
163158

164-
chrome.runtime.onMessage.addListener(async (request) => {
165159
if (request.action === "unlinkRepo") {
166160
await chrome.storage.local.remove(["repo"]);
167161
chrome.storage.local.set({ isRepoConnected: false });
168162
chrome.runtime.sendMessage({ action: "updateUI" });
169163
}
170-
});
171164

172-
chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
173165
if (request.action === "pushToGithub") {
174166
const { githubUsername, repo, directory, accessToken } =
175167
await chrome.storage.local.get([

0 commit comments

Comments
 (0)