mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 02:48:49 +03:00
ics-viewer: read the attachments again once the message body is loaded
The view sets the message before populateMessageBody() fills its attachments, so attachments() is still empty when the plugin looks for the calendar part, and it never looked again: the event panel did not show up for most invitations. Subscribe to msg.attachments until the part is found or another message is shown, and drop a late result that belongs to a message no longer displayed.
This commit is contained in:
parent
75303886d3
commit
81bde353f4
1 changed files with 19 additions and 2 deletions
|
|
@ -92,12 +92,23 @@
|
|||
// A scheduling mail does not always carry a text/calendar
|
||||
// attachment either: the part is often inline inside
|
||||
// multipart/alternative and repeated as application/ics.
|
||||
// The message is set before its body is fetched
|
||||
// (populateMessageBody), so attachments are usually still
|
||||
// empty at this point: read them again when they arrive,
|
||||
// once per message, and stop listening when it is done or
|
||||
// when another message is shown.
|
||||
let subscription = null, found = false;
|
||||
const stop = () => subscription && (subscription.dispose(), subscription = null);
|
||||
const readIcs = () => {
|
||||
if (view.message() !== msg) return stop();
|
||||
let ics = (msg.attachments() || []).find(attachment =>
|
||||
'text/calendar' == attachment.mimeType
|
||||
|| 'application/ics' == attachment.mimeType
|
||||
|| 'text/x-vcalendar' == attachment.mimeType
|
||||
|| /\.ics$/i.test(attachment.fileName || ''));
|
||||
if (ics && ics.download) {
|
||||
found = true;
|
||||
stop();
|
||||
|
||||
// fetch it and parse the VEVENT
|
||||
rl.fetch(ics.linkDownload())
|
||||
|
|
@ -131,9 +142,15 @@
|
|||
isCancelled: VEVENT.isCancelled(),
|
||||
shouldReply: VEVENT.shouldReply()
|
||||
});
|
||||
view.ICSViewer(VEVENT);
|
||||
view.message() === msg && view.ICSViewer(VEVENT);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(e => console.error('[ics-viewer]', e));
|
||||
}
|
||||
};
|
||||
readIcs();
|
||||
if (!found && view.message() === msg) {
|
||||
subscription = msg.attachments.subscribe(readIcs);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue