* Add linter rules for import order and type member delimiters * Remove unneeded group * Group all app/* imports before the internal imports * Move app/ imports before parent imports * Separate @node_modules imports into a different group * Substitute app paths by aliases * Fix @node_modules import order and add test related modules * Add aliases for types and test, and group import types
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {Client4} from '@client/rest';
|
|
import {FileTypes} from '@mm-redux/action_types';
|
|
import {DispatchFunc, GetStateFunc, ActionFunc} from '@mm-redux/types/actions';
|
|
|
|
import {logError} from './errors';
|
|
import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
|
|
|
|
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,
|
|
],
|
|
});
|
|
}
|