Skip to content

Commit

Permalink
修复一个可能导致异常推送的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun-Shan committed Jul 1, 2024
1 parent 73fab43 commit c7fb8f9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/background/CookieHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function tryNotice(source, newCookieList) {
}

const LocalCardMap = {};
let LastServerList = [];
const ServerCookieIdCache = new Set();

/**
* 蹲饼处理器
Expand Down Expand Up @@ -200,9 +200,8 @@ class CookieHandler {

DunInfo.counter++;
DunInfo.lastDunTime = Date.now();
if (LastServerList && LastServerList.length > 0) {
const map = Object.fromEntries(LastServerList.map((it) => [it.id, true]));
const newCookies = items.filter((it) => !map[it.id]);
if (ServerCookieIdCache.size > 0) {
const newCookies = items.filter((it) => !ServerCookieIdCache.has(it.id));
DunInfo.cookieCount += newCookies.length;
console.log('new cookies: ', newCookies);
await new Promise((r) => AvailableDataSourceMeta.doAfterInit(r));
Expand All @@ -222,14 +221,15 @@ class CookieHandler {
}
}

LastServerList = items;
items.forEach((it) => ServerCookieIdCache.add(it.id));

CardList.firstPageCookieList[configId] = items;
CardList.sendUpdateAtNextTick();
await PlatformHelper.Storage.saveLocalStorage('server_cookie_list_next_page_id', data.next_page_id || '');
}

static resetLastServerList() {
LastServerList = [];
ServerCookieIdCache.clear();
}
}

Expand Down

0 comments on commit c7fb8f9

Please sign in to comment.