cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [5/6] cordova-plugins git commit: passing the Cordova Notification object in success callback close is linked with remove in native side
Date Fri, 09 Dec 2016 00:59:42 GMT
passing the Cordova Notification object in success callback
close is linked with remove in native side

I "feel" native side should simply pass create and close functions instead of updating the
object


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/4d622971
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/4d622971
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/4d622971

Branch: refs/heads/master
Commit: 4d6229712b1536769e921b46521b1cd97a712be6
Parents: a1b5356
Author: Piotr Zalewa <piotr@zalewa.info>
Authored: Thu Dec 18 09:27:53 2014 +0100
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Dec 8 17:02:11 2016 -0800

----------------------------------------------------------------------
 notification/src/firefoxos/notification.js | 12 +++++++-----
 notification/www/notification.js           | 12 ++++++++----
 2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/4d622971/notification/src/firefoxos/notification.js
----------------------------------------------------------------------
diff --git a/notification/src/firefoxos/notification.js b/notification/src/firefoxos/notification.js
index a88f118..3236008 100644
--- a/notification/src/firefoxos/notification.js
+++ b/notification/src/firefoxos/notification.js
@@ -31,8 +31,8 @@ function makeNotification(successCB, errorCB, options) {
     delete options.notificationId;
     delete options.title;
 
-    var n = new mozNotification(title, options);
-    mozNotifications[nId] = n;
+    var notification = new mozNotification(title, options);
+    mozNotifications[nId] = notification;
     successCB();
 }
 
@@ -55,16 +55,18 @@ function create(successCB, errorCB, options) {
     });
 }
 
-function close(successCB, errorCB, params) {
+function remove(successCB, errorCB, params) {
     var nId = params.notificationId;
     mozNotifications[nId].close();
-    successCB();
+    if (successCB) {
+        successCB();
+    }
 }
 
 
 module.exports = {
     create: create,
-    close: close
+    remove: remove
 };    
     
 require("cordova/firefoxos/commandProxy").add("CNotification", module.exports);

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/4d622971/notification/www/notification.js
----------------------------------------------------------------------
diff --git a/notification/www/notification.js b/notification/www/notification.js
index e8ae096..13247a6 100644
--- a/notification/www/notification.js
+++ b/notification/www/notification.js
@@ -43,15 +43,19 @@ Emitter.methods = ["addEventListener", "dispatchEvent", "removeEventListener"];
 
 function CNotification(title, options, successCB, errorCB) {
     // add emitter methods to Notification
+    var self = this;
+    function success() {
+        successCB(self);
+    }
     Emitter.call(this);
     this.title = options.title = title;
     this.notificationId = options.notificationId = nId++;
-    exec(successCB, errorCB, "CNotification", "create", options);
+    exec(success, errorCB, "CNotification", "create", options);
 }
 
-CNotification.close = function(fields, successCB, errorCB, options) {
-    options.notificationId = this.notificationId;
-    exec(successCB, errorCB, "CNotification", "close", [fields, options]);
+CNotification.prototype.close = function(successCB, errorCB) {
+    var options = {notificationId: this.notificationId};
+    exec(successCB, errorCB, "CNotification", "remove", options);
 };
 
 module.exports = CNotification;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message