add chat base-button in header menu

This commit is contained in:
ogerly 2023-07-05 15:51:55 +02:00
parent 34d38b117e
commit c8af90f0a6
10 changed files with 108 additions and 36 deletions

View File

@ -30,12 +30,12 @@ import { roomQuery } from '~/graphql/Rooms'
import { messageQuery } from '~/graphql/Messages' import { messageQuery } from '~/graphql/Messages'
export default { export default {
name: 'Chat', name: 'Chat',
props: { props: {
theme: { theme: {
type: String, type: String,
}
}, },
},
data() { data() {
return { return {
currentUserId: '1234', currentUserId: '1234',
@ -126,27 +126,27 @@ export default {
methods: { methods: {
fetchMessages({ room, options = {} }) { fetchMessages({ room, options = {} }) {
console.log(room, options) // console.log(room, options)
this.messagesLoaded = false this.messagesLoaded = false
setTimeout(async () => { setTimeout(async () => {
if (options.reset) { if (options.reset) {
console.log('reset messages') // console.log('reset messages')
this.messages = [] // this.addMessages(true) this.messages = [] // this.addMessages(true)
} else { } else {
try { try {
const { const {
data: { Message }, data: { Message },
} = await this.$apollo.query({ } = await this.$apollo.query({
query: messageQuery(), query: messageQuery(),
variables: { variables: {
roomId: room.id, roomId: room.id,
} },
}) })
console.log('Messages', Message) // console.log('Messages', Message)
this.messages = Message this.messages = Message
} catch (error) { } catch (error) {
console.log('Error', error) // console.log('Error', error)
this.messages = [] //this.addMessages(true) this.messages = [] // this.addMessages(true)
this.$toast.error(error.message) this.$toast.error(error.message)
} }
} }
@ -217,10 +217,8 @@ export default {
if (!Room) { if (!Room) {
this.rooms = [] this.rooms = []
return return
} }
this.rooms = Room this.rooms = Room
}, },
error(error) { error(error) {
this.rooms = [] this.rooms = []

View File

@ -0,0 +1,67 @@
<template>
<nuxt-link
class="chat-menu"
:to="{ name: 'chat' }"
>
<base-button
ghost
circle
v-tooltip="{
content: $t('notifications.headerMenuButton.chat'),
placement: 'bottom-start',
}"
><img src="/img/empty/chat-bubble.svg"/>
</base-button>
</nuxt-link>
</template>
<script>
export default {
name: 'ChatMenu',
}
</script>
<style lang="scss">
.counter-icon {
position: relative;
> .count {
position: absolute;
top: -$space-xx-small;
right: 0;
display: inline-flex;
align-items: center;
justify-content: center;
height: $size-icon-base;
min-width: $size-icon-base;
padding: 3px; // magic number to center count
border-radius: 50%;
transform: translateX(50%);
color: $color-neutral-100;
background-color: $color-primary;
font-size: 10px; // magic number to center count
line-height: 1;
text-align: center;
&.--danger {
background-color: $color-danger;
}
&.--inactive {
background-color: $color-neutral-60;
}
&.--soft {
background-color: $color-neutral-90;
color: $text-color-soft;
}
}
}
</style>

View File

@ -92,6 +92,10 @@
<client-only v-if="!isEmpty(this.$env.MAPBOX_TOKEN)"> <client-only v-if="!isEmpty(this.$env.MAPBOX_TOKEN)">
<map-button /> <map-button />
</client-only> </client-only>
<!-- chat menü -->
<client-only>
<chat-notification-menu placement="top" />
</client-only>
<!-- avatar menu --> <!-- avatar menu -->
<client-only> <client-only>
<avatar-menu placement="top" /> <avatar-menu placement="top" />
@ -265,6 +269,7 @@ import SearchField from '~/components/features/SearchField/SearchField.vue'
import NotificationMenu from '~/components/NotificationMenu/NotificationMenu' import NotificationMenu from '~/components/NotificationMenu/NotificationMenu'
import links from '~/constants/links.js' import links from '~/constants/links.js'
import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue' import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue'
import ChatNotificationMenu from '~/components/ChatNotificationMenu/ChatNotificationMenu'
export default { export default {
components: { components: {
@ -278,6 +283,7 @@ export default {
NotificationMenu, NotificationMenu,
PageParamsLink, PageParamsLink,
SearchField, SearchField,
ChatNotificationMenu,
}, },
props: { props: {
showMobileMenu: { type: Boolean, default: false }, showMobileMenu: { type: Boolean, default: false },

View File

@ -2,7 +2,7 @@ import gql from 'graphql-tag'
export const messageQuery = () => { export const messageQuery = () => {
return gql` return gql`
query($roomId: ID!) { query ($roomId: ID!) {
Message(roomId: $roomId) { Message(roomId: $roomId) {
id id
content content
@ -13,4 +13,3 @@ export const messageQuery = () => {
} }
` `
} }

View File

@ -1,12 +1,12 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const roomQuery = () => gql` export const roomQuery = () => gql`
query { query {
Room { Room {
id id
users { users {
id id
}
}
} }
}
}
` `

View File

@ -692,7 +692,8 @@
}, },
"group": "Beschreibung", "group": "Beschreibung",
"headerMenuButton": { "headerMenuButton": {
"tooltip": "Meine Benachrichtigungen" "tooltip": "Meine Benachrichtigungen",
"chat": "Meine Chat"
}, },
"markAllAsRead": "Markiere alle als gelesen", "markAllAsRead": "Markiere alle als gelesen",
"pageLink": "Alle Benachrichtigungen", "pageLink": "Alle Benachrichtigungen",

View File

@ -692,7 +692,8 @@
}, },
"group": "Description", "group": "Description",
"headerMenuButton": { "headerMenuButton": {
"tooltip": "My notifications" "tooltip": "My notifications",
"chat": "My Chat"
}, },
"markAllAsRead": "Mark all as read", "markAllAsRead": "Mark all as read",
"pageLink": "All notifications", "pageLink": "All notifications",

View File

@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<chat :theme="theme"/> <chat :theme="theme" />
<base-button @click="theme = theme === 'light' ? 'dark' : 'light'"> <base-button @click="theme = theme === 'light' ? 'dark' : 'light'">
change style mode change style mode
</base-button> </base-button>
</div> </div>
</template> </template>

View File

@ -1,7 +1,6 @@
import { register } from 'vue-advanced-chat' import { register } from 'vue-advanced-chat'
export default ({ app }) => { export default ({ app }) => {
if(process.client){ if (process.client) {
register() register()
} }
} }

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" id="chat-bubble"><g data-name="Chat"><path fill="#9B9B9B" d="M27.23,24.91A9,9,0,0,0,22.44,9.52,8.57,8.57,0,0,0,21,9.41a8.94,8.94,0,0,0-8.92,10.14c0,.1,0,.2,0,.29a9,9,0,0,0,.22,1l0,.11a8.93,8.93,0,0,0,.38,1l.13.28a9,9,0,0,0,.45.83l.07.14a9.13,9.13,0,0,1-2.94-.36,1,1,0,0,0-.68,0L7,24.13l.54-1.9a1,1,0,0,0-.32-1,9,9,0,0,1,11.27-14,1,1,0,0,0,1.23-1.58A10.89,10.89,0,0,0,13,3.25a11,11,0,0,0-7.5,19l-1,3.34A1,1,0,0,0,5.9,26.82l4.35-1.93a11,11,0,0,0,4.68.16A9,9,0,0,0,21,27.41a8.81,8.81,0,0,0,2.18-.27l3.41,1.52A1,1,0,0,0,28,27.48Zm-1.77-1.1a1,1,0,0,0-.32,1L25.45,26l-1.79-.8a1,1,0,0,0-.41-.09,1,1,0,0,0-.29,0,6.64,6.64,0,0,1-2,.29,7,7,0,0,1,0-14,6.65,6.65,0,0,1,1.11.09,7,7,0,0,1,3.35,12.31Z"></path><path fill="#9B9B9B" d="M17.82 17.08H17a1 1 0 0 0 0 2h.82a1 1 0 0 0 0-2zM21.41 17.08h-.82a1 1 0 0 0 0 2h.82a1 1 0 0 0 0-2zM25 17.08h-.82a1 1 0 0 0 0 2H25a1 1 0 0 0 0-2z"></path></g></svg>

After

Width:  |  Height:  |  Size: 942 B