Skip to content

Commit

Permalink
Indicate configuration saving on LED Strip tab (betaflight#3551)
Browse files Browse the repository at this point in the history
  • Loading branch information
ASDosjani authored and chmelevskij committed Apr 27, 2024
1 parent 1affa6e commit 688c895
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
8 changes: 4 additions & 4 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 18 additions & 1 deletion src/js/tabs/led_strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/js/tabs/vtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 688c895

Please sign in to comment.