Skip to content

Commit

Permalink
Fix some notification problems (#827)
Browse files Browse the repository at this point in the history
* Fix missing success message in playlist editing, ref #798

Ref #768

* Fix deletion of messages in store, ref #768

This results in the same notification will not be shown again after hiding or removing it.

* Prevent notification messages with the same ID

Currently, it can happen that several messages get the same ID, as the number of messages is used to determine the next id. For example, if only the first message is removed from two messages, a new message receives the same ID as the second message.

---------

Co-authored-by: Dennis Benz <[email protected]>
  • Loading branch information
dennis531 and Dennis Benz authored Nov 6, 2023
1 parent ea430ba commit 60118e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vueapp/components/MessageBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="messagebox"
:class="`messagebox_` + type">
<div class="messagebox_buttons">
<a class="close" href="#" title="Nachrichtenbox schliessen">
<a class="close" href="#" title="Nachrichtenbox schliessen" @click.prevent="hide">
<span>Nachrichtenbox schliessen</span>
</a>
</div>
Expand Down
8 changes: 7 additions & 1 deletion vueapp/store/messages.module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const initialState = {
messages: [],
message_max_id: 0,
message_num: 1
};

Expand All @@ -23,7 +24,8 @@ export const actions = {
let messages = state.messages;
let current_message = messages.find(msg => msg.type == message.type && msg.text == message.text);
if (!current_message) {
message.id = messages.length + 1;
context.commit('incrementMessageMaxId')
message.id = state.message_max_id;
context.commit('setMessage', message);
}
},
Expand All @@ -43,6 +45,10 @@ export const mutations = {
state.messages = messages;
},

incrementMessageMaxId(state) {
state.message_max_id++;
},

removeMessage(state, id) {
let message_index = state.messages.findIndex(msg => msg.id == id);
if (message_index != -1) {
Expand Down
4 changes: 3 additions & 1 deletion vueapp/store/playlists.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ const mutations = {

addToVideosCount(state, data) {
let idx = state.playlists.findIndex(playlist => playlist.token === data.token);
state.playlists[idx].videos_count += data.addToCount;
if (idx !== -1) {
state.playlists[idx].videos_count += data.addToCount;
}
}
}

Expand Down

0 comments on commit 60118e7

Please sign in to comment.