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) {
8746 return `${current}\u200b/\u200b${total}`;8746 return `${current}\u200b/\u200b${total}`;
8747}8747}
87488748
8749function 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 */
8757function swipe_left(_event, { source, repeated } = {}) { // when we swipe left..but no generation.
8750 if (chat.length - 1 === Number(this_edit_mes_id)) {8758 if (chat.length - 1 === Number(this_edit_mes_id)) {
8751 closeMessageEditor();8759 closeMessageEditor();
8752 }8760 }
8753
8754 if (isStreamingEnabled() && streamingProcessor) {8761 if (isStreamingEnabled() && streamingProcessor) {
8755 streamingProcessor.onStopStreaming();8762 streamingProcessor.onStopStreaming();
8756 }8763 }
@@ -8758,6 +8765,11 @@ function swipe_left() { // when we swipe left..but no generation.
8758 // Make sure ad-hoc changes to extras are saved before swiping away8765 // Make sure ad-hoc changes to extras are saved before swiping away
8759 syncMesToSwipe();8766 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
8761 const swipe_duration = 120;8773 const swipe_duration = 120;
8762 const swipe_range = '700px';8774 const swipe_range = '700px';
8763 chat[chat.length - 1]['swipe_id']--;8775 chat[chat.length - 1]['swipe_id']--;
public/scripts/RossAscends-mods.js+1 -1
@@ -1143,7 +1143,7 @@ export function initRossMods() {
1143 $('#shadow_select_chat_popup').css('display') === 'none' &&1143 $('#shadow_select_chat_popup').css('display') === 'none' &&
1144 !isInputElementInFocus()1144 !isInputElementInFocus()
1145 ) {1145 ) {
1146 $('.swipe_left:last').click();1146 $('.swipe_left:last').trigger('click', { source: 'keyboard', repeated: event.repeat });
1147 return;1147 return;
1148 }1148 }
1149 }1149 }