u
This commit is contained in:
@@ -452,6 +452,11 @@ const actions = {
|
||||
refreshCategoryViewChildren(nextCategories);
|
||||
},
|
||||
|
||||
/** Invalidate all loaded category views. */
|
||||
invalidateAllCategoryViews() {
|
||||
invalidateAllCategoryViews();
|
||||
},
|
||||
|
||||
/** Reset state to idle (logout / company switch). */
|
||||
reset() {
|
||||
disposeAllCategoryViewAutomats();
|
||||
@@ -479,9 +484,9 @@ categoryAutomat.views = categoryViews;
|
||||
|
||||
// Load tree whenever the company data changes (or first becomes available)
|
||||
let _lastCompanyId = null;
|
||||
companyAutomat.subscribe((company) => {
|
||||
const id = company.current?.id ?? null;
|
||||
const rootCategoryId = company.current?.rootCategoryId ?? null;
|
||||
function syncCategoryWithCompany(company) {
|
||||
const id = company?.current?.id ?? null;
|
||||
const rootCategoryId = company?.current?.rootCategoryId ?? null;
|
||||
if (id && rootCategoryId && id !== _lastCompanyId) {
|
||||
const isCompanySwitch = _lastCompanyId !== null;
|
||||
_lastCompanyId = id;
|
||||
@@ -494,7 +499,10 @@ companyAutomat.subscribe((company) => {
|
||||
_lastCompanyId = null;
|
||||
categoryAutomat.actions.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
companyAutomat.subscribe(syncCategoryWithCompany);
|
||||
syncCategoryWithCompany(companyAutomat.state);
|
||||
|
||||
// Reset tree on logout
|
||||
authAutomat.subscribe((auth) => {
|
||||
|
||||
Reference in New Issue
Block a user