Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Persist pinned message open-ness between room switches #1935

Merged
merged 2 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -182,6 +183,7 @@ module.exports = React.createClass({
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
forwardingEvent: RoomViewStore.getForwardingEvent(),
shouldPeek: RoomViewStore.shouldPeek(),
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", RoomViewStore.getRoomId()),
editingRoomSettings: RoomViewStore.isEditingSettings(),
};

Expand Down Expand Up @@ -1136,7 +1138,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() {
Expand Down
4 changes: 4 additions & 0 deletions src/settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,8 @@ export const SETTINGS = {
displayName: _td('Enable widget screenshots on supported widgets'),
default: false,
},
"PinnedEvents.isOpen": {
supportedLevels: ['room-device'],
default: false,
},
};