Prevent rollover on keyboard left swipe if repeating Closes #3636

6aaa533410f1f50e0483302fcb13aa82ecdb9882

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +15 -3Ignore whitespace
public/script.js+14 -2
@@ -8746,11 +8746,18 @@ function formatSwipeCounter(current, total) {
87468746 return `${current}\u200b/\u200b${total}`;
87478747}
87488748
8749-function swipe_left() { // when we swipe left..but no generation.
8749+/**
8750+ * Handles the swipe to the left event.
8751+ * @param {JQuery.Event} _event Event.
8752+ * @param {object} params Additional parameters.
8753+ * @param {string} [params.source] The source of the swipe event.
8754+ * @param {boolean} [params.repeated] Is the swipe event repeated.
8755+ * @returns
8756+ */
8757+function swipe_left(_event, { source, repeated } = {}) { // when we swipe left..but no generation.
87508758 if (chat.length - 1 === Number(this_edit_mes_id)) {
87518759 closeMessageEditor();
87528760 }
8753-
87548761 if (isStreamingEnabled() && streamingProcessor) {
87558762 streamingProcessor.onStopStreaming();
87568763 }
@@ -8758,6 +8765,11 @@ function swipe_left() { // when we swipe left..but no generation.
87588765 // Make sure ad-hoc changes to extras are saved before swiping away
87598766 syncMesToSwipe();
87608767
8768+ if (source === 'keyboard' && repeated && chat[chat.length - 1].swipe_id === 0) {
8769+ // If the user is holding down the key and we're at the first swipe, don't do anything
8770+ return;
8771+ }
8772+
87618773 const swipe_duration = 120;
87628774 const swipe_range = '700px';
87638775 chat[chat.length - 1]['swipe_id']--;
public/scripts/RossAscends-mods.js+1 -1
@@ -1143,7 +1143,7 @@ export function initRossMods() {
11431143 $('#shadow_select_chat_popup').css('display') === 'none' &&
11441144 !isInputElementInFocus()
11451145 ) {
11461146 $('.swipe_left:last').clicktrigger('click', { source: 'keyboard', repeated: event.repeat });
11471147 return;
11481148 }
11491149 }