forked from matrix/element-web
Fix bug where rooms missing m.room.pinned_events could not pin messages
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
f7389b70aa
commit
965a25ba84
|
@ -134,7 +134,13 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onPinClick: function() {
|
onPinClick: function() {
|
||||||
MatrixClientPeg.get().getStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', '').then(event => {
|
MatrixClientPeg.get().getStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', '')
|
||||||
|
.then(null, e => {
|
||||||
|
// Intercept the Event Not Found error and fall through the promise chain with no event.
|
||||||
|
if (e.errcode === "M_NOT_FOUND") return null;
|
||||||
|
throw e;
|
||||||
|
})
|
||||||
|
.then(event => {
|
||||||
const eventIds = (event ? event.pinned : []) || [];
|
const eventIds = (event ? event.pinned : []) || [];
|
||||||
if (!eventIds.includes(this.props.mxEvent.getId())) {
|
if (!eventIds.includes(this.props.mxEvent.getId())) {
|
||||||
// Not pinned - add
|
// Not pinned - add
|
||||||
|
|
Loading…
Reference in New Issue