mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-03 01:44:42 +08:00
Stop using model version
to check if a message is brand new #1467
This commit is contained in:
parent
03dd94596c
commit
d561d7d6a1
2 changed files with 11 additions and 7 deletions
|
@ -30,29 +30,33 @@ export class Notifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// async for testing
|
// async for testing
|
||||||
async _onDatabaseChanged({ objectClass, objects }) {
|
async _onDatabaseChanged({ objectClass, objects, objectsRawJSON }) {
|
||||||
if (AppEnv.config.get('core.notifications.enabled') === false) {
|
if (AppEnv.config.get('core.notifications.enabled') === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectClass === Thread.name) {
|
if (objectClass === Thread.name) {
|
||||||
return this._onThreadsChanged(objects);
|
this._onThreadsChanged(objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectClass === Message.name) {
|
if (objectClass === Message.name) {
|
||||||
return this._onMessagesChanged(objects);
|
const newIds = objectsRawJSON.filter(json => json.headersSyncComplete).map(json => json.id);
|
||||||
|
if (!newIds.length) return;
|
||||||
|
this._onMessagesChanged(objects, newIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// async for testing
|
// async for testing
|
||||||
async _onMessagesChanged(msgs) {
|
async _onMessagesChanged(msgs, newIds: string[]) {
|
||||||
const notifworthy = {};
|
const notifworthy = {};
|
||||||
|
|
||||||
for (const msg of msgs) {
|
for (const msg of msgs) {
|
||||||
// ensure the message is unread
|
// ensure the message is unread
|
||||||
if (msg.unread !== true) continue;
|
if (msg.unread !== true) continue;
|
||||||
// ensure the message was just created (eg: this is not a modification)
|
// ensure the message was just created (eg: this is not a modification).
|
||||||
if (msg.version !== 1) continue;
|
// The sync engine attaches a JSON key to let us know that this is the first
|
||||||
|
// message emitted about this Message. (Hooray hacks around reactive patterns)
|
||||||
|
if (!newIds.includes(msg.id)) continue;
|
||||||
// ensure the message was received after the app launched (eg: not syncing an old email)
|
// ensure the message was received after the app launched (eg: not syncing an old email)
|
||||||
if (!msg.date || msg.date.valueOf() < this.activationTime) continue;
|
if (!msg.date || msg.date.valueOf() < this.activationTime) continue;
|
||||||
// ensure the message is not a loopback
|
// ensure the message is not a loopback
|
||||||
|
|
2
mailsync
2
mailsync
|
@ -1 +1 @@
|
||||||
Subproject commit 0513c6dcb76e131ab864778d135aa6cb40e58dfe
|
Subproject commit b624685a1707b7573c58a0e157736e181169a877
|
Loading…
Add table
Reference in a new issue