Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kabir-afk/SignIt
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir-afk committed Jun 19, 2024
2 parents 839b281 + 7512d92 commit 63ea338
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 16 additions & 5 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,21 @@ var browser = (browserType === 'firefox') ? browser : (browserType === 'chrome')
ui = new UI();
ui.switchPanel( 'loaded' );
}
chrome.runtime.onMessage.addListener((message, sender) => {
console.log(sender);
if (message.state === "ready") {
ui = new UI();
}
if (browserType === "chrome") {
chrome.runtime.onMessage.addListener((message, sender) => {
if (message.state === "ready") {
ui = new UI();
}
});
} else {
let state = _backgroundPage.state;
function waitWhileLoading() {
if (state === "ready") {
ui = new UI();
} else {
setTimeout(waitWhileLoading, 100);
}
}
waitWhileLoading();
}
})();
6 changes: 2 additions & 4 deletions sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ const WAIT_ALARM = 'waitWhileLoading';
async function createAlarm() {
await chrome.alarms.create(WAIT_ALARM, {
periodInMinutes: 1 / 60 // by specifying it as fraction we can run the ⏰ in every 1 second
},()=>console.log('⏰ running inside createAlarm()',new Date().getSeconds()));
});
}

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
Expand All @@ -788,9 +788,7 @@ chrome.alarms.onAlarm.addListener((alarm)=>{
if (alarm.name === WAIT_ALARM) {
if (state === 'ready') {
chrome.runtime.sendMessage({state:'ready'});
chrome.alarms.clear(WAIT_ALARM,()=>{
console.log('⏰ stopped at ',new Date().getSeconds());
});
chrome.alarms.clear(WAIT_ALARM);
}
}
})

0 comments on commit 63ea338

Please sign in to comment.