mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
fix(tabs): fix tab activation issue
This commit is contained in:
@@ -79,21 +79,27 @@ export const TabService = signalStore(
|
||||
},
|
||||
activateTab(id: number) {
|
||||
const tab = store.entityMap()[id];
|
||||
patchState(store, { activatedTabId: id });
|
||||
|
||||
if (!tab) {
|
||||
store._logger.warn('Cannot activate non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn('Cannot activate non-existent tab', () => ({
|
||||
tabId: id,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
const changes: Partial<Tab> = { activatedAt: Date.now() };
|
||||
patchState(store, updateEntity({ id, changes }));
|
||||
patchState(store, { activatedTabId: id });
|
||||
|
||||
store._logger.debug('Tab activated', () => ({ tabId: id }));
|
||||
},
|
||||
patchTab(id: number, changes: z.infer<typeof PatchTabSchema>) {
|
||||
const currentTab = store.entityMap()[id];
|
||||
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot patch non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn('Cannot patch non-existent tab', () => ({
|
||||
tabId: id,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +122,10 @@ export const TabService = signalStore(
|
||||
const currentTab = store.entityMap()[id];
|
||||
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot patch metadata for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn(
|
||||
'Cannot patch metadata for non-existent tab',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +153,10 @@ export const TabService = signalStore(
|
||||
const parsed: TabLocation = TabLocationSchema.parse(location);
|
||||
const currentTab = store.entityMap()[id];
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot navigate to location for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn(
|
||||
'Cannot navigate to location for non-existent tab',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -229,7 +241,9 @@ export const TabService = signalStore(
|
||||
navigateBack(id: number) {
|
||||
const currentTab = store.entityMap()[id];
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot navigate back for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn('Cannot navigate back for non-existent tab', () => ({
|
||||
tabId: id,
|
||||
}));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -243,7 +257,10 @@ export const TabService = signalStore(
|
||||
);
|
||||
|
||||
if (validatedCurrent <= 0) {
|
||||
store._logger.debug('Cannot navigate back - at beginning of history', () => ({ tabId: id }));
|
||||
store._logger.debug(
|
||||
'Cannot navigate back - at beginning of history',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -269,7 +286,10 @@ export const TabService = signalStore(
|
||||
navigateForward(id: number) {
|
||||
const currentTab = store.entityMap()[id];
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot navigate forward for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn(
|
||||
'Cannot navigate forward for non-existent tab',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -283,7 +303,10 @@ export const TabService = signalStore(
|
||||
);
|
||||
|
||||
if (validatedCurrent >= currentLocation.locations.length - 1) {
|
||||
store._logger.debug('Cannot navigate forward - at end of history', () => ({ tabId: id }));
|
||||
store._logger.debug(
|
||||
'Cannot navigate forward - at end of history',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -309,7 +332,10 @@ export const TabService = signalStore(
|
||||
clearLocationHistory(id: number) {
|
||||
const currentTab = store.entityMap()[id];
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot clear location history for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn(
|
||||
'Cannot clear location history for non-existent tab',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,11 +378,14 @@ export const TabService = signalStore(
|
||||
);
|
||||
|
||||
if (wasInvalid && store._config.enableIndexValidation) {
|
||||
store._logger.warn('Invalid location index corrected in getCurrentLocation', () => ({
|
||||
tabId: id,
|
||||
invalidIndex: currentLocation.current,
|
||||
correctedIndex: validatedCurrent,
|
||||
}));
|
||||
store._logger.warn(
|
||||
'Invalid location index corrected in getCurrentLocation',
|
||||
() => ({
|
||||
tabId: id,
|
||||
invalidIndex: currentLocation.current,
|
||||
correctedIndex: validatedCurrent,
|
||||
}),
|
||||
);
|
||||
|
||||
// Correct the invalid index in store (SIDE EFFECT)
|
||||
const changes: Partial<Tab> = {
|
||||
@@ -380,7 +409,10 @@ export const TabService = signalStore(
|
||||
updateCurrentLocation(id: number, updates: Partial<TabLocation>) {
|
||||
const currentTab = store.entityMap()[id];
|
||||
if (!currentTab) {
|
||||
store._logger.warn('Cannot update current location for non-existent tab', () => ({ tabId: id }));
|
||||
store._logger.warn(
|
||||
'Cannot update current location for non-existent tab',
|
||||
() => ({ tabId: id }),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -389,11 +421,14 @@ export const TabService = signalStore(
|
||||
currentLocation.current < 0 ||
|
||||
currentLocation.current >= currentLocation.locations.length
|
||||
) {
|
||||
store._logger.warn('Cannot update current location - invalid index', () => ({
|
||||
tabId: id,
|
||||
currentIndex: currentLocation.current,
|
||||
historyLength: currentLocation.locations.length,
|
||||
}));
|
||||
store._logger.warn(
|
||||
'Cannot update current location - invalid index',
|
||||
() => ({
|
||||
tabId: id,
|
||||
currentIndex: currentLocation.current,
|
||||
historyLength: currentLocation.locations.length,
|
||||
}),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user