Check for notifications, notification overlays are always displayed

@return {$.Promise} jQuery Promise object that is resolved or rejected after the notification check is complete.
968143
function checkForNotification(versionInfoUrl) {
        var result = new $.Deferred();

        _getNotificationInformation(versionInfoUrl)
            .done(function (notificationInfo) {
                // Get all available notifications
                var notifications = notificationInfo.notifications;
                if (notifications && notifications.length > 0) {
                    // Iterate through notifications and act only on the most recent
                    // applicable notification
                    notifications.every(function(notificationObj) {
                        // Only show the notification overlay if the user hasn't been
                        // alerted of this notification
                        if (_checkNotificationValidity(notificationObj)) {
                            if (notificationObj.silent) {
                                // silent notifications, to gather user validity based on filters
                                HealthLogger.sendAnalyticsData("notification", notificationObj.sequence, "handled");
                            } else {
                                showNotification(notificationObj);
                            }
                            // Break, we have acted on one notification already
                            return false;
                        }
                        // Continue, we haven't yet got a notification to act on
                        return true;
                    });
                }
                result.resolve();
            })
            .fail(function () {
                // Error fetching the update data. If this is a forced check, alert the user
                result.reject();
            });

        return result.promise();
    }
326675
def get_notification(self, notification_id, **params):
        """"""
        response = self._get('v2', 'notifications', notification_id, params=params)
        return self._make_api_object(response, Notification)
1269908
function (result) {
    // update status
    me.resolved = true;
    me.rejected = false;
    me.pending = false;

    _onSuccess.forEach(function (fn) {
      fn(result);
    });

    _process = function (onSuccess, onFail) {
      onSuccess(result);
    };

    _resolve = _reject = function () { };

    return me;
  }
87492
public ApiResponse<Void> notificationsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = notificationsValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }
543222
function Notification (payload) {
  this.encoding = "utf8";
  this.payload = {};
  this.compiled = false;

  this.aps = {};
  this.expiry = 0;
  this.priority = 10;

  if (payload) {
    for(let key in payload) {
      if (payload.hasOwnProperty(key)) {
        this[key] = payload[key];
      }
    }
  }
}
1311602
function (options) {
                var self = this;
                options = self.getOptions(options);
                var existing = $('.' + NOTIFICATIONS_CONTAINER_CLASS + ' > div');
                if (existing) {
                    var diff = existing.length - options.maxNotifications;
                    if (diff >= 0) {
                        for (var i = 0, _i = diff + 1; i < _i; i++) {
                            this.closeNotification(existing[i], -1);
                        }
                    }
                }

                this.buildNotification(options);
            }
174663
function checkSourceInfo () {
  return new Promise((resolve, reject) => {
    let ok = pjson.name === oldInfo.packageName
    ok = ok && readSync('android/app/src/main/AndroidManifest.xml').includes(`package="${oldInfo.packageID}"`)

    if (!ok) {
      reject(new Error('The App name is already modified.'))
      return
    }

    console.log()
    console.log('---------------------------------------------------------')
    console.log('New project parameters:')
    console.log('---------------------------------------------------------')
    console.log('App display name :', newInfo.appName)
    console.log('Project name     :', newInfo.projectName)
    console.log('Package name     :', newInfo.packageName)
    console.log('Package id       :', newInfo.packageID)
    console.log('---------------------------------------------------------')

    let r = null
    try {
      r = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
      })
      r.question('Is this correct?', (answer) => {
        r.close()
        resolve(answer)
      })
    } catch (e) {
      if (r) {
        r.close()
      }
      reject(e)
    }
  })
}
759699
async function showRationaleDialog(title: string, message: string): Promise<*> {
  let done;
  const result = new Promise(resolve => {
    done = resolve;
  });

  Alert.alert(
    title,
    message,
    [
      {
        text: 'OK',
        onPress: () => done()
      }
    ],
    { cancelable: false }
  );

  return result;
}
40554
def _handle_notification(self, method, params):
        """"""
        if method == CANCEL_METHOD:
            self._handle_cancel_notification(params['id'])
            return

        try:
            handler = self._dispatcher[method]
        except KeyError:
            log.warn("Ignoring notification for unknown method %s", method)
            return

        try:
            handler_result = handler(params)
        except Exception:  # pylint: disable=broad-except
            log.exception("Failed to handle notification %s: %s", method, params)
            return

        if callable(handler_result):
            log.debug("Executing async notification handler %s", handler_result)
            notification_future = self._executor_service.submit(handler_result)
            notification_future.add_done_callback(self._notification_callback(method, params))
977000
function(){
		var me = this,
			dispatchArguments = arguments,
			promises = []
		;

		this._promises = [];

		// A closure is needed for the callback id
		Object.keys( this._callbacks ).forEach( function( id ){

			// All the promises must be set in me._promises before trying to resolve
			// in order to make waitFor work ok
			me._promises[ id ] = me._Promise.resolve()
				.then( function(){
					return me._callbacks[ id ].apply( me, dispatchArguments );
				})
				.catch( function( err ){
					console.error( err.stack || err );
				})
			;

			promises.push( me._promises[ id ] );
		});

		//
		var dequeue = function(){
			me._dispatchQueue.shift();
			if( !me._dispatchQueue.length )
				me._currentDispatch = false;
		};

		return this._Promise.all( promises )
			.then( dequeue, dequeue )
		;
	}
676609
function promiseTry(callback) {
  try {
    const maybePromise = callback();

    if (isPromise(maybePromise)) {
      return maybePromise;
    } else {
      return Promise.resolve(maybePromise);
    }
  } catch (err) {
    return Promise.reject(err);
  }
}
867482
public void afterCompletion(int status) {
        for (DeferredEventNotification<?> notification : notifications) {
            if (!notification.isBefore() && notification.getStatus().matches(status)) {
                notification.run();
            }
        }
    }
1043599
def _notification_callback(method, params):
        """"""
        def callback(future):
            try:
                future.result()
                log.debug("Successfully handled async notification %s %s", method, params)
            except Exception:  # pylint: disable=broad-except
                log.exception("Failed to handle async notification %s %s", method, params)
        return callback
1312486
function promise(p) {
        var me = this;

        var canHandlePromise =
            this.children.indexOf("completed") >= 0 &&
            this.children.indexOf("failed") >= 0;

        if (!canHandlePromise){
            throw new Error("Publisher must have \"completed\" and \"failed\" child publishers");
        }

        p.then(function(response) {
            return me.completed(response);
        }, function(error) {
            return me.failed(error);
        });
    }
469273
function resolve(promise) {
    var method = promise.state === FULFILLED ? 'onFulfilled' : 'onRejected';
    var arg = method === 'onFulfilled' ? promise.value : promise.reason;
    var handler, value;

    nextTick(function() {
      var isPromise;

      while (promise.handlers[0]) {
        handler = promise.handlers.shift();

        try {
          value = handler[method](arg);

          // Handle "thenables" as well as Promises
          isPromise = value instanceof Promise || value && isFunc(value.then);

          if (isPromise) {
            value.then(function(value) { fulfill(handler.promise, value); },
                       function(reason) { reject(handler.promise, reason); });
          } else {
            fulfill(handler.promise, value);
          }
        } catch(err) {
          reject(handler.promise, err);
        }
      }
    });

    return promise;
  }
319294
@Override
    public void notificationCreated(RuntimeUpdateManager updateManager, RuntimeUpdateNotification notification) {

        // CONFIG_UPDATES_DELIVERED notification actually indicates that a config update is starting. The update
        // won't be complete until the future we get from the notification is complete.
        if (RuntimeUpdateNotification.CONFIG_UPDATES_DELIVERED.equals(notification.getName())) {

            configFuture = notification.getFuture();
            _futureMonitor.onCompletion(notification.getFuture(), new CompletionListener<Boolean>() {
                @Override
                public void successfulCompletion(Future<Boolean> future, Boolean result) {
                    // We're done with the update. Set the configFuture to null, and submit a dummy task
                    // so that performAction knows it can kick off the executor.
                    configFuture = null;
                    submit();
                }

                @Override
                public void failedCompletion(Future<Boolean> future, Throwable t) {
                    // The update failed, but we still want to process any queued actions. Set the
                    // configFuture to null, and submit a dummy task so that performAction knows
                    // it can kick off the executor.
                    configFuture = null;
                    submit();
                }

                // Submit a dummy job so that performAction() will kick off the executor for the actions queue
                private void submit() {
                    synchronized (actionQueue) {
                        performAction(new Runnable() {

                            @Override
                            public void run() {
                                return;
                            }
                        });
                    }
                }
            });
        }

    }
357196
function notifyHandler(data) {
        const notification = Notification.parse(data);
        return evalBlacklist(notification)
            .then(() => {
                forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
    
                const ids = {
                    post: notification.postId,
                    topic: notification.topicId,
                    user: notification.userId,
                    pm: -1,
                    chat: -1
                };
                return notification.getText()
                    .then((postData) => forum.Commands.get(ids,
                        postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content)))
                    .then((commands) => {
                        if (commands.commands.length === 0) {
                            debug(`Emitting events: 'notification' and 'notification:${notification.type}'`);
                            forum.emit(`notification:${notification.type}`, notification);
                            forum.emit('notification', notification);
                        }
                        return commands;
                    })
                    .then((commands) => commands.execute());
            }).catch((err) => {
                if (err === 'Ignoring notification') {
                //We do not process the notification, but we can continue with life
                    return Promise.resolve();
                }
                throw err;
            });
    }