forked from Ivasoft/mattermost-mobile
* Ensure post options always have the bindings for its channel * Mimic webapp model * Address feedback * Add return to validate bindings * Address feedback * Use empty bindings constant to avoid rerenderings Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {fetchAppBindings, fetchThreadAppBindings} from '@mm-redux/actions/apps';
|
|
import {getThreadAppsBindingsChannelId} from '@mm-redux/selectors/entities/apps';
|
|
import {getCurrentChannelId} from '@mm-redux/selectors/entities/common';
|
|
import {getCurrentUserId} from '@mm-redux/selectors/entities/users';
|
|
import {ActionResult, DispatchFunc, GetStateFunc} from '@mm-redux/types/actions';
|
|
import {appsEnabled} from '@utils/apps';
|
|
|
|
export function handleRefreshAppsBindings() {
|
|
return (dispatch: DispatchFunc, getState: GetStateFunc): ActionResult => {
|
|
const state = getState();
|
|
if (!appsEnabled(state)) {
|
|
return {data: true};
|
|
}
|
|
|
|
dispatch(fetchAppBindings(getCurrentUserId(state), getCurrentChannelId(state)));
|
|
|
|
const threadChannelID = getThreadAppsBindingsChannelId(state);
|
|
if (threadChannelID) {
|
|
dispatch(fetchThreadAppBindings(getCurrentUserId(state), threadChannelID));
|
|
}
|
|
|
|
return {data: true};
|
|
};
|
|
}
|