Merge pull request #770 from epw/master
Add support for dismissing Gadgetbridge notifications through notifymaster
commit
4a01fa1c6c
|
|
@ -1,4 +1,7 @@
|
||||||
(() => {
|
(() => {
|
||||||
|
// Current shown notification, saved for dismissing.
|
||||||
|
var currentNot = null;
|
||||||
|
|
||||||
// Music handling
|
// Music handling
|
||||||
const state = {
|
const state = {
|
||||||
music: "stop",
|
music: "stop",
|
||||||
|
|
@ -151,15 +154,18 @@
|
||||||
global.GB = (event) => {
|
global.GB = (event) => {
|
||||||
switch (event.t) {
|
switch (event.t) {
|
||||||
case "notify":
|
case "notify":
|
||||||
case "notify-":
|
currentNot = prettifyNotificationEvent(event);
|
||||||
if (event.t === "notify") {
|
require("notify").show(currentNot);
|
||||||
require("notify").show(prettifyNotificationEvent(event));
|
|
||||||
if (!(require('Storage').readJSON('setting.json',1)||{}).quiet) {
|
if (!(require('Storage').readJSON('setting.json',1)||{}).quiet) {
|
||||||
Bangle.buzz();
|
Bangle.buzz();
|
||||||
}
|
}
|
||||||
} else { // notify-
|
break;
|
||||||
|
case "notify-":
|
||||||
|
currentNot.t = "notify";
|
||||||
|
currentNot.n = "DISMISS";
|
||||||
|
gbSend(currentNot);
|
||||||
|
currentNot = null;
|
||||||
require("notify").hide(event);
|
require("notify").hide(event);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "musicinfo":
|
case "musicinfo":
|
||||||
state.musicInfo = event;
|
state.musicInfo = event;
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ exports.show = function(options) {
|
||||||
if (pos > -size) setTimeout(anim, 15);
|
if (pos > -size) setTimeout(anim, 15);
|
||||||
}
|
}
|
||||||
anim();
|
anim();
|
||||||
Bangle.on("touch", exports.hide);
|
Bangle.on("touch", exports.dismiss_and_hide);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -162,3 +162,20 @@ exports.hide = function(options) {
|
||||||
}
|
}
|
||||||
anim();
|
anim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Calls exports.hide(), but if Gadgetbridge is installed, dismiss through it
|
||||||
|
instead (which will call call exports.hide() itself).
|
||||||
|
*/
|
||||||
|
exports.dismiss_and_hide = function(options) {
|
||||||
|
options = options||{};
|
||||||
|
if (typeof(options) == "number") {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
if ("GB" in global) {
|
||||||
|
options["t"] = "notify-";
|
||||||
|
GB(options);
|
||||||
|
} else {
|
||||||
|
exports.hide(options);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue