Co-authored-by: Daniel Espino García <larkox@gmail.com> Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com> Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
16 lines
650 B
TypeScript
16 lines
650 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {GlobalState} from '@mm-redux/types/store';
|
|
import {AppBinding} from '@mm-redux/types/apps';
|
|
|
|
export function getAppsBindings(state: GlobalState, location?: string): AppBinding[] {
|
|
if (!state.entities.apps.bindings) {
|
|
return [];
|
|
}
|
|
|
|
if (location) {
|
|
const bindings = state.entities.apps.bindings.filter((b) => b.location === location);
|
|
return bindings.reduce((accum: AppBinding[], current: AppBinding) => accum.concat(current.bindings || []), []);
|
|
}
|
|
return state.entities.apps.bindings;
|
|
}
|