From 832123524d27bbf8c641f9bd3e99964b2be764c0 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 17 Sep 2019 17:34:30 +0100 Subject: [PATCH 1/3] make the lifetimes of the RM configurable --- src/components/structures/TimelinePanel.js | 12 +++++--- .../tabs/user/PreferencesUserSettingsTab.js | 29 ++++++++++++++++++- src/i18n/strings/en_EN.json | 4 ++- src/settings/Settings.js | 8 +++++ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 0ca1cb9996..faa6f2564a 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -42,8 +42,6 @@ import EditorStateTransfer from '../../utils/EditorStateTransfer'; const PAGINATE_SIZE = 20; const INITIAL_SIZE = 20; -const READ_MARKER_INVIEW_THRESHOLD_MS = 1 * 1000; -const READ_MARKER_OUTOFVIEW_THRESHOLD_MS = 30 * 1000; const READ_RECEIPT_INTERVAL_MS = 500; const DEBUG = false; @@ -191,6 +189,12 @@ const TimelinePanel = createReactClass({ // always show timestamps on event tiles? alwaysShowTimestamps: SettingsStore.getValue("alwaysShowTimestamps"), + + // how long to show the RM for when it's visible in the window + readMarkerInViewThresholdMs: SettingsStore.getValue("readMarkerInViewThresholdMs"), + + // how long to show the RM for when it's scrolled off-screen + readMarkerOutOfViewThresholdMs: SettingsStore.getValue("readMarkerOutOfViewThresholdMs"), }; }, @@ -593,8 +597,8 @@ const TimelinePanel = createReactClass({ _readMarkerTimeout(readMarkerPosition) { return readMarkerPosition === 0 ? - READ_MARKER_INVIEW_THRESHOLD_MS : - READ_MARKER_OUTOFVIEW_THRESHOLD_MS; + this.state.readMarkerInViewThresholdMs : + this.state.readMarkerOutOfViewThresholdMs; }, updateReadMarkerOnUserActivity: async function() { diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js index 6507854e59..6528c86f19 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -69,7 +69,12 @@ export default class PreferencesUserSettingsTab extends React.Component { alwaysShowMenuBarSupported: false, minimizeToTray: true, minimizeToTraySupported: false, - autocompleteDelay: SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10), + autocompleteDelay: + SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10), + readMarkerInViewThresholdMs: + SettingsStore.getValueAt(SettingLevel.DEVICE, 'readMarkerInViewThresholdMs').toString(10), + readMarkerOutOfViewThresholdMs: + SettingsStore.getValueAt(SettingLevel.DEVICE, 'readMarkerOutOfViewThresholdMs').toString(10), }; } @@ -124,6 +129,16 @@ export default class PreferencesUserSettingsTab extends React.Component { SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value); }; + _onReadMarkerInViewThresholdMs = (e) => { + this.setState({readMarkerInViewThresholdMs: e.target.value}); + SettingsStore.setValue("readMarkerInViewThresholdMs", null, SettingLevel.DEVICE, e.target.value); + }; + + _onReadMarkerOutOfViewThresholdMs = (e) => { + this.setState({readMarkerOutOfViewThresholdMs: e.target.value}); + SettingsStore.setValue("readMarkerOutOfViewThresholdMs", null, SettingLevel.DEVICE, e.target.value); + }; + _renderGroup(settingIds) { const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag"); return settingIds.map(i => ); @@ -178,6 +193,18 @@ export default class PreferencesUserSettingsTab extends React.Component { type='number' value={this.state.autocompleteDelay} onChange={this._onAutocompleteDelayChange} /> + + ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 32f4569a3a..8100c58658 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1796,5 +1796,7 @@ "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.": "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.", "Failed to set direct chat tag": "Failed to set direct chat tag", "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", - "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room" + "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room", + "Read Marker lifetime (ms)": "Read Marker lifetime (ms)", + "Read Marker off-screen lifetime (ms)": "Read Marker off-screen lifetime (ms)", } diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 7b049208aa..e0ff16c538 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -284,6 +284,14 @@ export const SETTINGS = { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, default: 200, }, + "readMarkerInViewThresholdMs": { + supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, + default: 3000, + }, + "readMarkerOutOfViewThresholdMs": { + supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, + default: 30000, + }, "blacklistUnverifiedDevices": { // We specifically want to have room-device > device so that users may set a device default // with a per-room override. From b2f44237b83c01861a7476c091377b928a9a7bbf Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 17 Sep 2019 17:36:29 +0100 Subject: [PATCH 2/3] dangling comma --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8100c58658..977d516fe4 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1798,5 +1798,5 @@ "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room", "Read Marker lifetime (ms)": "Read Marker lifetime (ms)", - "Read Marker off-screen lifetime (ms)": "Read Marker off-screen lifetime (ms)", + "Read Marker off-screen lifetime (ms)": "Read Marker off-screen lifetime (ms)" } From 90691ada3c52925edf4c51a53e5aad825ce8b65a Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 17 Sep 2019 17:51:03 +0100 Subject: [PATCH 3/3] normalise translations --- src/i18n/strings/en_EN.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 977d516fe4..f55eff0aff 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -636,6 +636,8 @@ "Timeline": "Timeline", "Room list": "Room list", "Autocomplete delay (ms)": "Autocomplete delay (ms)", + "Read Marker lifetime (ms)": "Read Marker lifetime (ms)", + "Read Marker off-screen lifetime (ms)": "Read Marker off-screen lifetime (ms)", "Unignore": "Unignore", "": "", "Import E2E room keys": "Import E2E room keys", @@ -1796,7 +1798,5 @@ "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.": "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.", "Failed to set direct chat tag": "Failed to set direct chat tag", "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", - "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room", - "Read Marker lifetime (ms)": "Read Marker lifetime (ms)", - "Read Marker off-screen lifetime (ms)": "Read Marker off-screen lifetime (ms)" + "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room" }