mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 08:30:58 -05:00
chore: lay groundwork for masquerades
This commit is contained in:
parent
bfeefb4c73
commit
b64c316dc9
1 changed files with 14 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue