"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lastAction = exports.NULL_ACTION = void 0;
// A reducer to remember the last dispatched action. This is primarily used by layout
// templates to listen on certain actions and be able to update their panel states
//
// As suggested by the creator of redux:
// https://github.com/reactjs/redux/issues/580
var type_guards_1 = require("../utils/type-guards");
var actions_1 = require("../constants/actions");
exports.NULL_ACTION = {};
function lastAction(state, action) {
    if (state === void 0) { state = null; }
    if ((0, type_guards_1.isAction)(action)) {
        switch (action.type) {
            case actions_1.ActionType.MAP_SET_BUSY_COUNT:
            case actions_1.ActionType.TASK_INVOKE_URL:
            case actions_1.ActionType.MAP_SET_SELECTION:
            case actions_1.ActionType.MAP_ADD_CLIENT_SELECTED_FEATURE:
            case actions_1.ActionType.MAP_SET_MAPTIP:
            case actions_1.ActionType.MAP_SET_ACTIVE_TOOL:
                return action;
        }
    }
    //As we're returning a const reference subsequent dispatched actions that
    //are not the ones listed above should give us the same branch in the eyes
    //of redux
    return exports.NULL_ACTION;
}
exports.lastAction = lastAction;
//# sourceMappingURL=last-action.js.map