Skip to content
This repository was archived by the owner on Oct 24, 2020. It is now read-only.

Commit 7a7efa2

Browse files
committed
Support E2E partially
(1) We can now read encrypted messages. It turns out that we should wait a little bit more to ensure crypto is initialized correctly. (matrix-org/matrix-js-sdk#731) (2) We still need to claim keys every time we refresh the page. This should be fixed later. (3) We cannot send encrypted messages yet. This should be fixed later. (4) Verifying devices is not yet supported.
1 parent 2933362 commit 7a7efa2

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/App.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class App extends React.Component
4444
this.initMatrix()
4545
this.startMatrix()
4646
}
47-
47+
4848
this.logIn = this.logIn.bind(this)
4949
this.logOut = this.logOut.bind(this)
5050
}
@@ -60,17 +60,18 @@ class App extends React.Component
6060
cryptoStore: new sdk.MemoryCryptoStore(),
6161
})
6262

63-
this.matrix.initCrypto()
63+
this.initCryptoPromise = this.matrix.initCrypto()
6464
}
6565

6666
async startMatrix()
6767
{
68+
await this.initCryptoPromise
6869
await this.matrix.startClient({
6970
initialSyncLimit: 10,
7071
pendingEventOrdering: 'detached',
7172
})
7273
}
73-
74+
7475
/**
7576
* logIn({ username, password, homeserver })
7677
*/
@@ -132,7 +133,7 @@ class App extends React.Component
132133

133134
this.matrix = null
134135
}
135-
136+
136137
render()
137138
{
138139
return (

src/components/timeline/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Timeline extends React.Component
3131
{
3232
super(props)
3333
this.state = { timeline: [] }
34-
34+
3535
this.timelineWindow = new sdk.TimelineWindow(
3636
this.props.matrix, this.props.timelineSet)
3737

@@ -75,9 +75,9 @@ class Timeline extends React.Component
7575

7676
paginateBack()
7777
{
78-
return this.paginate(sdk.EventTimeline.BACKWARDS)
78+
return this.paginate(sdk.EventTimeline.BACKWARDS)
7979
}
80-
80+
8181
paginateForward()
8282
{
8383
return this.paginate(sdk.EventTimeline.FORWARDS)
@@ -87,7 +87,7 @@ class Timeline extends React.Component
8787
{
8888
return this.timelineWindow.paginate(direction, 10)
8989
}
90-
90+
9191
reloadEvents()
9292
{
9393
debug('reloading events')
@@ -97,6 +97,7 @@ class Timeline extends React.Component
9797
this.timelineWindow.canPaginate(sdk.EventTimeline.FORWARDS)
9898
? events
9999
: events.concat(this.props.timelineSet.getPendingEvents())
100+
debug('Timeline now:', timeline)
100101

101102
this.setState({ timeline })
102103
}
@@ -111,12 +112,12 @@ class Timeline extends React.Component
111112
{
112113
this.updateTimeline()
113114
}
114-
115+
115116
render()
116117
{
117118
const { timeline } = this.state
118119
const { matrix } = this.props
119-
120+
120121
return (
121122
<div>
122123
<button
@@ -126,7 +127,7 @@ class Timeline extends React.Component
126127
{ timeline.map(msg => {
127128
const sender = msg.getSender()
128129
const isMe = sender === matrix.getUserId()
129-
130+
130131
return (
131132
<div className='timeline__message'
132133
key={ msg.getId() }>
@@ -139,7 +140,7 @@ class Timeline extends React.Component
139140
</span>:
140141
</div>
141142
<div className='timeline__content'>
142-
{ msg.event.content.body }
143+
{ msg.getContent().body }
143144
</div>
144145
<div className='timeline__status'>
145146
{ msg.isSending() ? '[sending]' : '' }

0 commit comments

Comments
 (0)