-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird Issue on single message thread. #1
Comments
That's quite weird, I am using this script since February and I never had any problems with it. |
The answer may lie here: var last_index = threads[i].getMessageCount()-1;
var len = threads[i].getMessageCount();
Logger.log(threads[i].getMessageCount())
Logger.log(len)
Logger.log(threads[i].getMessageCount() - 1)
Logger.log(last_index) result:
This being my first experience in javascript I can hardly diagnose, but there seems to be some problems with the array length being interpreted as the wrong integer value in expressions, but being resolved correctly when storing into a variable. The issue also occurs for a thread of 3 messages where I get a blank email due to an attempt to access a non-existant 4th element. |
Let me just rephrase that so I can collect like terms Logger.log(threads[i].getMessageCount())
//[16-01-12 12:21:55:798 AEDT] 2.0
var len = threads[i].getMessageCount();
Logger.log(len)
//[16-01-12 12:21:55:799 AEDT] 1.0
Logger.log(threads[i].getMessageCount() - 1)
//[16-01-12 12:21:55:800 AEDT] 1.0
var last_index = threads[i].getMessageCount()-1;
Logger.log(last_index)
//[16-01-12 12:21:55:800 AEDT] 0.0 Wow! This is every programmer's worst nightmare. A statement that evaluates to a different value if it's stored in a variable. Maybe this is some kind of rounding issue behind the scenes? |
You're likely correct, the lack of a built in integral type and weird array issues in general are worrying. Nonetheless your original proposed solution has worked for me with single and multi-message threads. |
I attempted to implement the snoozever script and I was getting empty notes titled "To do from inbox - "
Now I throw some logging in.
Given
I get the following logs
I change the following code (I'm no javascript expert) so I don't know why this worked.
Which results in finding the correct message
I don't know if others are having this issue but figured I'd let you know. Again that shouldn't have fixed anything but I can revert it and see the exact issue again.
The text was updated successfully, but these errors were encountered: