32 lines
925 B
JavaScript
32 lines
925 B
JavaScript
(function (root, factory) {
|
|
const api = factory();
|
|
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
else root.mobileAppShortcuts = api;
|
|
})(typeof self !== 'undefined' ? self : this, function () {
|
|
const ACTIONS = new Set(['continue', 'new', 'agenda']);
|
|
|
|
function parse(search) {
|
|
const action = new URLSearchParams(search || '').get('launch');
|
|
return ACTIONS.has(action) ? action : null;
|
|
}
|
|
|
|
function createController(options) {
|
|
const launchAction = parse(options.search);
|
|
let handled = false;
|
|
|
|
function action() { return launchAction; }
|
|
|
|
function run() {
|
|
if (!launchAction || handled) return null;
|
|
handled = true;
|
|
if (launchAction === 'continue') return options.continueWork();
|
|
if (launchAction === 'new') return options.newIssue();
|
|
return options.agenda();
|
|
}
|
|
|
|
return {action, run};
|
|
}
|
|
|
|
return {parse, createController};
|
|
});
|