From a2727c65fe129d6ee59b220210c0f8294284f66c Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 12 Feb 2021 12:00:06 +0100 Subject: [PATCH] Bugfix: messages list ArrowUp/ArrowDown broken --- .eslintrc.js | 3 ++- dev/Common/Selector.js | 29 ++++------------------------ dev/External/ifvisible.js | 4 ++-- dev/View/User/MailBox/MessageList.js | 19 +++++++++--------- 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index afec4cd58..b313093c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,9 +28,10 @@ module.exports = { 'SquireUI': "readonly", // node_modules/knockout but dev/External/ko.js is used 'ko': "readonly", + // dev/External/ifvisible.js + 'ifvisible': "readonly", // vendors/routes/ 'hasher': "readonly", - 'signals': "readonly", 'Crossroads': "readonly", // vendors/jua 'Jua': "readonly", diff --git a/dev/Common/Selector.js b/dev/Common/Selector.js index 12020e1d5..36bf86c6a 100644 --- a/dev/Common/Selector.js +++ b/dev/Common/Selector.js @@ -232,20 +232,6 @@ export class Selector { } } - /** - * @param {boolean} forceSelect - */ - goDown(forceSelect) { - this.newSelectPosition('ArrowDown', false, forceSelect); - } - - /** - * @param {boolean} forceSelect - */ - goUp(forceSelect) { - this.newSelectPosition('ArrowUp', false, forceSelect); - } - unselect() { this.selectedItem(null); this.focusedItem(null); @@ -283,8 +269,7 @@ export class Selector { return true; }); - shortcuts.add('arrowup', 'meta', keyScope, () => false); - shortcuts.add('arrowdown', 'meta', keyScope, () => false); + shortcuts.add('arrowup,arrowdown', 'meta', keyScope, () => false); shortcuts.add('arrowup,arrowdown', 'shift', keyScope, event => { this.newSelectPosition(event.key, true); @@ -329,7 +314,7 @@ export class Selector { result = null; const pageStep = 10, - list = this.list, + list = this.list(), listLen = list.length, focused = this.focusedItem(); @@ -342,9 +327,7 @@ export class Selector { } else if (++i < listLen) { result = list[i]; } - if (!result && ' ' !== sEventKey) { - (this.oCallbacks.onUpUpOrDownDown || (()=>true))('ArrowUp' === sEventKey); - } + result || (this.oCallbacks.onUpUpOrDownDown || (()=>true))('ArrowUp' === sEventKey); } else if ('Home' === sEventKey) { result = list[0]; } else if ('End' === sEventKey) { @@ -361,13 +344,11 @@ export class Selector { } } } else if ( - 'ArrowUp' == sEventKey || 'Home' == sEventKey || 'PageUp' == sEventKey ) { result = list[0]; } else if ( - 'ArrowDown' === sEventKey || 'End' === sEventKey || 'PageDown' === sEventKey ) { @@ -392,9 +373,7 @@ export class Selector { this.scrollToFocused(); } else if (focused) { - if (bShiftKey && isArrow) { - focused.checked(!focused.checked()); - } else if (' ' === sEventKey) { + if ((bShiftKey && isArrow) || ' ' === sEventKey) { focused.checked(!focused.checked()); } diff --git a/dev/External/ifvisible.js b/dev/External/ifvisible.js index 2c94ea859..a7c3dd984 100644 --- a/dev/External/ifvisible.js +++ b/dev/External/ifvisible.js @@ -1,5 +1,7 @@ (doc => { let visible = "visible", + status = visible, + timer = 0, wakeUp = () => { clearTimeout(timer); if (status !== visible) { @@ -12,8 +14,6 @@ } }, 10000); }, - status = visible, - timer = 0, init = () => { init = ()=>{}; // Safari diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 22da0ba04..e4a82222f 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -49,10 +49,9 @@ import { ComposePopupView } from 'View/Popup/Compose'; import { AdvancedSearchPopupView } from 'View/Popup/AdvancedSearch'; const - canBeMovedHelper = () => MessageStore.hasCheckedOrSelected(), - ifvisible = window.ifvisible; + canBeMovedHelper = () => MessageStore.hasCheckedOrSelected(); -class MessageListMailBoxUserView extends AbstractViewRight { +export class MessageListMailBoxUserView extends AbstractViewRight { constructor() { super('User/MailBox/MessageList', 'MailMessageList'); @@ -211,9 +210,13 @@ class MessageListMailBoxUserView extends AbstractViewRight { this.selector.on('onUpUpOrDownDown', v => this.goToUpUpOrDownDown(v)); - addEventListener('mailbox.message-list.selector.go-down', e => this.selector.goDown(e.detail)); + addEventListener('mailbox.message-list.selector.go-down', + e => this.selector.newSelectPosition('ArrowDown', false, e.detail) + ); - addEventListener('mailbox.message-list.selector.go-up', e => this.selector.goUp(e.detail)); + addEventListener('mailbox.message-list.selector.go-up', + e => this.selector.newSelectPosition('ArrowUp', false, e.detail) + ); addEventListener('mailbox.message.show', e => { const sFolder = e.detail.Folder, sUid = e.detail.Uid; @@ -703,7 +706,7 @@ class MessageListMailBoxUserView extends AbstractViewRight { this.initUploaderForAppend(); this.initShortcuts(); - if (ifvisible && !rl.settings.app('mobile') && Settings.capa(Capa.Prefetch)) { + if (!rl.settings.app('mobile') && Settings.capa(Capa.Prefetch)) { ifvisible.idle(this.prefetchNextTick.bind(this)); } } @@ -854,7 +857,7 @@ class MessageListMailBoxUserView extends AbstractViewRight { } prefetchNextTick() { - if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisible) { + if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisible) { const message = this.messageList.find( item => item && !hasRequestedMessage(item.folder, item.uid) ); @@ -928,5 +931,3 @@ class MessageListMailBoxUserView extends AbstractViewRight { return !!oJua; } } - -export { MessageListMailBoxUserView };