|
labelCache[name] = GmailApp.getUserLabelByName(name) || GmailApp.createLabel(name); |
I was just writing an appscript (I found yours when searching to see if there was already a similar solution). In my testing GmailApp.createLabel(name) does the "get or create" step inherently. labelCache[name] = GmailApp.getUserLabelByName(name) || GmailApp.createLabel(name); is unnecessary.
I'd love to know if my understanding is incorrect if I missed something and need to fix my script.
I like the caching though.
gmail-labeler/labeler.gs
Line 28 in fb22f59
I was just writing an appscript (I found yours when searching to see if there was already a similar solution). In my testing
GmailApp.createLabel(name)does the "get or create" step inherently.labelCache[name] = GmailApp.getUserLabelByName(name) || GmailApp.createLabel(name);is unnecessary.I'd love to know if my understanding is incorrect if I missed something and need to fix my script.
I like the caching though.