Merge pull request #2655 from blm768/alarm-fix

Fix a menu crash in alarms app
pull/2658/head
Gordon Williams 2023-03-20 09:50:15 +00:00 committed by GitHub
commit 46e4bba312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -43,3 +43,4 @@
Display alarm label in delete prompt
0.39: Dated event repeat option
0.40: Use substring of message when it's longer than fits the designated menu entry.
0.41: Fix a menu bug affecting alarms with empty messages.

View File

@ -56,6 +56,16 @@ function trimLabel(label, maxLength) {
: label.substring(0,maxLength));
}
function formatAlarmMessage(msg) {
if (msg == null) {
return msg;
} else if (msg.length > 7) {
return msg.substring(0,6)+"...";
} else {
return msg.substring(0,7);
}
}
function showMainMenu() {
const menu = {
"": { "title": /*LANG*/"Alarms & Timers" },
@ -145,9 +155,7 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
},
/*LANG*/"Message": {
value: alarm.msg,
format: v => (v.length > 7
? (v.substring(0,6)+"...")
: v.substring(0,7)),
format: formatAlarmMessage,
onchange: () => {
setTimeout(() => {
keyboard.input({text:alarm.msg}).then(result => {
@ -379,9 +387,7 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
},
/*LANG*/"Message": {
value: timer.msg,
format: v => (v.length > 7
? (v.substring(0,6)+"...")
: v.substring(0,7)),
format: formatAlarmMessage,
onchange: () => {
setTimeout(() => {
keyboard.input({text:timer.msg}).then(result => {

View File

@ -2,7 +2,7 @@
"id": "alarm",
"name": "Alarms & Timers",
"shortName": "Alarms",
"version": "0.40",
"version": "0.41",
"description": "Set alarms and timers on your Bangle",
"icon": "app.png",
"tags": "tool,alarm",