Merge branch 'develop' of github.com:thecodingmachine/workadventure into feat/follow-woka
This commit is contained in:
commit
a1cfaa0225
11 changed files with 113 additions and 51 deletions
|
@ -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();
|
||||
|
|
29
front/src/Stores/TypeMessageStore/MessageStore.ts
Normal file
29
front/src/Stores/TypeMessageStore/MessageStore.ts
Normal 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;
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue