mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
chore: lay groundwork for masquerades
This commit is contained in:
@@ -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<string, string>;
|
||||
drafts: Record<string, DraftObject>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles storing draft (currently being written) messages.
|
||||
*/
|
||||
export default class Draft implements Store, Persistent<Data> {
|
||||
private drafts: ObservableMap<string, string>;
|
||||
private drafts: ObservableMap<string, DraftObject>;
|
||||
|
||||
/**
|
||||
* Construct new Draft store.
|
||||
@@ -52,7 +59,10 @@ export default class Draft implements Store, Persistent<Data> {
|
||||
* @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<Data> {
|
||||
* @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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user