From 688c895d41bf39f7de74930fd0982c5ee9020492 Mon Sep 17 00:00:00 2001 From: ASDosjani <62965528+ASDosjani@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:05:21 +0100 Subject: [PATCH] Indicate configuration saving on LED Strip tab (#3551) --- locales/en/messages.json | 8 ++++---- src/js/tabs/led_strip.js | 19 ++++++++++++++++++- src/js/tabs/vtx.js | 6 +++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index c26dc5eb6c..93adc0b60c 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -6655,13 +6655,13 @@ "message": "Save", "description": "Save button in the VTX tab" }, - "vtxButtonSaving": { + "buttonSaving": { "message": "Saving", - "description": "Show state of the Save button in the VTX tab" + "description": "Show state of the Save button in the VTX/LED tab" }, - "vtxButtonSaved": { + "buttonSaved": { "message": "Saved", - "description": "Saved action button in the VTX tab" + "description": "Saved action button in the VTX/LED tab" }, "vtxSmartAudioUnlocked": { "message": "{{version}} unlocked", diff --git a/src/js/tabs/led_strip.js b/src/js/tabs/led_strip.js index e027da6224..1933bdb70b 100644 --- a/src/js/tabs/led_strip.js +++ b/src/js/tabs/led_strip.js @@ -639,6 +639,10 @@ led_strip.initialize = function (callback, scrollPosition) { $('a.save').on('click', function () { + const saveButton = $('a.save'); + const oldText = saveButton.text(); + saveButton.html(i18n.getMessage('buttonSaving')).addClass('disabled'); + mspHelper.sendLedStripConfig(send_led_strip_colors); function send_led_strip_colors() { @@ -650,7 +654,20 @@ led_strip.initialize = function (callback, scrollPosition) { } function save_to_eeprom() { - mspHelper.writeConfiguration(false); + mspHelper.writeConfiguration(false, save_completed); + } + + function save_completed() { + const buttonDelay = 1500; + + // Allow firmware to make relevant changes before initialization + setTimeout(() => { + saveButton.html(i18n.getMessage('buttonSaved')); + + setTimeout(() => { + saveButton.html(oldText).removeClass('disabled'); + }, buttonDelay); + }, buttonDelay); } }); diff --git a/src/js/tabs/vtx.js b/src/js/tabs/vtx.js index 38646e1d9d..6f8b80bde1 100644 --- a/src/js/tabs/vtx.js +++ b/src/js/tabs/vtx.js @@ -899,15 +899,15 @@ vtx.initialize = function (callback) { const saveButton = $("#save_button"); const oldText = saveButton.text(); - const buttonDelay = 2000; + const buttonDelay = 1500; - saveButton.html(i18n.getMessage('vtxButtonSaving')).addClass('disabled'); + saveButton.html(i18n.getMessage('buttonSaving')).addClass('disabled'); clearInterval(TABS.vtx.intervalId); // Allow firmware to make relevant changes before initialization setTimeout(() => { - saveButton.html(i18n.getMessage('vtxButtonSaved')); + saveButton.html(i18n.getMessage('buttonSaved')); setTimeout(() => { TABS.vtx.initialize();