From beaa276ea89d6e843805885cb879fdb5f3a5a158 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sat, 26 May 2018 19:32:23 -0600 Subject: [PATCH] Persist pinned message open-ness between room switches Addresses part of https://github.com/vector-im/riot-web/issues/5405 Signed-off-by: Travis Ralston --- src/components/structures/RoomView.js | 9 +++++++-- src/settings/Settings.js | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index c5f6a75cc5b2..eae621b72293 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -44,7 +44,7 @@ import { KeyCode, isOnlyCtrlOrCmdKeyEvent } from '../../Keyboard'; import RoomViewStore from '../../stores/RoomViewStore'; import RoomScrollStateStore from '../../stores/RoomScrollStateStore'; -import SettingsStore from "../../settings/SettingsStore"; +import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; const DEBUG = false; let debuglog = function() {}; @@ -115,6 +115,7 @@ module.exports = React.createClass({ showApps: false, isAlone: false, isPeeking: false, + showingPinned: false, // error object, as from the matrix client/server API // If we failed to load information about the room, @@ -182,6 +183,7 @@ module.exports = React.createClass({ isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(), forwardingEvent: RoomViewStore.getForwardingEvent(), shouldPeek: RoomViewStore.shouldPeek(), + showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", RoomViewStore.getRoomId()), }; // Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307 @@ -1135,7 +1137,10 @@ module.exports = React.createClass({ }, onPinnedClick: function() { - this.setState({showingPinned: !this.state.showingPinned, searching: false}); + const nowShowingPinned = !this.state.showingPinned; + const roomId = this.state.room.roomId; + this.setState({showingPinned: nowShowingPinned, searching: false}); + SettingsStore.setValue("PinnedEvents.isOpen", roomId, SettingLevel.ROOM_DEVICE, nowShowingPinned); }, onSettingsClick: function() { diff --git a/src/settings/Settings.js b/src/settings/Settings.js index b1bc4161fdba..e5dc005ebdfe 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -29,6 +29,7 @@ const LEVELS_ACCOUNT_SETTINGS = ['device', 'account', 'config']; const LEVELS_FEATURE = ['device', 'config']; const LEVELS_DEVICE_ONLY_SETTINGS = ['device']; const LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG = ['device', 'config']; +const LEVELS_DEVICE_ROOM_SETTINGS = ['room-device', 'device']; export const SETTINGS = { // EXAMPLE SETTING: @@ -274,4 +275,8 @@ export const SETTINGS = { displayName: _td('Enable widget screenshots on supported widgets'), default: false, }, + "PinnedEvents.isOpen": { + supportedLevels: LEVELS_DEVICE_ROOM_SETTINGS, + default: false, + }, };