This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
local_storage.js
44 lines (34 loc) · 1.64 KB
/
local_storage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getCurrentTeamId, getTeamByName} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import localStorageStore from 'stores/local_storage_store';
// getLastViewedChannelName combines data from the Redux store and localStorage to return the
// previously selected channel name, returning the default channel if none exists.
//
// See LocalStorageStore for context.
export const getLastViewedChannelName = (state) => {
const userId = getCurrentUserId(state);
const teamId = getCurrentTeamId(state);
return localStorageStore.getPreviousChannelName(userId, teamId);
};
export const getPenultimateViewedChannelName = (state) => {
const userId = getCurrentUserId(state);
const teamId = getCurrentTeamId(state);
return localStorageStore.getPenultimateChannelName(userId, teamId);
};
// getLastViewedChannelNameByTeamName combines data from the Redux store and localStorage to return
// the url to the previously selected channel, returning the path to the default channel if none
// exists.
//
// See LocalStorageStore for context.
export const getLastViewedChannelNameByTeamName = (state, teamName) => {
const userId = getCurrentUserId(state);
const team = getTeamByName(state, teamName);
const teamId = team && team.id;
return localStorageStore.getPreviousChannelName(userId, teamId);
};
export const getPreviousTeamId = (state) => {
const userId = getCurrentUserId(state);
return localStorageStore.getPreviousTeamId(userId);
};