Skip to content

Commit

Permalink
GH-18 | Convert to async / await syntex
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jun 10, 2023
1 parent afa0ff1 commit dde8798
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions octoprint_SpoolManager/static/js/ResetSettingsUtilV3.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ function ResetSettingsUtilV3(pluginSettings) {

// add/update click action
resetButton.unbind("click");
resetButton.click(function() {
$.ajax({
url: `${API_BASEURL}plugin/${PLUGIN_ID_string}?action=resetSettings`,
type: "GET",
}).done(function(newSettingsData) {
resetButton.click(async () => {
try {
const newSettingsData = await $.ajax({
url: `${API_BASEURL}plugin/${PLUGIN_ID_string}?action=resetSettings`,
type: "GET",
});

new PNotify({
title: "Default settings saved!",
text: "The plugin settings have now been reset to the default values.<br>Please do a Browser reload (Strg + F5) to update all settings in the UI.",
Expand All @@ -84,7 +86,9 @@ function ResetSettingsUtilV3(pluginSettings) {

// delegate to the client. So client is able to reset/init other values
mapSettingsToViewModel_function(newSettingsData);
});
} catch (error) {
// TODO: error handling
}
});

resetButton.show();
Expand Down

0 comments on commit dde8798

Please sign in to comment.