~nicohman/signal-rs

ref: 323c129fa86bb81c565d359f329f8b986f9ee021 signal-rs/qml/SignalState.qml -rw-r--r-- 1.7 KiB
323c129f — nicohman Re-add editcontact, and fix createchat lag 5 months ago
                                                                                
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
48
49
50
51
52
53
import QtQuick 2.0
import QtQuick.Controls 2.5

Item {
    id: signalState
    property var messages: ({})
    property string current: ""
    property string currentName: ""
    property string currentView: ""
    property var currentChat : {}
    property var headerItems: []
    property bool desktopView: false
    function openView(viewName) {
        signalState.currentView = viewName;
        signal.show_view(viewName);
        switch (viewName) {
            case "chats":
                window.pageStack.push(chatViewStack);
                break;
            case "createContact":
                window.pageStack.layers.push(Qt.resolvedUrl("CreateContact.qml"));
                break;
            case "settings":
                window.pageStack.push(Qt.resolvedUrl("Settings.qml"));
                break;
            case "chatHistory":
                if (!signalState.desktopView) {
                    window.pageStack.push(messagesViewStack);
                }
                break;
            case "editContact":
                window.pageStack.layers.push(Qt.resolvedUrl("EditContact.qml"));
                break;
            case "createChat":
                window.pageStack.push(createChatStack);
                break;
        }
    }
    function contact(tel) {
        return JSON.parse(signal.contact(tel));
    }
    function setCurrent(cur) {
        signalState.current = cur;
        for (var i=0; i < signal.chats.rowCount(); i++) {
            var idx = signal.chats.index(i, 0);
            var str = signal.chats.data(idx, 2+256).toString();
            if (str == cur.toString()) {
                signalState.currentName = signal.chats.data(idx, 1+256).toString();
                break;
            }
        }
    }
}