From b64c316dc990ae6a87d8215c73db0ba5a1ab3899 Mon Sep 17 00:00:00 2001 From: Ed L Date: Sat, 10 Sep 2022 20:25:44 +0100 Subject: [PATCH] chore: lay groundwork for masquerades --- src/mobx/stores/Draft.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mobx/stores/Draft.ts b/src/mobx/stores/Draft.ts index de84c1f9..345351d7 100644 --- a/src/mobx/stores/Draft.ts +++ b/src/mobx/stores/Draft.ts @@ -5,15 +5,22 @@ import { mapToRecord } from "../../lib/conversion"; import Persistent from "../interfaces/Persistent"; import Store from "../interfaces/Store"; +interface DraftObject { + content?: string; + masquerade?: { + avatar: string; + name: string; + }; +} export interface Data { - drafts: Record; + drafts: Record; } /** * Handles storing draft (currently being written) messages. */ export default class Draft implements Store, Persistent { - private drafts: ObservableMap; + private drafts: ObservableMap; /** * Construct new Draft store. @@ -52,7 +59,10 @@ export default class Draft implements Store, Persistent { * @param channel Channel ID */ @computed has(channel: string) { - return this.drafts.has(channel) && this.drafts.get(channel)!.length > 0; + return ( + this.drafts.has(channel) && + this.drafts.get(channel)!.content!.length > 0 + ); } /** @@ -60,7 +70,7 @@ export default class Draft implements Store, Persistent { * @param channel Channel ID * @param content Draft content */ - @action set(channel: string, content?: string) { + @action set(channel: string, content?: DraftObject) { if (typeof content === "undefined") { return this.clear(channel); }