* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {Client4} from '@mm-redux/client';
|
|
import {FileTypes} from '@mm-redux/action_types';
|
|
|
|
import {Action, batchActions, DispatchFunc, GetStateFunc, ActionFunc} from '@mm-redux/types/actions';
|
|
|
|
import {logError} from './errors';
|
|
import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
|
|
import {FileUploadResponse} from '@mm-redux/types/files';
|
|
|
|
export function getFilesForPost(postId: string): ActionFunc {
|
|
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
|
let files;
|
|
|
|
try {
|
|
files = await Client4.getFileInfosForPost(postId);
|
|
} catch (error) {
|
|
forceLogoutIfNecessary(error, dispatch, getState);
|
|
dispatch(logError(error));
|
|
return {error};
|
|
}
|
|
|
|
dispatch({
|
|
type: FileTypes.RECEIVED_FILES_FOR_POST,
|
|
data: files,
|
|
postId,
|
|
});
|
|
|
|
return {data: true};
|
|
};
|
|
}
|
|
|
|
export function getFilePublicLink(fileId: string): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.getFilePublicLink,
|
|
onSuccess: FileTypes.RECEIVED_FILE_PUBLIC_LINK,
|
|
params: [
|
|
fileId,
|
|
],
|
|
});
|
|
}
|