Skip to content

Commit 549d992

Browse files
committed
API change: Make EventTiles which hold stuff common to all events that appear in a room timeline.
1 parent d4a5ab1 commit 549d992

3 files changed

Lines changed: 36 additions & 23 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var MatrixClientPeg = require("../../MatrixClientPeg");
20+
21+
module.exports = {
22+
shouldHighlight: function() {
23+
var actions = MatrixClientPeg.get().getPushActionsForEvent(this.props.mxEvent);
24+
if (!actions || !actions.tweaks) { return false; }
25+
return actions.tweaks.highlight;
26+
}
27+
};
28+

‎src/controllers/molecules/MessageTile.js‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,5 @@ limitations under the License.
1919
var MatrixClientPeg = require("../../MatrixClientPeg");
2020

2121
module.exports = {
22-
shouldHighlight: function() {
23-
var actions = MatrixClientPeg.get().getPushActionsForEvent(this.props.mxEvent);
24-
if (!actions || !actions.tweaks) { return false; }
25-
return actions.tweaks.highlight;
26-
},
27-
28-
getInitialState: function() {
29-
return {
30-
resending: false
31-
};
32-
}
3322
};
3423

‎src/controllers/organisms/RoomView.js‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,18 @@ module.exports = {
316316
},
317317

318318
getEventTiles: function() {
319-
var tileTypes = {
320-
'm.room.message': sdk.getComponent('molecules.MessageTile'),
321-
'm.room.member' : sdk.getComponent('molecules.EventAsTextTile'),
322-
'm.call.invite' : sdk.getComponent('molecules.EventAsTextTile'),
323-
'm.call.answer' : sdk.getComponent('molecules.EventAsTextTile'),
324-
'm.call.hangup' : sdk.getComponent('molecules.EventAsTextTile'),
325-
'm.room.topic' : sdk.getComponent('molecules.EventAsTextTile'),
326-
};
327-
328319
var ret = [];
329320
var count = 0;
330321

322+
var EventTile = sdk.getComponent('molecules.EventTile');
323+
331324
for (var i = this.state.room.timeline.length-1; i >= 0 && count < this.state.messageCap; --i) {
332325
var mxEv = this.state.room.timeline[i];
333-
var TileType = tileTypes[mxEv.getType()];
326+
327+
if (!EventTile.supportsEventType(mxEv.getType())) {
328+
continue;
329+
}
330+
334331
var continuation = false;
335332
var last = false;
336333
if (i == this.state.room.timeline.length - 1) {
@@ -348,9 +345,8 @@ module.exports = {
348345
continuation = true;
349346
}
350347
}
351-
if (!TileType) continue;
352348
ret.unshift(
353-
<li key={mxEv.getId()}><TileType mxEvent={mxEv} continuation={continuation} last={last}/></li>
349+
<li key={mxEv.getId()}><EventTile mxEvent={mxEv} continuation={continuation} last={last}/></li>
354350
);
355351
++count;
356352
}

0 commit comments

Comments
 (0)