@@ -133,6 +133,7 @@ const isLoading = ref(true)
const characters = ref([])
const selectedCharacterId = ref(null)
const isCreateNewCharacterModalOpen = ref(false)
+const newNickname = ref('')
const newCharacterName = ref('')
const characterHairs = ref([])
const selectedHairId = ref(null)
@@ -179,7 +180,8 @@ function loginWithCharacter() {
SocketEvent.CHARACTER_CONNECT,
{
characterId: selectedCharacterId.value,
- characterHairId: selectedHairId.value
+ characterHairId: selectedHairId.value,
+ newNickname: newNickname.value
},
(response: { character: CharacterT; map: Map; characters: CharacterT[] }) => {
gameStore.setCharacter(response.character)
@@ -198,6 +200,7 @@ function createCharacter() {
// Watch changes for selected character and update hairs
watch(selectedCharacterId, (characterId) => {
if (!characterId) return
+ newNickname.value = ''
selectedHairId.value = characters.value.find((c) => c.id == characterId)?.characterHair ?? null
})
diff --git a/src/components/utilities/Notifications.vue b/src/components/utilities/Notifications.vue
index 13e6db2..55a42e7 100644
--- a/src/components/utilities/Notifications.vue
+++ b/src/components/utilities/Notifications.vue
@@ -14,7 +14,7 @@ import { SocketEvent } from '@/application/enums'
import Modal from '@/components/utilities/Modal.vue'
import { socketManager } from '@/managers/SocketManager'
import { useGameStore } from '@/stores/gameStore'
-import { onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, watch } from 'vue'
+import { onMounted, onUnmounted, watch } from 'vue'
const gameStore = useGameStore()
@@ -37,13 +37,13 @@ function setupNotificationListener(connection: any) {
}
onMounted(() => {
- const connection = gameStore.connection
+ const connection = socketManager.connection
if (connection) {
setupNotificationListener(connection)
} else {
// Watch for changes in the socket connection
watch(
- () => gameStore.connection,
+ () => socketManager.connection,
(newConnection) => {
if (newConnection) setupNotificationListener(newConnection)
}
@@ -52,7 +52,7 @@ onMounted(() => {
})
onUnmounted(() => {
- const connection = gameStore.connection
+ const connection = socketManager.connection
if (connection) {
connection.off(SocketEvent.NOTIFICATION)
}