Forráskód Böngészése

refactor(editor): drop duplicate grant sync left by the branch merge

Merging the sync-selected-grant work onto the original #11276 branch left two
grant syncs in SavePageControls: the extracted useSyncSelectedGrantWithCurrentPage
hook and the original inline applyCurrentPageGrantToSelectedGrant effect. Remove
the inline copy (and its now-unused imports) so a single hook owns the sync.

Refs #11272

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Yuki Takei 3 napja
szülő
commit
3016be8a3b

+ 0 - 30
apps/app/src/client/components/PageEditor/EditorNavbarBottom/SavePageControls.tsx

@@ -17,10 +17,8 @@ import {
   UncontrolledButtonDropdown,
 } from 'reactstrap';
 
-import { UserGroupPageGrantStatus } from '~/interfaces/page';
 import {
   useCurrentPageData,
-  useCurrentPageId,
   useCurrentPagePath,
   useIsEditable,
 } from '~/states/page';
@@ -38,7 +36,6 @@ import {
   useWaitingSaveProcessing,
 } from '~/states/ui/editor';
 import { useSWRxSlackChannels } from '~/stores/editor';
-import { useSWRxCurrentGrantData } from '~/stores/page';
 import loggerFactory from '~/utils/logger';
 
 import { NotAvailable } from '../../NotAvailable';
@@ -238,33 +235,6 @@ export const SavePageControls = (): JSX.Element | null => {
     }
   }, [editorMode, setIsSlackEnabled, slackChannelsDataString]);
 
-  // Initialize selectedGrantAtom from the current page's grant data.
-  // This must be done at SavePageControls level (always mounted) rather than
-  // inside GrantSelector, which on mobile is rendered only within a closed Modal
-  // and therefore never mounts — leaving selectedGrantAtom at its GRANT_PUBLIC default.
-  const currentPageId = useCurrentPageId();
-  const { data: grantData } = useSWRxCurrentGrantData(currentPageId);
-  const [, setSelectedGrant] = useSelectedGrant();
-
-  const applyCurrentPageGrantToSelectedGrant = useCallback(() => {
-    const currentPageGrant = grantData?.grantData.currentPageGrant;
-    if (currentPageGrant == null) return;
-
-    const userRelatedGrantedGroups =
-      currentPageGrant.groupGrantData?.userRelatedGroups
-        .filter((group) => group.status === UserGroupPageGrantStatus.isGranted)
-        ?.map((group) => ({ item: group.id, type: group.type })) ?? [];
-
-    setSelectedGrant({
-      grant: currentPageGrant.grant,
-      userRelatedGrantedGroups,
-    });
-  }, [grantData?.grantData.currentPageGrant, setSelectedGrant]);
-
-  useEffect(() => {
-    applyCurrentPageGrantToSelectedGrant();
-  }, [applyCurrentPageGrantToSelectedGrant]);
-
   const slackChannelsChangedHandler = useCallback((slackChannels: string) => {
     setSlackChannels(slackChannels);
   }, []);