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