minor: remove update notifier code

the alarm was already disabled
This commit is contained in:
Index 2024-10-01 18:28:38 -05:00
parent 001f92db85
commit 591dbe1f01

View file

@ -342,86 +342,7 @@ chrome.action.onClicked.addListener((tab) => {
chrome.tabs.create({active: true, url: SettingsURL});
});
// REGISTER AN ALARM FOR DAILY UPDATE CHECK
chrome.alarms.create('PolyPlus-UpdateCheck', {
when: Date.now() + GetNext12PM()
});
function GetNext12PM() {
const Now = new Date();
const Next = new Date();
Next.setHours(12, 0, 0, 0);
if (Now.getHours() >= 12) {
Next.setDate(Next.getDate() + 1);
}
return Next - Now;
}
// HANDLE ALARMS FIRING
/*
chrome.alarms.onAlarm.addListener(function (alarm) {
if (alarm.name === 'PolyPlus-UpdateCheck') {
RunUpdateNotifier();
}
});
*/
function RunUpdateNotifier() {
chrome.storage.local.get(['PolyPlus_LiveVersion', 'PolyPlus_OutOfDate', 'PolyPlus_SkipUpdate'], function (result) {
const OutOfDate = result.PolyPlus_OutOfDate || false;
const SkipUpdate = result.PolyPlus_SkipUpdate || null;
const LiveVersion = result.PolyPlus_LiveVersion || Manifest.version;
if (OutOfDate !== true && SkipUpdate !== LiveVersion) {
fetch('https://polyplus.vercel.app/data/version.json')
.then((response) => {
if (!response.ok) {
throw new Error('Network not ok');
}
return response.json();
})
.then((data) => {
chrome.storage.local.set({PolyPlus_LiveVersion: data.version}, function () {
console.log('Cached live version');
});
if (data.version > Manifest.version) {
chrome.storage.local.set({PolyPlus_OutOfDate: true, PolyPlus_ReleaseNotes: data.releaseNotes}, function () {
console.log('Cached update notifier result');
});
chrome.notifications.create(
'',
{
type: 'basic',
iconUrl: chrome.runtime.getURL('icon.png'),
title: 'New Update Available',
message: 'A new update is available for Poly+! (v' + data.version + ')'
},
function (notificationID) {
chrome.notifications.onClicked.addListener(function (id) {
if (id === notificationID) {
chrome.tabs.create({url: 'https://github.com/IndexingGitHub/PolyPlus/releases', active: true});
chrome.notifications.clear(notificationID);
}
});
}
);
}
})
.catch((error) => {
console.log(error);
});
}
});
}
chrome.contextMenus.removeAll(function () {
chrome.contextMenus.create({
title: 'Run Update Notifier',
id: 'PolyPlus-RunUpdateNotifier',
contexts: ['all'],
documentUrlPatterns: [
'https://polytoria.com/my/settings/polyplus*'
]
});
// COPY ASSET ID CONTEXT MENU ITEM REGISTRATION
/*
const AssetTypes = ["Place", "User", "Item", "Guild"]