This commit fixes an issue where the check state of categories was lost when toggling between card and tree views. This is solved by immediately emitting node state changes for all nodes. This ensures consistent view transitions without any loss of node state information. Furthermore, this commit includes added unit tests for the modified code sections.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { IEventSubscription } from '@/infrastructure/Events/IEventSource';
|
|
import { IEventSubscriptionCollection } from '@/infrastructure/Events/IEventSubscriptionCollection';
|
|
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
|
|
|
export class EventSubscriptionCollectionStub
|
|
extends StubWithObservableMethodCalls<IEventSubscriptionCollection>
|
|
implements IEventSubscriptionCollection {
|
|
private readonly subscriptions = new Array<IEventSubscription>();
|
|
|
|
public get mostRecentSubscription(): IEventSubscription | undefined {
|
|
if (this.subscriptions.length === 0) {
|
|
return undefined;
|
|
}
|
|
return this.subscriptions[this.subscriptions.length - 1];
|
|
}
|
|
|
|
public get subscriptionCount(): number {
|
|
return this.subscriptions.length;
|
|
}
|
|
|
|
public register(
|
|
subscriptions: IEventSubscription[],
|
|
): void {
|
|
this.registerMethodCall({
|
|
methodName: 'register',
|
|
args: [subscriptions],
|
|
});
|
|
this.subscriptions.push(...subscriptions);
|
|
}
|
|
|
|
public unsubscribeAll(): void {
|
|
this.registerMethodCall({
|
|
methodName: 'unsubscribeAll',
|
|
args: [],
|
|
});
|
|
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
this.subscriptions.length = 0;
|
|
}
|
|
|
|
public unsubscribeAllAndRegister(
|
|
subscriptions: IEventSubscription[],
|
|
): void {
|
|
this.registerMethodCall({
|
|
methodName: 'unsubscribeAllAndRegister',
|
|
args: [subscriptions],
|
|
});
|
|
// Not calling other methods to avoid registering method calls.
|
|
this.subscriptions.splice(0, this.subscriptions.length, ...subscriptions);
|
|
}
|
|
}
|