From dcdbc0719586349af618bacd0cfe23ccfe2a5c87 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 3 Jul 2023 07:51:59 +0200 Subject: [PATCH] fix: delete actions for admins on communities --- ts/models/conversation.ts | 5 +++++ ts/node/migration/sessionMigrations.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 0b58d801d..5c4a66b43 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -343,6 +343,11 @@ export class ConversationModel extends Backbone.Model { // those are values coming only from both the DB or the wrapper. Currently we display the data from the DB if (this.isClosedGroup()) { toRet.members = this.get('members') || []; + } + + // those are values coming only from both the DB or the wrapper. Currently we display the data from the DB + if (this.isClosedGroup() || this.isPublic()) { + // for public, this value always comes from the DB toRet.groupAdmins = this.getGroupAdmins(); } diff --git a/ts/node/migration/sessionMigrations.ts b/ts/node/migration/sessionMigrations.ts index 9c25bf3f4..382cf9c18 100644 --- a/ts/node/migration/sessionMigrations.ts +++ b/ts/node/migration/sessionMigrations.ts @@ -1887,7 +1887,16 @@ export async function updateSessionSchema(db: BetterSqlite3.Database) { for (let index = 0, max = LOKI_SCHEMA_VERSIONS.length; index < max; index += 1) { const runSchemaUpdate = LOKI_SCHEMA_VERSIONS[index]; runSchemaUpdate(lokiSchemaVersion, db); - if (index > lokiSchemaVersion) { + if (index > lokiSchemaVersion && index - lokiSchemaVersion <= 3) { + /** When running migrations, we block the node process. + * This causes the app to be in a Not responding state when we have a lot of data. + * To avoid this, we add a `sleep` between the run of the last 3 migrations. + * This "only for the last 3 migrations" serves 2 purposes: + * - we don't wait for `200ms * total number of migrations` when starting from schemaVersion 0 + * - we do have some time between the last 3 migrations, at most. + * + * This means that this sleepFor will only sleep for at most 600ms, even if we need to run 30 migrations. + */ await sleepFor(200); // give some time for the UI to not freeze between 2 migrations } }