From dadf0b63297ce15c925314668dbcb650a369de6d Mon Sep 17 00:00:00 2001 From: Sophie L Date: Tue, 24 Jan 2023 17:55:04 +0000 Subject: [PATCH] fix: update draft check (#830) --- src/mobx/stores/Draft.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mobx/stores/Draft.ts b/src/mobx/stores/Draft.ts index de81ea8a..7c5fcaaa 100644 --- a/src/mobx/stores/Draft.ts +++ b/src/mobx/stores/Draft.ts @@ -59,10 +59,12 @@ export default class Draft implements Store, Persistent { * @param channel Channel ID */ @computed has(channel: string) { - return ( - this.drafts.has(channel) && - this.drafts.get(channel)!.content!.length > 0 - ); + if (!this.drafts.has(channel)) return false; + // fetch the draft object + const potentialDraft = this.drafts.get(channel)?.content; + // if it doesn't have any content return false + if (!potentialDraft) return false; + return potentialDraft.length > 0; } /**