* fix: handle NSMutableData * feat: integrate react-native-network-client * fix: typos * fix: semicolon * fix: rename to urlVersion * fix: add returnDataOnly arg * fix: configure network client * fix: headers * fix: handling of serverVersion * fix: rename requests to actions * fix: action imports * fix: no need to stringify body * fix: sso flow * fix: address PR feedback * fix: invalidate client on logout * fix: address PR feedback take 2 * fix: address PR feedback take 3 * fix: tsc issues * fix: get csrf token during client creation * fix: linter * fix: invalidate client onLogout * fix: event emitter * fix: unit tests * fix: apply linter fixes * fix lint * Modify actions to add / update database values * Rename clien4.d.ts to client.d.ts * fix empty & missing translations * cleanup api client * Cleanup init & squash some TODO's * Emit certificate errors in NetworkManager * cleanup user actions * Fix NetworkManager invalidate client * Invalidate client when server screen appears * Update kotlin to 1.4.30 required by network-client * patch react-native-keychain to remove cached credential * update react-native-network-client * Use app.db instead of default.db in native code * fix use of rnnc on Android * Init PushNotifications * No need to reset serverVersion on logout * fix logout action * fix deleteServerDatabase * fix schedule expired session notification * use safeParseJSON for db json fields * unsubscribe when database component unmounts * cleanup init * session type * pass launchprops to entire login flow * Properly remove third party cookies after SSO login * recreate network client if sso with redirect fails * add missing launch props from server screen * use query prefix for database queries * Add temporary logout function to channel screen Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
import {field, json} from '@nozbe/watermelondb/decorators';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
import {safeParseJSON} from '@utils/helpers';
|
|
|
|
const {CHANNEL, DRAFT, POST} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* The Draft model represents the draft state of messages in Direct/Group messages and in channels
|
|
*/
|
|
export default class Draft extends Model {
|
|
/** table (name) : Draft */
|
|
static table = DRAFT;
|
|
|
|
/** associations : Describes every relationship to this table. */
|
|
static associations: Associations = {
|
|
|
|
/** A DRAFT can belong to only one CHANNEL */
|
|
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
|
|
|
/** A DRAFT is associated to only one POST */
|
|
[POST]: {type: 'belongs_to', key: 'root_id'},
|
|
};
|
|
|
|
/** channel_id : The foreign key pointing to the channel in which the draft was made */
|
|
@field('channel_id') channelId!: string;
|
|
|
|
/** message : The draft message */
|
|
@field('message') message!: string;
|
|
|
|
/** root_id : The root_id will be empty most of the time unless the draft relates to a draft reply of a thread */
|
|
@field('root_id') rootId!: string;
|
|
|
|
/** files : The files field will hold an array of file objects that have not yet been uploaded and persisted within the FILE table */
|
|
@json('files', safeParseJSON) files!: FileInfo[];
|
|
}
|