PromucFlow_constructor/app/client/src/selectors/appCollabSelectors.tsx
Sangeeth Sivan e9d719103c
chore: code split sagas and reducer's index file (#16261)
* chore: code split sagas and reducers index file

* fix: update imports

* chore: remove acl reducers file on ce

* fix: code split reducers properly

* chore: remove unnecessary import

* chore: split root sagas file
2022-08-24 17:46:32 +05:30

40 lines
1.3 KiB
TypeScript

import { createSelector } from "reselect";
import { AppState } from "@appsmith/reducers";
import { AppCollabReducerState } from "reducers/uiReducers/appCollabReducer";
import { getCurrentUser, selectFeatureFlags } from "./usersSelectors";
import { User } from "entities/AppCollab/CollabInterfaces";
import { ANONYMOUS_USERNAME } from "constants/userConstants";
export const getAppCollabState = (state: AppState) => state.ui.appCollab;
export const getRealtimeAppEditors = createSelector(
getAppCollabState,
getCurrentUser,
(appCollab: AppCollabReducerState, currentUser) =>
appCollab.editors.filter((el) => el.email !== currentUser?.email),
);
export const isMultiplayerEnabledForUser = createSelector(
selectFeatureFlags,
(featureFlags) => featureFlags.MULTIPLAYER,
);
export const getConcurrentPageEditors = (state: AppState) =>
state.ui.appCollab.pageEditors;
export const isConcurrentPageEditorToastVisible = createSelector(
getConcurrentPageEditors,
getCurrentUser,
(pageEditors: User[], currentUser?: User) => {
if (
pageEditors.length === 0 ||
!currentUser ||
currentUser.email === ANONYMOUS_USERNAME
)
return;
return pageEditors.some(
(editor: User) => editor.email !== currentUser?.email,
);
},
);