Skip to content

Commit 4cb1fe7

Browse files
committed
refactor(app-shell): keep the slug answer with the organization it was read for (objectui#11720)
The environment answer is stored with its organization id, so another organization reads as pending again without a synchronous reset inside the effect. Claude-Session: https://claude.ai/code/session_01FngvPpdrnhHMdHHq6vwwju Co-authored-by: Claude <noreply@anthropic.com>
1 parent b5a686b commit 4cb1fe7

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎packages/app-shell/src/console/organizations/manage/SettingsPage.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ export function SettingsPage() {
7878
const [membersLoading, setMembersLoading] = useState(true);
7979

8080
// Slug availability — only an owner sees the form, so only an owner's visit
81-
// asks about the organization's environments.
82-
const [slugAvailability, setSlugAvailability] = useState<SlugAvailability>('pending');
81+
// asks about the organization's environments. The answer is kept WITH the
82+
// organization it was read for, so moving to another organization reads as
83+
// `pending` again without a reset inside the effect.
84+
const [slugAnswer, setSlugAnswer] = useState<{ orgId: string; locked: boolean } | null>(null);
85+
const slugAvailability: SlugAvailability =
86+
slugAnswer?.orgId === org.id ? (slugAnswer.locked ? 'locked' : 'open') : 'pending';
8387
const slugLocked = slugAvailability === 'locked';
8488

8589
// Danger zone dialogs
@@ -120,9 +124,9 @@ export function SettingsPage() {
120124
useEffect(() => {
121125
if (isOwner !== true) return;
122126
let cancelled = false;
123-
setSlugAvailability('pending');
124-
void readOrgEnvironmentPresence(org.id).then((presence) => {
125-
if (!cancelled) setSlugAvailability(presence === 'present' ? 'locked' : 'open');
127+
const orgId = org.id;
128+
void readOrgEnvironmentPresence(orgId).then((presence) => {
129+
if (!cancelled) setSlugAnswer({ orgId, locked: presence === 'present' });
126130
});
127131
return () => {
128132
cancelled = true;

0 commit comments

Comments
 (0)