Files
Agent-System/web/src/lib/adminUserDirectorySync.ts
T
weichenandCursor ec8a45a5fe fix(web): sync parent user directory after admin account changes
AdminSettingsModal previously left onRefreshUsers as a dead prop, so newly
created users never reached App allUsers/localStorage and Create Project
member candidates stayed stale (UI-01). Wire syncAdminUserDirectories,
surface refresh errors, and document the residual cross-device directory gap.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 11:58:06 +00:00

24 lines
876 B
TypeScript

/**
* 管理员账号变更后,同步父级全局用户目录(App allUsers / localStorage)。
* 若漏接 onRefreshUsers,立项成员候选会看不到新开通账号(UI-01 实战缺陷)。
*/
export type ParentUserDirectoryRefresh = () => void | Promise<void>;
/**
* 先刷新模态内部列表,再强制调用父级 onRefreshUsers。
* onRefreshUsers 缺失或抛错时必须让调用方可见,禁止静默成功。
*/
export async function syncAdminUserDirectories(params: {
reloadLocalUsers: () => Promise<void>;
onRefreshUsers?: ParentUserDirectoryRefresh;
}): Promise<void> {
await params.reloadLocalUsers();
if (!params.onRefreshUsers) {
throw new Error(
'onRefreshUsers 未绑定:全局用户目录不会更新,立项成员候选可能缺少新开通账号',
);
}
await Promise.resolve(params.onRefreshUsers());
}