Skip to content

Commit

Permalink
Fix broken management of alert messages
Browse files Browse the repository at this point in the history
In aded591, the function to add alert message has been modified
for no good reason resulting in message to be empty in the interface.

We also fix alert message management when loading data. This has been
missed when switching to VueJS. We shouldn't use "this" keyword anymore in
vue components or views.
  • Loading branch information
pgiraud committed Nov 13, 2024
1 parent 5167097 commit 60afe94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions powa/static/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ import LoginView from "@/components/LoginView.vue";
import { encodeQueryData } from "@/utils/query";
import { useMessageService } from "@/composables/MessageService.js";
const { alertMessages, addAlertMessage, removeAlertMessage } =
const { alertMessages, addAlertMessage, addAlertMessages, removeAlertMessage } =
useMessageService();
const theme = useTheme();
Expand Down Expand Up @@ -355,7 +355,7 @@ function loadData() {
try {
const data = JSON.parse(response);
if (data) {
this.addAlertMessages(data.messages);
addAlertMessages(data.messages);
}
} catch (error) {
// pass
Expand Down
6 changes: 4 additions & 2 deletions powa/static/js/composables/MessageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ function addAlertMessage(level, message) {
}

function addAlertMessages(messages) {
for (let message in messages) {
addAlertMessage(message.level, message.message);
for (let level in messages) {
for (let message of messages[level]) {
addAlertMessage(level, message);
}
}
}
function removeAlertMessage(id) {
Expand Down

0 comments on commit 60afe94

Please sign in to comment.