Compare commits
10 Commits
fcb195ddb3
...
c611d03341
| Author | SHA1 | Date | |
|---|---|---|---|
| c611d03341 | |||
| db3038e181 | |||
| 241ee19e1c | |||
| b39391dc90 | |||
| 665a3c0dfa | |||
| eb50f45822 | |||
| 914f4ac97b | |||
| 02fcfba5f1 | |||
| be10d1896b | |||
| 0ed4f9545c |
@@ -9,6 +9,8 @@ services:
|
||||
RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_DEFAULT_VHOST}
|
||||
volumes:
|
||||
- rabbitmqdata:/var/lib/rabbitmq
|
||||
ports:
|
||||
- "15672:15672"
|
||||
healthcheck:
|
||||
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
|
||||
interval: 10s
|
||||
|
||||
@@ -109,6 +109,7 @@ public class WhiteboardHub : Hub
|
||||
if (user == null)
|
||||
{
|
||||
user = await _userService.GetUser(userId);
|
||||
whiteboard.AddUser(user);
|
||||
}
|
||||
|
||||
await Clients.User(ownerId.ToString()).SendAsync("UserWaitingForApproval", user);
|
||||
@@ -128,8 +129,7 @@ public class WhiteboardHub : Hub
|
||||
await Clients.User(targetUserId.ToString()).SendAsync("Accepted");
|
||||
await Clients.User(targetUserId.ToString()).SendAsync("InitWhiteboard", whiteboard);
|
||||
|
||||
await Clients.GroupExcept(whiteboard.WhiteboardId.ToString(),
|
||||
Context.ConnectionId).SendAsync("Joined", user);
|
||||
await Clients.Group(whiteboard.WhiteboardId.ToString()).SendAsync("Joined", user);
|
||||
}
|
||||
|
||||
public async Task RejectUser(Guid targetUserId)
|
||||
|
||||
@@ -26,9 +26,9 @@ const showLogoutConfirm = ref(false)
|
||||
|
||||
<div id="navbarNav" class="collapse navbar-collapse">
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<!-- <li class="nav-item">
|
||||
<RouterLink class="nav-link" active-class="active" to="/test">Test</RouterLink>
|
||||
</li>
|
||||
</li> -->
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav">
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, type Ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import type { Arrow, Line, Rectangle, Shape, ShapeTool, ShapeType, TextShape, Whiteboard } from '@/types/whiteboard.ts'
|
||||
import { whiteboardHubService } from '@/services/whiteboardHubService.ts'
|
||||
import {useWhiteboardsStore} from "@/stores/whiteboards.ts";
|
||||
import router from "@/router";
|
||||
import type {User} from "@/types";
|
||||
import { fetchUser } from '@/services/userService'
|
||||
|
||||
export const useWhiteboardStore = defineStore('whiteboard', () => {
|
||||
const whiteboard = ref<Whiteboard | null>(null)
|
||||
@@ -22,6 +23,20 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
|
||||
const toolThickness = ref(2)
|
||||
const toolTextSize = ref(24)
|
||||
|
||||
async function resolveUsername(list: Ref<User[]>, user: User): Promise<void> {
|
||||
if (user.username && user.username !== 'Unknown') return
|
||||
|
||||
try {
|
||||
const resolved = await fetchUser(user.userId)
|
||||
const idx = list.value.findIndex(u => u.userId === user.userId)
|
||||
if (idx !== -1 && resolved.username) {
|
||||
list.value[idx] = { ...list.value[idx], username: resolved.username, email: resolved.email || list.value[idx].email }
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`Failed to resolve username for ${user.userId}`, err)
|
||||
}
|
||||
}
|
||||
|
||||
const selectedShape = computed(() => {
|
||||
if (!selectedShapeId.value || !selectedShapeType.value || !whiteboard.value) return null
|
||||
switch (selectedShapeType.value) {
|
||||
@@ -49,6 +64,9 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
|
||||
}
|
||||
|
||||
connectedUsers.value = Array.from(uniqueUsers.values())
|
||||
for (const user of connectedUsers.value) {
|
||||
resolveUsername(connectedUsers, user)
|
||||
}
|
||||
isLoading.value = false
|
||||
})
|
||||
|
||||
@@ -75,6 +93,7 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
|
||||
whiteboardHubService.onJoined((user) => {
|
||||
if (!connectedUsers.value.some(u => u.userId === user.userId)) {
|
||||
connectedUsers.value.push(user)
|
||||
resolveUsername(connectedUsers, user)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -90,6 +109,7 @@ export const useWhiteboardStore = defineStore('whiteboard', () => {
|
||||
whiteboardHubService.onUserWaitingForApproval((user) => {
|
||||
if (!pendingUsers.value.some(u => u.userId === user.userId)) {
|
||||
pendingUsers.value.push(user)
|
||||
resolveUsername(pendingUsers, user)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -126,7 +126,10 @@ async function joinWithCode() {
|
||||
pattern="[0-9]*"
|
||||
@input="joinCode = joinCode.replace(/\D/g, '')"
|
||||
/>
|
||||
<button class="btn btn-primary w-75 mt-2 d-block mx-auto" @click="joinWithCode">Join with code</button>
|
||||
<button class="btn btn-primary w-75 mt-2 d-block mx-auto" :disabled="whiteboards.isLoading" @click="joinWithCode">
|
||||
<span v-if="whiteboards.isLoading" class="spinner-border spinner-border-sm me-2"></span>
|
||||
Join with code
|
||||
</button>
|
||||
<div class="text-center">
|
||||
<small class="text-muted my-4 d-inline-block">or</small>
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,7 @@ async function onSubmit() {
|
||||
loading.value = true
|
||||
try {
|
||||
await auth.signup({ username: username.value, email: email.value, password: password.value })
|
||||
await auth.login({ email: email.value, password: password.value})
|
||||
router.push('/')
|
||||
} catch (e: any) {
|
||||
error.value = e.messages || ['Signup failed']
|
||||
|
||||
Reference in New Issue
Block a user