Commit 63c99d3e by Sebastián Katzer

Allow prio as an alias for priority and allow priority to take a string like "high" instead of 1

parent b4631b8f
......@@ -587,18 +587,6 @@ exports._convertProperties = function (options) {
options.badge = parseToInt('badge', options);
}
if (options.priority) {
options.priority = parseToInt('priority', options);
}
if (options.foreground === true) {
options.priority = Math.max(options.priority, 1);
}
if (options.foreground === false) {
options.priority = Math.min(options.priority, 0);
}
if (options.defaults) {
options.defaults = parseToInt('defaults', options);
}
......@@ -617,6 +605,7 @@ exports._convertProperties = function (options) {
options.data = JSON.stringify(options.data);
this._convertPriority(options);
this._convertTrigger(options);
this._convertActions(options);
this._convertProgressBar(options);
......@@ -625,6 +614,33 @@ exports._convertProperties = function (options) {
};
/**
* Convert the passed values for the priority to their required type.
*
* @param [ Map ] options Set of custom values.
*
* @return [ Map ] Interaction object with trigger spec.
*/
exports._convertPriority = function (options) {
var prio = options.priority || options.prio || 0;
if (typeof prio === 'string') {
prio = { min: -2, low: -1, high: 1, max: 2 }[prio] || 0;
}
if (options.foreground === true) {
prio = Math.max(prio, 1);
}
if (options.foreground === false) {
prio = Math.min(prio, 0);
}
options.priority = prio;
return options;
};
/**
* Convert the passed values to their required type, modifying them
* directly for Android and passing the converted list back for iOS.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment