Add composable to dynamically use showAlert for individual bots

This commit is contained in:
Matthias 2023-09-23 17:06:24 +02:00
parent 171c608ea8
commit 3bfdeacb04
2 changed files with 11 additions and 1 deletions

View File

@ -6,3 +6,11 @@ export function showAlert(message: string, severity: AlertSeverity = 'warning',
show(message, { title: `${bot ? 'Bot: ' + bot : 'Notification'}`, variant: severity }); show(message, { title: `${bot ? 'Bot: ' + bot : 'Notification'}`, variant: severity });
} }
export function useAlertForBot(botName: string) {
return {
showAlert: (message: string, severity: AlertSeverity = 'warning') => {
showAlert(message, severity, botName);
},
};
}

View File

@ -50,7 +50,7 @@ import {
} from '@/types'; } from '@/types';
import axios, { AxiosResponse } from 'axios'; import axios, { AxiosResponse } from 'axios';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { showAlert } from '../shared/alerts'; import { useAlertForBot } from '../shared/alerts';
import { useWebSocket } from '@vueuse/core'; import { useWebSocket } from '@vueuse/core';
import { FTWsMessage, FtWsMessageTypes } from '@/types/wsMessageTypes'; import { FTWsMessage, FtWsMessageTypes } from '@/types/wsMessageTypes';
import { showNotification } from '@/shared/notifications'; import { showNotification } from '@/shared/notifications';
@ -59,6 +59,8 @@ export function createBotSubStore(botId: string, botName: string) {
const userService = useUserService(botId); const userService = useUserService(botId);
const { api } = useApi(userService, botId); const { api } = useApi(userService, botId);
const { showAlert } = useAlertForBot(botName);
const useBotStore = defineStore(botId, { const useBotStore = defineStore(botId, {
state: () => { state: () => {
return { return {