/
store.ts
47 lines (44 loc) · 1.63 KB
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 3rd Party Libraries
import * as immutable from "immutable";
// Internal Libraries
import { Store } from "../app-framework/Store";
interface ChatState {
height: number; // 0 means not rendered; otherwise is the height of the chat editor
input: string; // content of the input box
is_preview?: boolean; // currently displaying preview of the main input chat
last_sent?: string; // last sent message
messages?: immutable.Map<any, any>;
offset?: number; // information about where on screen the chat editor is located
position?: number; // more info about where chat editor is located
saved_mesg?: string; // The message state before saving and edited message. Potentially broken with mutiple edits
use_saved_position?: boolean; // whether or not to maintain last saved scroll position (used when unmounting then remounting, e.g., due to tab change)
saved_position?: number;
search: string;
add_collab: boolean;
is_saving: boolean;
has_uncommitted_changes: boolean;
has_unsaved_changes: boolean;
unsent_user_mentions: immutable.List<{ id: string; display: string }>;
}
export class ChatStore extends Store<ChatState> {
getInitialState = function() {
return {
height: 0,
input: "",
is_preview: undefined,
last_sent: undefined,
messages: undefined,
offset: undefined,
position: undefined,
saved_mesg: undefined,
use_saved_position: undefined,
saved_position: undefined,
search: "",
add_collab: true,
is_saving: false,
has_uncommitted_changes: false,
has_unsaved_changes: false,
unsent_user_mentions: immutable.List()
};
};
}