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 = createSelector( - onScreenThreadInfos, - (threadInfos: $ReadOnlyArray): $ReadOnlyArray => - 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, @@ -1932,6 +1933,15 @@ ); } +function useOnScreenEntryEditableThreadInfos(): $ReadOnlyArray { + const visibleThreadInfos = useSelector(onScreenThreadInfos); + const editableVisibleThreadInfos = useThreadsWithPermission( + visibleThreadInfos, + threadPermissions.EDIT_ENTRIES, + ); + return editableVisibleThreadInfos; +} + export { threadHasPermission, useThreadHasPermission, @@ -2002,4 +2012,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 (