Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Times out with lots of messages in draft folder. Easy fix. #162

Open
JustinWi opened this issue Nov 26, 2020 · 0 comments
Open

Times out with lots of messages in draft folder. Easy fix. #162

JustinWi opened this issue Nov 26, 2020 · 0 comments

Comments

@JustinWi
Copy link

The code currently uses the filter() function on an array, which will return all drafts that match the draft subject line entered, but always selects the first draft in the filtered array anyway:

const draft = drafts.filter(subjectFilter_(subject_line))[0];

The filter function takes forever if there are any significant number of draft emails because it looks for all messages that match, which requires looking through every draft message the user has. Instead, since we only draft we care about the first match found (as demonstrated by the "[0]" above), I think you can use the find() function instead and speed things up dramatically:

const draft = drafts.find(subjectFilter_(subject_line));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant