Merge pull request #48 from StewKI/feature-updated-whiteboard-creation-logic

Now uses policy and max participants for creating whiteboards
This commit is contained in:
2026-03-08 15:45:36 +01:00
committed by GitHub
3 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import type {JoinResult, Whiteboard} from "@/types"; import type {JoinResult, Whiteboard} from "@/types";
import {api} from './api' import {api} from './api'
import type {WhiteboardJoinPolicy} from "@/enums";
export const whiteboardService = { export const whiteboardService = {
async getWhiteboardHistory(): Promise<Whiteboard[]> { async getWhiteboardHistory(): Promise<Whiteboard[]> {
@@ -12,8 +13,8 @@ export const whiteboardService = {
return raw.map(mapWhiteboard) return raw.map(mapWhiteboard)
}, },
async createNewWhiteboard(title: string): Promise<string> { async createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise<string> {
return await api.post<string>('/api/Whiteboard', { title: title, maxParticipants: 10, joinPolicy: 0}) return await api.post<string>('/api/Whiteboard', { title: title, maxParticipants: maxParticipants, joinPolicy: joinPolicy})
}, },
async getWhiteboardById(id: string): Promise<Whiteboard> { async getWhiteboardById(id: string): Promise<Whiteboard> {

View File

@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { ref } from 'vue' import { ref } from 'vue'
import type {JoinResult, Whiteboard} from '@/types' import type {JoinResult, Whiteboard} from '@/types'
import { whiteboardService } from '@/services/whiteboardService' import { whiteboardService } from '@/services/whiteboardService'
import type {WhiteboardJoinPolicy} from "@/enums";
export const useWhiteboardsStore = defineStore('whiteboards', () => { export const useWhiteboardsStore = defineStore('whiteboards', () => {
const ownedWhiteboards = ref<Whiteboard[]>([]) const ownedWhiteboards = ref<Whiteboard[]>([])
@@ -35,13 +36,13 @@ export const useWhiteboardsStore = defineStore('whiteboards', () => {
} }
} }
async function createNewWhiteboard(title: string): Promise<string> { async function createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise<string> {
let newWhiteboard: Whiteboard; let newWhiteboard: Whiteboard;
isLoading.value = true isLoading.value = true
error.value = null error.value = null
try { try {
const newId = await whiteboardService.createNewWhiteboard(title) const newId = await whiteboardService.createNewWhiteboard(title, joinPolicy, maxParticipants)
newWhiteboard = await whiteboardService.getWhiteboardById(newId) newWhiteboard = await whiteboardService.getWhiteboardById(newId)
} catch (err: any) { } catch (err: any) {
error.value = err.message ?? 'Failed to create whiteboard' error.value = err.message ?? 'Failed to create whiteboard'

View File

@@ -25,7 +25,11 @@ async function handleCreateNewWhiteboard() {
} }
try { try {
const newWhiteboardId = await whiteboards.createNewWhiteboard(whiteboardTitle.value.trim()) const newWhiteboardId = await whiteboards.createNewWhiteboard(
whiteboardTitle.value.trim(),
selectedJoinPolicy.value,
maxParticipants.value
)
showCreateModal.value = false showCreateModal.value = false
whiteboardTitle.value = '' whiteboardTitle.value = ''