Disallow conversation model creation during import
This commit is contained in:
parent
65055fd475
commit
3b78c9885a
5 changed files with 60 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue