mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
69 lines (68 loc) • 1.85 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = usage;
const action_types_1 = require("mattermost-redux/action_types");
const emptyUsage = {
files: {
totalStorage: 0,
totalStorageLoaded: false,
},
messages: {
history: 0,
historyLoaded: false,
},
boards: {
cards: 0,
cardsLoaded: false,
},
teams: {
active: 0,
cloudArchived: 0,
teamsLoaded: false,
},
};
// represents the usage associated with this workspace
function usage(state = emptyUsage, action) {
switch (action.type) {
case action_types_1.CloudTypes.RECEIVED_MESSAGES_USAGE: {
return {
...state,
messages: {
history: action.data,
historyLoaded: true,
},
};
}
case action_types_1.CloudTypes.RECEIVED_FILES_USAGE: {
return {
...state,
files: {
totalStorage: action.data,
totalStorageLoaded: true,
},
};
}
case action_types_1.CloudTypes.RECEIVED_BOARDS_USAGE: {
return {
...state,
boards: {
cards: action.data,
cardsLoaded: true,
},
};
}
case action_types_1.CloudTypes.RECEIVED_TEAMS_USAGE: {
return {
...state,
teams: {
...action.data,
teamsLoaded: true,
},
};
}
default:
return state;
}
}