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

Commit 5cdc8fb

Browse files
authored
Fix reading of cached room device setting values (#8491)
* Fix reading of cached room device setting values * Add tests
1 parent 3c36a7f commit 5cdc8fb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/settings/handlers/RoomDeviceSettingsHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class RoomDeviceSettingsHandler extends AbstractLocalStorageSetti
6969
}
7070

7171
private read(key: string): any {
72-
return this.getItem(key);
72+
return this.getObject(key);
7373
}
7474

7575
private getKey(settingName: string, roomId: string): string {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import RoomDeviceSettingsHandler from "../../../src/settings/handlers/RoomDeviceSettingsHandler";
18+
import { WatchManager } from "../../../src/settings/WatchManager";
19+
20+
describe("RoomDeviceSettingsHandler", () => {
21+
it("should correctly read cached values", () => {
22+
const watchers = new WatchManager();
23+
const handler = new RoomDeviceSettingsHandler(watchers);
24+
25+
const settingName = "RightPanel.phases";
26+
const roomId = "!room:server";
27+
const value = {
28+
isOpen: true,
29+
history: [{}],
30+
};
31+
32+
handler.setValue(settingName, roomId, value);
33+
expect(handler.getValue(settingName, roomId)).toEqual(value);
34+
});
35+
});

0 commit comments

Comments
 (0)