Merge branch 'develop' of github.com:thecodingmachine/workadventure into feat/follow-woka

This commit is contained in:
David Négrier 2021-12-24 15:06:15 +01:00
commit a1cfaa0225
11 changed files with 113 additions and 51 deletions

View file

@ -1,5 +1,3 @@
import { writable } from "svelte/store";
import { createMessageStore } from "./MessageStore";
export const banMessageVisibleStore = writable(false);
export const banMessageContentStore = writable("");
export const banMessageStore = createMessageStore();

View file

@ -0,0 +1,29 @@
import { writable } from "svelte/store";
import { v4 as uuidv4 } from "uuid";
export interface Message {
id: string;
text: string;
}
/**
* A store that contains a list of messages to be displayed.
*/
export function createMessageStore() {
const { subscribe, update } = writable<Message[]>([]);
return {
subscribe,
addMessage: (text: string): void => {
update((messages: Message[]) => {
return [...messages, { id: uuidv4(), text }];
});
},
clearMessageById: (id: string): void => {
update((messages: Message[]) => {
messages = messages.filter((message) => message.id !== id);
return messages;
});
},
};
}

View file

@ -1,5 +1,3 @@
import { writable } from "svelte/store";
import { createMessageStore } from "./MessageStore";
export const textMessageVisibleStore = writable(false);
export const textMessageContentStore = writable("");
export const textMessageStore = createMessageStore();