Disallow conversation model creation during import

This commit is contained in:
Fedor Indutny 2025-01-27 12:16:50 -08:00 committed by GitHub
parent 65055fd475
commit 3b78c9885a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 8 deletions

View file

@ -150,6 +150,7 @@ export function start(): void {
export class ConversationController {
#_initialFetchComplete = false;
#isReadOnly = false;
private _initialPromise: undefined | Promise<void>;
@ -291,6 +292,10 @@ export class ConversationController {
return conversation;
}
if (this.#isReadOnly) {
throw new Error('ConversationController is read-only');
}
const id = generateUuid();
if (type === 'group') {
@ -1299,6 +1304,16 @@ export class ConversationController {
);
}
setReadOnly(value: boolean): void {
if (this.#isReadOnly === value) {
log.warn(`ConversationController: already at readOnly=${value}`);
return;
}
log.info(`ConversationController: readOnly=${value}`);
this.#isReadOnly = value;
}
reset(): void {
delete this._initialPromise;
this.#_initialFetchComplete = false;