Skip to content

Commit 17c3d73

Browse files
author
thyttan
committed
Merge remote-tracking branch 'upstream/music_message_handling' into app-loader
2 parents c88c0cb + 12e0134 commit 17c3d73

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

apps/messages/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
default, if locked, always)
1717
0.69: Remove .music field (which is not used - require("messages").getMessages().find(m=>m.id=="music") works fine)
1818
Ensure .getMessages uses Bangle.MESSAGES to return the most up to date message info
19+
0.70: Fix message app not showing latest music messages

apps/messages/lib.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ exports.clearAll = function() {
152152
* that aren't yet written) apply them to the messages we read so we get
153153
* up to date info.
154154
*
155+
* If were in the messages app and it's defined `MESSAGES` then we just use that
156+
* as it contains all the messages that are already loaded.
157+
*
155158
* Optionally pass in a message to apply to the list, this is for event handlers:
156159
* By passing the message from the event, you can make sure the list is up-to-date,
157160
* even if the message has not been saved (yet)
@@ -165,7 +168,11 @@ exports.clearAll = function() {
165168
* @returns {array} All messages
166169
*/
167170
exports.getMessages = function(withMessage) {
168-
let messages = require("Storage").readJSON("messages.json", true);
171+
let messages;
172+
if (global.MESSAGES!==undefined)
173+
messages = global.MESSAGES.slice(); // we're in the messages app, just use the messages list that it's keeping (clone the array)
174+
else
175+
messages = require("Storage").readJSON("messages.json", true);
169176
messages = Array.isArray(messages) ? messages : []; // make sure we always return an array
170177
(Bangle.MESSAGES || []).forEach(m => require("messages").apply(m, messages)); // apply any usaved messages
171178
if (withMessage && withMessage.id) exports.apply(withMessage, messages);

apps/messages/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "messages",
33
"name": "Messages",
4-
"version": "0.69",
4+
"version": "0.70",
55
"description": "Library to handle, load and store message events received from Android/iOS",
66
"icon": "app.png",
77
"type": "module",

0 commit comments

Comments
 (0)