CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/chat/store.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Store } from "@cocalc/frontend/app-framework";
7
import type { ChatMessages } from "./types";
8
9
export interface ChatState {
10
project_id?: string;
11
path?: string;
12
height: number; // 0 means not rendered; otherwise is the height of the chat editor
13
message_plain_text: string; // What the user sees in the chat box eg. stripped of internal mention markup
14
messages?: ChatMessages;
15
drafts?: Map<string, any>;
16
offset?: number; // information about where on screen the chat editor is located
17
position?: number; // more info about where chat editor is located
18
saved_position?: number;
19
search: string;
20
add_collab: boolean;
21
}
22
23
export function getInitialState() {
24
return {
25
height: 0,
26
message_plain_text: "",
27
messages: undefined,
28
drafts: undefined,
29
offset: undefined,
30
position: undefined,
31
saved_position: undefined,
32
search: "",
33
add_collab: false,
34
};
35
}
36
37
export class ChatStore extends Store<ChatState> {
38
getInitialState = () => getInitialState();
39
}
40
41