mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
57 lines
1.1 KiB
Vue
57 lines
1.1 KiB
Vue
<script>
|
|
import WootSnackbar from './Snackbar.vue';
|
|
import { emitter } from 'shared/helpers/mitt';
|
|
|
|
export default {
|
|
components: {
|
|
WootSnackbar,
|
|
},
|
|
props: {
|
|
duration: {
|
|
type: Number,
|
|
default: 2500,
|
|
},
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
snackMessages: [],
|
|
};
|
|
},
|
|
|
|
mounted() {
|
|
emitter.on('newToastMessage', this.onNewToastMessage);
|
|
},
|
|
unmounted() {
|
|
emitter.off('newToastMessage', this.onNewToastMessage);
|
|
},
|
|
methods: {
|
|
onNewToastMessage({ message, action }) {
|
|
this.snackMessages.push({
|
|
key: new Date().getTime(),
|
|
message,
|
|
action,
|
|
});
|
|
window.setTimeout(() => {
|
|
this.snackMessages.splice(0, 1);
|
|
}, this.duration);
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<transition-group
|
|
name="toast-fade"
|
|
tag="div"
|
|
class="left-0 my-0 mx-auto max-w-[25rem] overflow-hidden absolute right-0 text-center top-4 z-[9999]"
|
|
>
|
|
<WootSnackbar
|
|
v-for="snackMessage in snackMessages"
|
|
:key="snackMessage.key"
|
|
:message="snackMessage.message"
|
|
:action="snackMessage.action"
|
|
/>
|
|
</transition-group>
|
|
</template>
|