Skip to content

Commit

Permalink
Default to a room version of 1 when there is no room create event
Browse files Browse the repository at this point in the history
Fixes element-hq/element-web#7331

There is something to be worried about when there is no room create event, however. This should always be available, although due to cache problems or servers that don't provide the event we can't be sure of this.
  • Loading branch information
turt2live authored and krombel committed Nov 6, 2018
1 parent 002151a commit 196861f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ utils.inherits(Room, EventEmitter);
*/
Room.prototype.getVersion = function() {
const createEvent = this.currentState.getStateEvents("m.room.create", "");
if (!createEvent) return null;
if (!createEvent) {
console.warn("Room " + this.room_id + " does not have an m.room.create event");
return '1';
}
const ver = createEvent.getContent()['room_version'];
if (ver === undefined) return '1';
return ver;
Expand Down

0 comments on commit 196861f

Please sign in to comment.