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