WAPI.loadEarlierMessagesTillDate enters infinite loop if the earliest message is posterior to the requested time
See original GitHub issueCurrent implementation of loadEarlierMessagesTillDate is
window.WAPI.loadEarlierMessagesTillDate = function (id, lastMessage, done) {
const found = WAPI.getChat(id);
x = function () {
if (found.msgs.models[0].t > lastMessage) {
found.loadEarlierMsgs().then(x);
} else {
done();
}
};
x();
};
This tries to retrieve earlier messages even if the chat doesn’t have any, which may cause an infinite loop. The fix would be something in the lines of:
window.WAPI.loadEarlierMessagesTillDate = function (id, lastMessage, done) {
const found = WAPI.getChat(id);
x = function () {
if (found.msgs.models[0].t > lastMessage && !found.msgs.msgLoadState.noEarlierMsgs) {
found.loadEarlierMsgs().then(x);
} else {
done();
}
};
x();
};
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
R42520 Is In Infinite Loop If Print Message Contains 24 Lines
When Print Message with 24 lines text data is processed by R42520 , the UBE keeps on processing for long time and User...
Read more >Multicastsocket keeps receiving same message in infinite loop
Basically when this flag is enabled, you will receive messages you send on the multicast socket. So if you also send a message...
Read more >Infinite loop occurs when using LEAVE trigger and MESSAGE ...
An infinite loop may occur in an application which uses multiple embedded windows. The loop may occur when a LEAVE trigger executes the...
Read more >Display warning message-Infinite loop - NI Community
During execution, the display enters infinite loop. I want the warning to disappear when pressed "OK" button and ten turn the pump off....
Read more >The sulla from danielcardeenas - GithubHelp
... enters infinite loop if the earliest message is posterior to the requested time. Current implementation of loadEarlierMessagesTillDate is. window.WAPI.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@OskJonsdottir You should suggest this change in this repo: https://github.com/mukulhase/WebWhatsapp-Wrapper as the wapi.js is taken from here: https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/master/webwhatsapi/js/wapi.js
@danielcardeenas Apparently someone fixed this in the original WAPI repo now…
https://github.com/mukulhase/WebWhatsapp-Wrapper/commit/da1dd396e769e3d812a55f929013ab570503d3f3#diff-ab0d21a115b41c44e1ec163f3a78f078R492
Maybe we can update wapi.js in this repo to pull the fix?