Skip to content

Commit

Permalink
fix: close notification entry expand, when close notification menu
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Apr 10, 2022
1 parent 2e6aa6f commit b6bf2d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/notifications/NotificationMenuEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<script lang="ts">
import BaseMixin from '@/components/mixins/base'
import { Component, Mixins, Prop } from 'vue-property-decorator'
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import { mdiClose, mdiLinkVariant, mdiBellOffOutline } from '@mdi/js'
import { GuiNotificationStateEntry } from '@/store/gui/notifications/types'
Expand All @@ -113,6 +113,9 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
@Prop({ required: true })
declare readonly entry: GuiNotificationStateEntry
@Prop({ default: true })
declare readonly parentState: boolean
get formatedText() {
return this.entry.description.replace(/\[([^\]]+)\]\(([^)]+)\)/, '<a href="$2" target="_blank">$1</a>')
}
Expand All @@ -138,6 +141,11 @@ export default class NotificationMenuEntry extends Mixins(BaseMixin) {
dismiss(type: 'time' | 'reboot', time: number | null) {
this.$store.dispatch('gui/notifications/dismiss', { id: this.entry.id, type, time })
}
@Watch('parentState')
parentStateUpdate(newVal: boolean) {
if (!newVal) this.expand = false
}
}
</script>

Expand Down
6 changes: 5 additions & 1 deletion src/components/notifications/TheNotificationMenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<v-menu
v-model="boolMenu"
bottom
:left="!isMobile"
offset-y
Expand Down Expand Up @@ -27,7 +28,8 @@
<notification-menu-entry
:key="entry.id"
:entry="entry"
:class="index < notifications.length - 1 ? '' : 'mb-0'" />
:class="index < notifications.length - 1 ? '' : 'mb-0'"
:parent-state="boolMenu" />
</template>
</v-card-text>
</overlay-scrollbars>
Expand Down Expand Up @@ -66,6 +68,8 @@ export default class TheNotificationMenu extends Mixins(BaseMixin) {
mdiBellOutline = mdiBellOutline
mdiCloseBoxMultipleOutline = mdiCloseBoxMultipleOutline
private boolMenu = false
get notifications() {
return this.$store.getters['gui/notifications/getNotifications'] ?? []
}
Expand Down

0 comments on commit b6bf2d6

Please sign in to comment.