Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
407233757e
2 changed files with 14 additions and 9 deletions
|
@ -47,7 +47,8 @@ module.exports = React.createClass({
|
||||||
const index = pinned.indexOf(this.props.mxEvent.getId());
|
const index = pinned.indexOf(this.props.mxEvent.getId());
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
pinned.splice(index, 1);
|
pinned.splice(index, 1);
|
||||||
MatrixClientPeg.get().sendStateEvent(this.props.mxRoom.roomId, 'm.room.pinned_events', {pinned}, '').then(() => {
|
MatrixClientPeg.get().sendStateEvent(this.props.mxRoom.roomId, 'm.room.pinned_events', {pinned}, '')
|
||||||
|
.then(() => {
|
||||||
if (this.props.onUnpinned) this.props.onUnpinned();
|
if (this.props.onUnpinned) this.props.onUnpinned();
|
||||||
});
|
});
|
||||||
} else if (this.props.onUnpinned) this.props.onUnpinned();
|
} else if (this.props.onUnpinned) this.props.onUnpinned();
|
||||||
|
|
|
@ -47,20 +47,21 @@ module.exports = React.createClass({
|
||||||
const promises = [];
|
const promises = [];
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
pinnedEvents.getContent().pinned.map(eventId => {
|
pinnedEvents.getContent().pinned.map((eventId) => {
|
||||||
promises.push(cli.getEventTimeline(this.props.room.getUnfilteredTimelineSet(), eventId, 0).then(timeline => {
|
promises.push(cli.getEventTimeline(this.props.room.getUnfilteredTimelineSet(), eventId, 0).then(
|
||||||
const event = timeline.getEvents().find(e => e.getId() === eventId);
|
(timeline) => {
|
||||||
|
const event = timeline.getEvents().find((e) => e.getId() === eventId);
|
||||||
return {eventId, timeline, event};
|
return {eventId, timeline, event};
|
||||||
}).catch(err => {
|
}).catch((err) => {
|
||||||
console.error("Error looking up pinned event " + eventId + " in room " + this.props.room.roomId);
|
console.error("Error looking up pinned event " + eventId + " in room " + this.props.room.roomId);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return null; // return lack of context to avoid unhandled errors
|
return null; // return lack of context to avoid unhandled errors
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(promises).then(contexts => {
|
Promise.all(promises).then((contexts) => {
|
||||||
// Filter out the messages before we try to render them
|
// Filter out the messages before we try to render them
|
||||||
const pinned = contexts.filter(context => {
|
const pinned = contexts.filter((context) => {
|
||||||
if (!context) return false; // no context == not applicable for the room
|
if (!context) return false; // no context == not applicable for the room
|
||||||
if (context.event.getType() !== "m.room.message") return false;
|
if (context.event.getType() !== "m.room.message") return false;
|
||||||
if (context.event.isRedacted()) return false;
|
if (context.event.isRedacted()) return false;
|
||||||
|
@ -77,8 +78,11 @@ module.exports = React.createClass({
|
||||||
return (<div>{ _t("No pinned messages.") }</div>);
|
return (<div>{ _t("No pinned messages.") }</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.state.pinned.map(context => {
|
return this.state.pinned.map((context) => {
|
||||||
return (<PinnedEventTile key={context.event.getId()} mxRoom={this.props.room} mxEvent={context.event} onUnpinned={this._updatePinnedMessages} />);
|
return (<PinnedEventTile key={context.event.getId()}
|
||||||
|
mxRoom={this.props.room}
|
||||||
|
mxEvent={context.event}
|
||||||
|
onUnpinned={this._updatePinnedMessages} />);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue