UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains middleware and components that are meant to be consumed by the app's host. The middleware and `Frame` component are responsible for facilitating messages posted between the client and host, and used to act on actions sent from the

47 lines (46 loc) 1.87 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var actions_1 = require("@shopify/app-bridge/actions"); var titleBar_1 = require("@shopify/app-bridge/validate/actions/titleBar"); var actions_2 = require("./actions"); exports.defaultTitlebarStore = null; function titleBarReducer(state, action) { if (state === void 0) { state = exports.defaultTitlebarStore; } switch (action.type) { case actions_1.TitleBar.ActionType.UPDATE: { // Need to cast the action to the correct type var castAction = action; if (titleBar_1.validateAction(castAction)) { return state; } var _a = castAction.payload, title = _a.title, buttons = _a.buttons, breadcrumbs = _a.breadcrumbs; return __assign({}, state, { title: title, breadcrumbs: breadcrumbs, buttons: buttons }); } case actions_2.SET_PAGINATION: { // Need to cast the action to the correct type var castAction = action; return __assign({}, state, { pagination: castAction.payload }); } case actions_2.SET_APP_INFO: { var castAction = action; var currentAppInfo = (state && state.appInfo) || {}; return __assign({}, state, { appInfo: __assign({}, currentAppInfo, castAction.payload) }); } default: return state; } } exports.default = titleBarReducer;