Page MenuHomePhabricator

D11925.diff
No OneTemporary

D11925.diff

diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js
--- a/lib/selectors/thread-selectors.js
+++ b/lib/selectors/thread-selectors.js
@@ -31,7 +31,6 @@
threadInBackgroundChatList,
threadInFilterList,
threadInfoFromRawThreadInfo,
- threadHasPermission,
threadInChatList,
threadHasAdminRole,
roleIsAdminRole,
@@ -47,7 +46,6 @@
RawThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import type { BaseAppState } from '../types/redux-types.js';
-import { threadPermissions } from '../types/thread-permission-types.js';
import {
threadTypes,
threadTypeIsCommunityRoot,
@@ -124,16 +122,6 @@
},
);
-const onScreenEntryEditableThreadInfos: (
- state: BaseAppState<>,
-) => $ReadOnlyArray<ThreadInfo> = createSelector(
- onScreenThreadInfos,
- (threadInfos: $ReadOnlyArray<ThreadInfo>): $ReadOnlyArray<ThreadInfo> =>
- threadInfos.filter(threadInfo =>
- threadHasPermission(threadInfo, threadPermissions.EDIT_ENTRIES),
- ),
-);
-
const entryInfoSelector: (state: BaseAppState<>) => {
+[id: string]: EntryInfo,
} = createObjectSelector(
@@ -568,7 +556,6 @@
threadInfoSelector,
communityThreadSelector,
onScreenThreadInfos,
- onScreenEntryEditableThreadInfos,
entryInfoSelector,
currentDaysToEntries,
childThreadInfos,
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -51,6 +51,7 @@
threadInfoSelector,
pendingToRealizedThreadIDsSelector,
threadInfosSelectorForThreadType,
+ onScreenThreadInfos,
} from '../selectors/thread-selectors.js';
import {
getRelativeMemberInfos,
@@ -1922,6 +1923,15 @@
);
}
+function useOnScreenEntryEditableThreadInfos(): $ReadOnlyArray<ThreadInfo> {
+ const visibleThreadInfos = useSelector(onScreenThreadInfos);
+ const editableVisibleThreadInfos = useThreadsWithPermission(
+ visibleThreadInfos,
+ threadPermissions.EDIT_ENTRIES,
+ );
+ return editableVisibleThreadInfos;
+}
+
export {
threadHasPermission,
useThreadHasPermission,
@@ -1992,4 +2002,5 @@
getThreadsToDeleteText,
useUserProfileThreadInfo,
assertAllThreadInfosAreLegacy,
+ useOnScreenEntryEditableThreadInfos,
};
diff --git a/native/calendar/thread-picker-modal.react.js b/native/calendar/thread-picker-modal.react.js
--- a/native/calendar/thread-picker-modal.react.js
+++ b/native/calendar/thread-picker-modal.react.js
@@ -9,7 +9,7 @@
createLocalEntryActionType,
} from 'lib/actions/entry-actions.js';
import { useGlobalThreadSearchIndex } from 'lib/selectors/nav-selectors.js';
-import { onScreenEntryEditableThreadInfos } from 'lib/selectors/thread-selectors.js';
+import { useOnScreenEntryEditableThreadInfos } from 'lib/shared/thread-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import Modal from '../components/modal.react.js';
@@ -72,9 +72,7 @@
);
const index = useGlobalThreadSearchIndex();
- const onScreenThreadInfos = useSelector(state =>
- onScreenEntryEditableThreadInfos(state),
- );
+ const onScreenThreadInfos = useOnScreenEntryEditableThreadInfos();
return (
<Modal>
<ThreadList
diff --git a/web/modals/threads/thread-picker-modal.react.js b/web/modals/threads/thread-picker-modal.react.js
--- a/web/modals/threads/thread-picker-modal.react.js
+++ b/web/modals/threads/thread-picker-modal.react.js
@@ -4,7 +4,7 @@
import * as React from 'react';
import { useGlobalThreadSearchIndex } from 'lib/selectors/nav-selectors.js';
-import { onScreenEntryEditableThreadInfos } from 'lib/selectors/thread-selectors.js';
+import { useOnScreenEntryEditableThreadInfos } from 'lib/shared/thread-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js';
@@ -12,7 +12,6 @@
import ThreadAvatar from '../../avatars/thread-avatar.react.js';
import Button from '../../components/button.react.js';
import Search from '../../components/search.react.js';
-import { useSelector } from '../../redux/redux-utils.js';
import Modal, { type ModalOverridableProps } from '../modal.react.js';
type OptionProps = {
@@ -52,7 +51,7 @@
function ThreadPickerModal(props: Props): React.Node {
const { createNewEntry, ...modalProps } = props;
- const onScreenThreadInfos = useSelector(onScreenEntryEditableThreadInfos);
+ const onScreenThreadInfos = useOnScreenEntryEditableThreadInfos();
const searchIndex = useGlobalThreadSearchIndex();
invariant(

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 8:31 AM (19 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2429777
Default Alt Text
D11925.diff (4 KB)

Event Timeline