Skip to content

Commit

Permalink
Fixed-getLogoutMessage-SonarCloud-Warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve0012345 committed Aug 27, 2024
1 parent 1094150 commit 9b8d2ea
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions public/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ app.onDomReady();
let logoutMessage;

// Separate the translation logic into a function that returns a promise
function translateMessage(callback) {
require(['translator'], function (translator) {
translator.translate('[[login:logged-out-due-to-inactivity]]', callback);
});
}
// Separate function to generate the logout message
function getLogoutMessage() {
return new Promise((resolve) => {
if (logoutMessage) {
resolve(logoutMessage);
} else {
require(['translator'], function (translator) {
translator.translate('[[login:logged-out-due-to-inactivity]]',
function (translated) {
logoutMessage = translated;
resolve(logoutMessage);
});
translateMessage((translated) => {
logoutMessage = translated;
resolve(logoutMessage);
});
}
});
Expand Down

0 comments on commit 9b8d2ea

Please sign in to comment.