mattermost-mobile/app/actions/local/file.ts
Avinash Lingaloo 39cfb297a3
MM-39711 - Gekidou Advanced Settings (#6412)
* fix display clock

* implemented help functionality

* skelton for adv settings

* added rightComponent to menuItem

* added advanced settings

* adv settings delete

* Update en.json

* clean up

* Update index.tsx

* fix for camera-roll on android > 30

* undo delete camera-roll images

* Update app/screens/settings/index.tsx

Co-authored-by: Daniel Espino García <larkox@gmail.com>

* refactoring

* removed menu item

* refactored imports and getAllFilesInCachesDirectory transferred into util/files

* corrections after review

* ts fix

Co-authored-by: Daniel Espino García <larkox@gmail.com>
2022-07-08 14:39:41 +04:00

36 lines
1.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import DatabaseManager from '@database/manager';
import {getFileById} from '@queries/servers/file';
import {logError} from '@utils/log';
export const updateLocalFile = async (serverUrl: string, file: FileInfo) => {
try {
const {operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl);
return operator.handleFiles({files: [file], prepareRecordsOnly: false});
} catch (error) {
logError('Failed updateLocalFile', error);
return {error};
}
};
export const updateLocalFilePath = async (serverUrl: string, fileId: string, localPath: string) => {
try {
const {database} = DatabaseManager.getServerDatabaseAndOperator(serverUrl);
const file = await getFileById(database, fileId);
if (file) {
await database.write(async () => {
await file.update((r) => {
r.localPath = localPath;
});
});
}
return {error: undefined};
} catch (error) {
logError('Failed updateLocalFilePath', error);
return {error};
}
};