summary refs log tree commit diff
path: root/v2/screen/home.ts
blob: 4c8a7cc26d8c45de872769a984ee52561121f2ab (plain)
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
import { ElemType } from "../screenbuilder.ts";
import { Screen } from "../screen.ts";
import type { Input } from "../elements.ts";
import * as client from "../client.ts"

export default {
    elements: [
        {
            type: ElemType.TextElem,
            id: 'home',
            data: ["Loading home posts...\n"]
        },
        {
            type: ElemType.HR,
            id: 'hr',
            data: []
        },
        {
            type: ElemType.InputElem,
            id: 'msg-input',
            data: [false, false, true]
        },
        {
            type: ElemType.ButtonElem,
            id: 'done-btn',
            data: ["Send", async function (this: Screen) {
                const msgInput: Input = this.elements.get('msg-input') as Input
                client.sendHome(msgInput.value);
                msgInput.value = ""
                this.render()
            }]
        }
    ],
    focus: "msg-input",
    name: 'home',
    onload (screen: Screen) {
        client.setScreen(screen)
        client.loadHome(screen)
    }
}