fix: сохранил pinned sessions после reload (#943)
This commit is contained in:
@@ -275,6 +275,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
||||
const sync = useSync();
|
||||
const liveSessions = useAllLiveSessions();
|
||||
const liveSessionStatuses = useAllSessionStatuses();
|
||||
const hasLoadedGlobalSessions = useGlobalSessionsStore((state) => state.hasLoaded);
|
||||
const globalActiveSessions = useGlobalSessionsStore((state) => state.activeSessions);
|
||||
const archivedSessions = useGlobalSessionsStore((state) => state.archivedSessions);
|
||||
const currentSessionId = useSessionUIStore((state) => state.currentSessionId);
|
||||
@@ -476,6 +477,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
||||
|
||||
const { scheduleCollapsedProjectsPersist } = useSidebarPersistence({
|
||||
isVSCode,
|
||||
hasLoadedGlobalSessions,
|
||||
safeStorage,
|
||||
keys: {
|
||||
sessionExpanded: SESSION_EXPANDED_STORAGE_KEY,
|
||||
|
||||
@@ -19,6 +19,7 @@ type Keys = {
|
||||
|
||||
type Args = {
|
||||
isVSCode: boolean;
|
||||
hasLoadedGlobalSessions: boolean;
|
||||
safeStorage: SafeStorageLike;
|
||||
keys: Keys;
|
||||
sessions: Session[];
|
||||
@@ -34,6 +35,7 @@ type Args = {
|
||||
export const useSidebarPersistence = (args: Args) => {
|
||||
const {
|
||||
isVSCode,
|
||||
hasLoadedGlobalSessions,
|
||||
safeStorage,
|
||||
keys,
|
||||
sessions,
|
||||
@@ -114,6 +116,10 @@ export const useSidebarPersistence = (args: Args) => {
|
||||
}, [keys.projectCollapse, keys.sessionExpanded, safeStorage, setCollapsedProjects, setExpandedParents]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!hasLoadedGlobalSessions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingSessionIds = new Set(sessions.map((session) => session.id));
|
||||
setPinnedSessionIds((prev) => {
|
||||
let changed = false;
|
||||
@@ -127,7 +133,7 @@ export const useSidebarPersistence = (args: Args) => {
|
||||
});
|
||||
return changed ? next : prev;
|
||||
});
|
||||
}, [sessions, setPinnedSessionIds]);
|
||||
}, [hasLoadedGlobalSessions, sessions, setPinnedSessionIds]);
|
||||
|
||||
React.useEffect(() => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user