* 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
30 lines
924 B
TypeScript
30 lines
924 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
|
|
import {from as from$} from 'rxjs';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {observeFilesForPost} from '@queries/servers/file';
|
|
import {filesLocalPathValidation} from '@utils/file';
|
|
|
|
import EditOption from './edit_option';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
import type PostModel from '@typings/database/models/servers/post';
|
|
|
|
type Props = WithDatabaseArgs & {
|
|
post: PostModel;
|
|
}
|
|
|
|
const enhance = withObservables(['post'], ({post, database}: Props) => {
|
|
const files = observeFilesForPost(database, post.id).pipe(
|
|
switchMap((fs) => from$(filesLocalPathValidation(fs, post.userId))),
|
|
);
|
|
|
|
return {
|
|
files,
|
|
};
|
|
});
|
|
|
|
export default withDatabase(enhance(EditOption));
|