@bobfrankston/rmfmail 1.2.78 → 1.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6753,7 +6753,11 @@ var GmailApiProvider = class _GmailApiProvider {
6753
6753
  }
6754
6754
  const cap = options.since ? 0 : 200;
6755
6755
  const ids = await this.listMessageIds(query, cap);
6756
- return this.batchFetch(ids, options);
6756
+ const fresh = options.knownUids ? ids.filter((id) => !options.knownUids.has(idToUid(id))) : ids;
6757
+ if (options.knownUids) {
6758
+ console.log(`[gmail] fetchSince ${folder}: ${ids.length} listed, ${ids.length - fresh.length} already stored, fetching ${fresh.length}`);
6759
+ }
6760
+ return this.batchFetch(fresh, options);
6757
6761
  }
6758
6762
  async fetchByDate(folder, since, before, options = {}, onChunk) {
6759
6763
  const afterDate = this.formatDate(since);
@@ -10052,10 +10056,18 @@ var AndroidSyncManager = class {
10052
10056
  emitEvent({ type: "syncProgress", accountId, phase: `sync:${folder.path}`, progress: 0 });
10053
10057
  const highestUid = this.db.getHighestUid(accountId, folderId);
10054
10058
  const startDate = new Date(Date.now() - 30 * 864e5);
10059
+ const account = this.db.getAccounts().find((a) => a.id === accountId);
10060
+ const isGoogle = !!account && isGoogleAccount(account);
10055
10061
  let messages;
10056
10062
  if (highestUid > 0) {
10057
- messages = await provider.fetchSince(folder.path, highestUid, { source: false });
10058
- messages = messages.filter((m) => m.uid > highestUid);
10063
+ const opts = { source: false };
10064
+ if (isGoogle) {
10065
+ opts.knownUids = new Set(this.db.getUidsForFolder(accountId, folderId));
10066
+ }
10067
+ messages = await provider.fetchSince(folder.path, highestUid, opts);
10068
+ if (!isGoogle) {
10069
+ messages = messages.filter((m) => m.uid > highestUid);
10070
+ }
10059
10071
  } else {
10060
10072
  const tomorrow = new Date(Date.now() + 864e5);
10061
10073
  messages = await provider.fetchByDate(folder.path, startDate, tomorrow, { source: false });