Fix ignoring settings for reaching the first message in a channel if no new messages were saved

This commit is contained in:
chylex 2022-03-13 16:55:35 +01:00
parent ae821f738e
commit f70bbd53d9
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548

View File

@ -42,6 +42,10 @@
stopTrackingDelayed(() => isSending = false); stopTrackingDelayed(() => isSending = false);
}; };
const isNoAction = function(action) {
return action === null || action === CONSTANTS.AUTOSCROLL_ACTION_NOTHING;
};
const onTrackingContinued = function(anyNewMessages) { const onTrackingContinued = function(anyNewMessages) {
if (!STATE.isTracking()) { if (!STATE.isTracking()) {
return; return;
@ -59,14 +63,14 @@
if (SETTINGS.autoscroll) { if (SETTINGS.autoscroll) {
let action = null; let action = null;
if (!anyNewMessages) { if (!DISCORD.hasMoreMessages()) {
action = SETTINGS.afterSavedMsg;
}
else if (!DISCORD.hasMoreMessages()) {
action = SETTINGS.afterFirstMsg; action = SETTINGS.afterFirstMsg;
} }
if (isNoAction(action) && !anyNewMessages) {
action = SETTINGS.afterSavedMsg;
}
if (action === null || action === CONSTANTS.AUTOSCROLL_ACTION_NOTHING) { if (isNoAction(action)) {
DISCORD.loadOlderMessages(); DISCORD.loadOlderMessages();
} }
else if (action === CONSTANTS.AUTOSCROLL_ACTION_PAUSE || (action === CONSTANTS.AUTOSCROLL_ACTION_SWITCH && !DISCORD.selectNextTextChannel())) { else if (action === CONSTANTS.AUTOSCROLL_ACTION_PAUSE || (action === CONSTANTS.AUTOSCROLL_ACTION_SWITCH && !DISCORD.selectNextTextChannel())) {