fix(settings): build bulk lock drafts only from a readable lock store

The Xtream and M3U management dialogs offer lock toggles, and the
Stalker lock dialog opens, only once the lock store has been read. A
draft built from the empty fail-closed snapshot would otherwise replace
the real locks with nothing on Save if storage recovered in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 5.5 committed 2026-09-27 15:44:41 +02:00
1 parent ceb0653415
commit ed48e7fd2b
7 files changed
+94 -5

No files matched your search

@@ -967,6 +967,9 @@ describe('WorkspaceContextPanelComponent', () => {
value: signal(true),
});
jest.spyOn(parentalLock, 'requestUnlock').mockResolvedValue(true);
jest.spyOn(parentalLock, 'ensureLocksReadable').mockResolvedValue(
true
);
}
it('opens with the categories snapshotted before the lazy import', async () => {
@@ -1027,6 +1030,28 @@ describe('WorkspaceContextPanelComponent', () => {
expect(dialog.open).not.toHaveBeenCalled();
});
it('opens nothing while the lock store cannot be read', async () => {
enableLock();
jest.spyOn(
TestBed.inject(ParentalLockService),
'ensureLocksReadable'
).mockResolvedValue(false);
fixture.componentRef.setInput('context', {
provider: 'stalker',
playlistId: 'stalker-1',
});
fixture.componentRef.setInput('section', 'itv');
fixture.detectChanges();
const component = fixture.componentInstance;
component.loadStalkerLockDialog = jest.fn(
async () => class DialogStub {}
);
await component.openManageStalkerCategories();
expect(dialog.open).not.toHaveBeenCalled();
});
it('opens nothing when the route changed during the lazy import', async () => {
enableLock();
fixture.componentRef.setInput('context', {
@@ -548,6 +548,11 @@ export class WorkspaceContextPanelComponent {
if (!contentType || !(await this.parentalLock.requestUnlock())) {
return;
}
// The dialog's draft is the lock store's list: built from the empty
// fail-closed snapshot it would erase the real locks on Save.
if (!unchanged() || !(await this.parentalLock.ensureLocksReadable())) {
return;
}
if (!unchanged()) {
return;
}