neilalexander / seaglass

A truly native Matrix client for macOS - written in Swift/Cocoa, with E2E encryption support
Other
525 stars 34 forks source link

Switch RoomMessageView.js to preact, in theory #86

Closed ara4n closed 5 years ago

ara4n commented 6 years ago

Switch from direct DOM mangling to using preact to automate DOM updates by instead maintaining a virtual DOM which preact keeps in sync. Using a test jig to insert events into the HTML seems to work okay:

    <script type="text/javascript">
        setTimeout(()=>{
            drawEvents([
                {
                    eventId: "123",
                    sender: "@matthew:matrix.org",
                    type: "m.room.message",
                    content: {
                        body: "i am a fish",
                    }
                },
                {
                    eventId: "124",
                    sender: "@matthew:matrix.org",
                    type: "m.room.message",
                    content: {
                        body: "i am a fish",
                    }
                }
            ], true);
        }, 0);

        setTimeout(()=>{
            removeEvents([
                {
                    eventId: "123",
                    sender: "@matthew:matrix.org",
                    type: "m.room.message",
                    content: {
                        body: "i am a fish",
                    }
                },
                {
                    eventId: "124",
                    sender: "@matthew:matrix.org",
                    type: "m.room.message",
                    content: {
                        body: "i am a fish",
                    }
                }
            ]);
        }, 1000);
    </script>

...but it seems to be erroring from Seaglass itself. Eitherway, the point of the PR is to hopefully demonstrate that managing an HTML view in WebKit using preact might be quite painless and easy to forget about, and possibly less pain than NSAttributedString fun.