Move persisting of last viewed into SpaceStore
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
67dcb3a448
commit
2dcb60b489
2 changed files with 9 additions and 9 deletions
|
@ -79,7 +79,7 @@ import { CommunityPrototypeStore } from "../../stores/CommunityPrototypeStore";
|
||||||
import DialPadModal from "../views/voip/DialPadModal";
|
import DialPadModal from "../views/voip/DialPadModal";
|
||||||
import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast';
|
import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast';
|
||||||
import { shouldUseLoginForWelcome } from "../../utils/pages";
|
import { shouldUseLoginForWelcome } from "../../utils/pages";
|
||||||
import SpaceStore, {LAST_VIEWED_ROOMS, LAST_VIEWED_ROOMS_HOME} from "../../stores/SpaceStore";
|
import SpaceStore from "../../stores/SpaceStore";
|
||||||
import SpaceRoomDirectory from "./SpaceRoomDirectory";
|
import SpaceRoomDirectory from "./SpaceRoomDirectory";
|
||||||
import {replaceableComponent} from "../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../utils/replaceableComponent";
|
||||||
import RoomListStore from "../../stores/room-list/RoomListStore";
|
import RoomListStore from "../../stores/room-list/RoomListStore";
|
||||||
|
@ -875,14 +875,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
private viewRoom(roomInfo: IRoomInfo) {
|
private viewRoom(roomInfo: IRoomInfo) {
|
||||||
this.focusComposer = true;
|
this.focusComposer = true;
|
||||||
|
|
||||||
// persist last viewed room from a space
|
|
||||||
const activeSpace = SpaceStore.instance.activeSpace;
|
|
||||||
const activeSpaceId = activeSpace?.roomId || LAST_VIEWED_ROOMS_HOME;
|
|
||||||
const lastViewedRooms = JSON.parse(window.localStorage.getItem(LAST_VIEWED_ROOMS)) || {};
|
|
||||||
|
|
||||||
lastViewedRooms[activeSpaceId] = roomInfo.room_id;
|
|
||||||
window.localStorage.setItem(LAST_VIEWED_ROOMS, JSON.stringify(lastViewedRooms));
|
|
||||||
|
|
||||||
if (roomInfo.room_alias) {
|
if (roomInfo.room_alias) {
|
||||||
console.log(
|
console.log(
|
||||||
`Switching to room alias ${roomInfo.room_alias} at event ` +
|
`Switching to room alias ${roomInfo.room_alias} at event ` +
|
||||||
|
|
|
@ -490,6 +490,14 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
if (!SettingsStore.getValue("feature_spaces")) return;
|
if (!SettingsStore.getValue("feature_spaces")) return;
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case "view_room": {
|
case "view_room": {
|
||||||
|
// persist last viewed room from a space
|
||||||
|
const activeSpace = SpaceStore.instance.activeSpace;
|
||||||
|
const activeSpaceId = activeSpace?.roomId || LAST_VIEWED_ROOMS_HOME;
|
||||||
|
const lastViewedRooms = JSON.parse(window.localStorage.getItem(LAST_VIEWED_ROOMS)) || {};
|
||||||
|
|
||||||
|
lastViewedRooms[activeSpaceId] = payload.room_id;
|
||||||
|
window.localStorage.setItem(LAST_VIEWED_ROOMS, JSON.stringify(lastViewedRooms));
|
||||||
|
|
||||||
const room = this.matrixClient?.getRoom(payload.room_id);
|
const room = this.matrixClient?.getRoom(payload.room_id);
|
||||||
|
|
||||||
if (room?.getMyMembership() === "join") {
|
if (room?.getMyMembership() === "join") {
|
||||||
|
|
Loading…
Reference in a new issue