Account for cases where the Pebble global is undefined

This commit is contained in:
Keegan
2016-02-27 08:51:54 +11:00
parent 1cd4590691
commit aa30ef7d7a
3 changed files with 26 additions and 8 deletions
+6 -2
View File
@@ -29,7 +29,11 @@ function Clay(config, customFn, options) {
self.config = config;
self.customFn = customFn || function() {};
self.components = {};
self.meta = {};
self.meta = {
activeWatchInfo: null,
accountToken: '',
watchToken: ''
};
// Let Clay handle all the magic
if (options.autoHandleEvents !== false && typeof Pebble !== 'undefined') {
@@ -63,7 +67,7 @@ function Clay(config, customFn, options) {
* @return {void}
*/
function _populateMeta() {
self.meta = !Pebble ? {} : {
self.meta = {
activeWatchInfo: Pebble.getActiveWatchInfo && Pebble.getActiveWatchInfo(),
accountToken: Pebble.getAccountToken(),
watchToken: Pebble.getWatchToken()