mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-17 08:58:21 +00:00
Adds the durable storage foundation for synchronized drafts (mobile-only, no network behavior yet): - Fix draft batch dedup in handleDraft to key by the composite (channel_id, root_id) instead of channel_id alone, so a channel draft and its thread reply drafts in the same batch no longer collapse. - Add Draft columns: server_update_at (nullable ancestry hint, not a revision), props (JSON), file_ids (JSON portable server attachment IDs). - Add the DraftOutbox table (one durable pending op per draft key) with operation/status const objects, generation, keep_local, retry fields, and a deleted_fingerprint column for delete-vs-newer-write disambiguation. - Add buildDraftOutboxId, the serialized mutateDraftAndOutbox writer primitive (enters database.write before querying both tables, commits one batch), and deterministic repairDuplicateDrafts. - Bump server schema 20 -> 21 with addColumns + createTable migration; register schema/model in the database managers, mocks, types, and docs. Tests: composite-key survival, concurrent-mutation serialization, batch failure atomicity, duplicate repair winner, model round-trip / migration compatibility, and migration definition. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
export const DRAFT_TYPE_DRAFT = 'draft' as const;
|
|
export const DRAFT_TYPE_SCHEDULED = 'scheduled' as const;
|
|
|
|
export type DraftType = typeof DRAFT_TYPE_DRAFT | typeof DRAFT_TYPE_SCHEDULED;
|
|
|
|
export const DRAFT_SCHEDULED_POST_LAYOUT_PADDING = 40;
|
|
|
|
export const DRAFT_SCREEN_TAB_DRAFTS = 'drafts' as const;
|
|
export const DRAFT_SCREEN_TAB_SCHEDULED_POSTS = 'scheduled_posts' as const;
|
|
export type DraftScreenTab = typeof DRAFT_SCREEN_TAB_DRAFTS | typeof DRAFT_SCREEN_TAB_SCHEDULED_POSTS;
|
|
|
|
// DraftOutbox durable operation queued for a draft key.
|
|
export const DraftOutboxOperation = {
|
|
Upsert: 'upsert',
|
|
Delete: 'delete',
|
|
} as const;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
export type DraftOutboxOperation = typeof DraftOutboxOperation[keyof typeof DraftOutboxOperation];
|
|
|
|
// DraftOutbox status for the currently queued operation of a draft key.
|
|
export const DraftOutboxStatus = {
|
|
Pending: 'pending',
|
|
WaitingForUpload: 'waiting_for_upload',
|
|
BlockedUpload: 'blocked_upload',
|
|
ConfirmingDelete: 'confirming_delete',
|
|
Blocked: 'blocked',
|
|
} as const;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
export type DraftOutboxStatus = typeof DraftOutboxStatus[keyof typeof DraftOutboxStatus];
|