Update styles for MediaGallery

This commit is contained in:
Fedor Indutny
2025-09-10 13:25:21 -07:00
committed by GitHub
parent 11e612f57b
commit 53d1650844
41 changed files with 999 additions and 920 deletions

View File

@@ -0,0 +1,43 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { WritableDB } from '../Interface';
export default function updateToSchemaVersion1450(db: WritableDB): void {
db.exec(`
ALTER TABLE message_attachments
ADD COLUMN messageType TEXT;
ALTER TABLE message_attachments
ADD COLUMN receivedAt INTEGER;
ALTER TABLE message_attachments
ADD COLUMN receivedAtMs INTEGER;
ALTER TABLE message_attachments
ADD COLUMN isViewOnce INTEGER;
`);
// Backfill
db.exec(`
UPDATE message_attachments
SET
messageType = messages.type,
receivedAt = messages.received_at,
receivedAtMs = messages.received_at_ms,
isViewOnce = messages.isViewOnce
FROM (
SELECT id, type, received_at, received_at_ms, isViewOnce
FROM messages
) AS messages
WHERE
message_attachments.messageId IS messages.id
`);
// Index
db.exec(`
CREATE INDEX message_attachments_getOlderMedia ON message_attachments
(conversationId, attachmentType, receivedAt DESC, sentAt DESC)
WHERE
editHistoryIndex IS -1 AND
messageType IN ('incoming', 'outgoing') AND
isViewOnce IS NOT 1
`);
}

View File

@@ -120,6 +120,7 @@ import updateToSchemaVersion1410 from './1410-remove-wallpaper';
import updateToSchemaVersion1420 from './1420-backup-downloads';
import updateToSchemaVersion1430 from './1430-call-links-epoch-id';
import updateToSchemaVersion1440 from './1440-chat-folders';
import updateToSchemaVersion1450 from './1450-all-media';
import { DataWriter } from '../Server';
@@ -1595,6 +1596,7 @@ export const SCHEMA_VERSIONS: ReadonlyArray<SchemaUpdateType> = [
{ version: 1420, update: updateToSchemaVersion1420 },
{ version: 1430, update: updateToSchemaVersion1430 },
{ version: 1440, update: updateToSchemaVersion1440 },
{ version: 1450, update: updateToSchemaVersion1450 },
];
export class DBVersionFromFutureError extends Error {