From 30b908982944492074da8b1e1cbed59f6645d463 Mon Sep 17 00:00:00 2001 From: padreug Date: Fri, 5 Sep 2025 16:32:42 +0200 Subject: [PATCH] Refactor chat module to utilize standardized service tokens for improved dependency management - Update chat module to use SERVICE_TOKENS for chat service registration and injection, enhancing consistency across the application. - Modify useChat composable to reference the standardized service token, ensuring alignment with the new DI container structure. - Clean up references to the previous CHAT_SERVICE_TOKEN, streamlining the codebase and improving maintainability. --- src/modules/chat/composables/useChat.ts | 6 +++--- src/modules/chat/index.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/chat/composables/useChat.ts b/src/modules/chat/composables/useChat.ts index 4bd6a93..c0a3136 100644 --- a/src/modules/chat/composables/useChat.ts +++ b/src/modules/chat/composables/useChat.ts @@ -1,11 +1,11 @@ import { ref, computed } from 'vue' -import { injectService } from '@/core/di-container' +import { injectService, SERVICE_TOKENS } from '@/core/di-container' import type { ChatService } from '../services/chat-service' import type { ChatPeer } from '../types' import { useMultiAsyncOperation } from '@/core/composables/useAsyncOperation' -// Service token for chat service -export const CHAT_SERVICE_TOKEN = Symbol('chatService') +// Use standardized service token from DI container +export const CHAT_SERVICE_TOKEN = SERVICE_TOKENS.CHAT_SERVICE export function useChat() { const chatService = injectService(CHAT_SERVICE_TOKEN) diff --git a/src/modules/chat/index.ts b/src/modules/chat/index.ts index 0cbd173..831732a 100644 --- a/src/modules/chat/index.ts +++ b/src/modules/chat/index.ts @@ -1,13 +1,13 @@ import type { App } from 'vue' import type { ModulePlugin } from '@/core/types' import type { RouteRecordRaw } from 'vue-router' -import { container } from '@/core/di-container' +import { container, SERVICE_TOKENS } from '@/core/di-container' import { eventBus } from '@/core/event-bus' // Import chat components and services import ChatComponent from './components/ChatComponent.vue' import { ChatService } from './services/chat-service' -import { useChat, CHAT_SERVICE_TOKEN } from './composables/useChat' +import { useChat } from './composables/useChat' import type { ChatConfig } from './types' /** @@ -33,7 +33,7 @@ export const chatModule: ModulePlugin = { // Create and register chat service const chatService = new ChatService(config) - container.provide(CHAT_SERVICE_TOKEN, chatService) + container.provide(SERVICE_TOKENS.CHAT_SERVICE, chatService) // Initialize the service (will handle dependency injection) await chatService.initialize({ @@ -60,10 +60,10 @@ export const chatModule: ModulePlugin = { console.log('🗑️ Uninstalling chat module...') // Clean up chat service - const chatService = container.inject(CHAT_SERVICE_TOKEN) + const chatService = container.inject(SERVICE_TOKENS.CHAT_SERVICE) if (chatService) { chatService.destroy() - container.remove(CHAT_SERVICE_TOKEN) + container.remove(SERVICE_TOKENS.CHAT_SERVICE) } console.log('✅ Chat module uninstalled') @@ -90,7 +90,7 @@ export const chatModule: ModulePlugin = { }, services: { - chatService: CHAT_SERVICE_TOKEN + chatService: SERVICE_TOKENS.CHAT_SERVICE } }