Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate configuration saving on LED Strip tab #3551

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6564,13 +6564,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 @@ -556,6 +556,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 @@ -567,7 +571,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