|
@@ -256,12 +256,32 @@ export async function setMessageCount () {
|
|
|
const { accessToken: token = '', uid = '' } = await getChromeStorage('userInfo') || {}
|
|
|
if(token) {
|
|
|
getMessageInfo();
|
|
|
- setInterval(() => {
|
|
|
- getMessageInfo();
|
|
|
- }, 60000);
|
|
|
+ createAlarm();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function createAlarm() {
|
|
|
+ let alarmInfo = {
|
|
|
+
|
|
|
+ delayInMinutes: 1,
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ periodInMinutes : 1
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ chrome.alarms.clearAll();
|
|
|
+
|
|
|
+ chrome.alarms.onAlarm.addListener(function(alarm) {
|
|
|
+ console.log("onAlarm-", alarm);
|
|
|
+ getMessageInfo();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ chrome.alarms.create('denetChromeAlarm',alarmInfo);
|
|
|
+}
|
|
|
+
|
|
|
export function getMessageInfo () {
|
|
|
fetchAllMessageInfo().then(res => {
|
|
|
if(res.code == 0) {
|