* Viewing Files in Edit mode in mobile with ability to delete and save * Added upload attachment to keyboard tracker view * using state instread of use ref * Minor * Added tests * intl extract * new function getFiles ById, batch file deletion and tests * Files fetching in edit options and tests * Removed DeviceEventEmitter and used React context * Added support to check minimum required version to show edit file attachments * resolve forward ref issue * Minor * memotized props for context and observe config with value * Import fixes * Ability to show quick action and add files to edit post * type safety for EditPostContext * Reverted back the post priority props * constant shift * Added test for QuickAction to show slashcomand * Added test for edit_post, upload_item and upload_remove * Added test for Edit_post_input and edit_post index * fix the height issue between attachment and keyboard due to safeArea * Minor: removed debugging border color * Addressed dev review comments * Import fixes * Address UX comments * Fixed props for UploadItem and remove effective Edit mode * handled save button disabled state when uploading attachments * handled newly added and retry file removal without alert message * Test updated * Added test for input_quick_action index.tsx * Added test for not in edit mode for upload_item index * Added test for upload_remove component when not in edit mode * added tests for file_upload_error hook * Added test for calling callback when in edit mode * Test for edit post input for server version check
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
|
|
import {of as of$} from 'rxjs';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {DEFAULT_SERVER_MAX_FILE_SIZE, MAX_MESSAGE_LENGTH_FALLBACK} from '@constants/post_draft';
|
|
import {observeFilesForPost} from '@queries/servers/file';
|
|
import {observeCanUploadFiles} from '@queries/servers/security';
|
|
import {observeConfigIntValue, observeMaxFileCount} from '@queries/servers/system';
|
|
|
|
import EditPost from './edit_post';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
import type PostModel from '@typings/database/models/servers/post';
|
|
|
|
const enhance = withObservables([], ({database, post}: WithDatabaseArgs & { post: PostModel}) => {
|
|
const maxPostSize = observeConfigIntValue(database, 'MaxPostSize', MAX_MESSAGE_LENGTH_FALLBACK);
|
|
const canUploadFiles = observeCanUploadFiles(database);
|
|
const maxFileSize = observeConfigIntValue(database, 'MaxFileSize', DEFAULT_SERVER_MAX_FILE_SIZE);
|
|
const maxFileCount = observeMaxFileCount(database);
|
|
|
|
const hasFilesAttached = observeFilesForPost(database, post.id).pipe(switchMap((files) => of$(files?.length > 0)));
|
|
|
|
return {
|
|
maxPostSize,
|
|
hasFilesAttached,
|
|
canUploadFiles,
|
|
maxFileSize,
|
|
maxFileCount,
|
|
};
|
|
});
|
|
|
|
export default withDatabase(enhance(EditPost));
|