From 0b221ded05ffbb8b993abb23887ae75a10ca081e Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 27 Mar 2024 19:35:13 +0100 Subject: [PATCH] dynamic --- frontend/src/Apps/Msg.vue | 14 +++++--------- frontend/src/rest/msg.js | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue index 58e243e..92c9c49 100644 --- a/frontend/src/Apps/Msg.vue +++ b/frontend/src/Apps/Msg.vue @@ -7,9 +7,8 @@ @@ -18,10 +17,10 @@
{{ discussion.name }}
- +
-

+

{{ msg.content }} @@ -58,11 +57,8 @@ div#discList{ } .InputTitle{ - background: inherit; - border: inherit; - font-size: inherit; - font-family: inherit; - text-align: inherit; + all: inherit; + margin: auto; } .discItem{ diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js index 94f18dd..d1a9521 100644 --- a/frontend/src/rest/msg.js +++ b/frontend/src/rest/msg.js @@ -8,24 +8,18 @@ import { restGet, restPost, restPatch } from './restConsumer.js' import { ref } from 'vue' -export const currentDiscussion = ref({}); - /** - * @return array of * - id * - name * - members */ -export async function getDiscussions(){ - return restGet("/discussions"); -} +export const discussionsList = ref({}); +export const currentDiscussion = ref({}); -export async function fetchDiscussion(id){ - currentDiscussion.value = await restGet("/discussion/" + id); -} export async function createDiscussion(name){ - return restPost("/discussion", {name: name}); + let disc = await restPost("/discussion", {name: name}); + discussionsList.value.push(disc); } @@ -42,5 +36,16 @@ export async function sendMessage(id, content, responseId){ } export async function updateDiscussionName(id, name){ - return restPatch("/discussion/" + id, {name: name}); + restPatch("/discussion/" + id, {name: name}).then(() => fetchDiscussions()); } + + +async function fetchDiscussions(){ + discussionsList.value = await restGet("/discussions"); +} + +export async function fetchDiscussion(id){ + currentDiscussion.value = await restGet("/discussion/" + id); +} + +await fetchDiscussions();