Add support for replying to messages to messagegui

master
Brian Whelan 2024-07-15 22:57:29 +01:00 committed by GitHub
parent d5a995a7f8
commit b0ffab457d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -106,3 +106,4 @@
0.77: Messages can now use international fonts if they are installed
0.78: Fix: When user taps on a new message, clear the unread timeout
0.79: Fix: Reset the unread timeout each time a new message is shown. When the message is read from user input, do not set an unread timeout.
0.80: Add ability to reply to messages if a reply library is installed and the message can be replied to

View File

@ -24,6 +24,7 @@ require("messages").pushMessage({"t":"add","id":"call","src":"Phone","title":"Bo
var Layout = require("Layout");
var layout; // global var containing the layout for the currently displayed message
var settings = require('Storage').readJSON("messages.settings.json", true) || {};
var reply = require("reply");
var fontSmall = "6x8";
var fontMedium = g.getFonts().includes("6x15")?"6x15":"6x8:2";
var fontBig = g.getFonts().includes("12x20")?"12x20":"6x8:2";
@ -45,6 +46,7 @@ if (Graphics.prototype.setFontIntl) {
var active; // active screen (undefined/"list"/"music"/"map"/"message"/"scroller"/"settings")
var openMusic = false; // go back to music screen after we handle something else?
var replying = false; // If we're replying to a message, don't interrupt
// hack for 2v10 firmware's lack of ':size' font handling
try {
g.setFont("6x8:2");
@ -267,11 +269,27 @@ function showMessageSettings(msg) {
/*LANG*/"View Message" : () => {
showMessageScroller(msg);
},
/*LANG*/"Reply": () => {
replying = true;
reply.reply({msg: msg})
.then(result => {
Bluetooth.println(JSON.stringify(result));
replying = false;
showMessage(msg.id);
})
.catch(() => {
replying = false;
showMessage(msg.id);
});
},
/*LANG*/"Delete" : () => {
MESSAGES = MESSAGES.filter(m=>m.id!=msg.id);
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0});
},
};
if (!msg.reply || !reply) delete menu[/*LANG*/"Reply"];
if (Bangle.messageIgnore && msg.src)
menu[/*LANG*/"Ignore"] = () => {
E.showPrompt(/*LANG*/"Ignore all messages from "+E.toJS(msg.src)+"?", {title:/*LANG*/"Ignore"}).then(isYes => {