Files
mattermost-mobile/app/queries/servers/drafts.ts
Kyriakos Z ab4f65020a [MM-49540] Message Priority Phase 3 (#7142)
* Init

* i18 and types

* Acknowledge button, api

* Ack button + display ackd users

* Saves priority on draft and addresses some comments

* Addresses review comments round 2

* Moves fetching userprofiles upon opening ACKs

* Adds metadata column in drafts table

+ Addresses some more review comments.

* Small refactor according to review comments

* Addresses some review comments

* Addresses some review comments

* Uses local action when ACKing

* Fixes first time selecting priority and other

* Updates snapshots

* Fixes i18n

* Fixes ts errors

---------

Co-authored-by: Anurag Shivarathri <anurag6713@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-04-27 11:22:03 +00:00

33 lines
967 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Database, Q} from '@nozbe/watermelondb';
import {of as of$} from 'rxjs';
import {MM_TABLES} from '@constants/database';
import type DraftModel from '@typings/database/models/servers/draft';
const {SERVER: {DRAFT}} = MM_TABLES;
export const getDraft = async (database: Database, channelId: string, rootId = '') => {
const record = await queryDraft(database, channelId, rootId).fetch();
// Check done to force types
if (record.length) {
return record[0];
}
return undefined;
};
export const queryDraft = (database: Database, channelId: string, rootId = '') => {
return database.collections.get<DraftModel>(DRAFT).query(
Q.where('channel_id', channelId),
Q.where('root_id', rootId),
);
};
export function observeFirstDraft(v: DraftModel[]) {
return v[0]?.observe() || of$(undefined);
}