0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 21:38:18 +02:00

client: Update room summary related; may break synapse compat; possibly issue with IRCd /state/ response.

This commit is contained in:
Jason Volk 2017-11-30 10:45:09 -08:00
parent 7c4659e089
commit 1cbd0ab8ba
3 changed files with 14 additions and 13 deletions

View file

@ -39,8 +39,12 @@ mc.room = class
if(maybe(() => summary.room_id.endsWith(":localhost")))
this.opts.local = true;
if(!Array.isArray(summary))
this.id = summary.room_id;
else
this.id = summary[0].room_id;
// Identity
this.id = summary.room_id;
this.sid = mc.m.sid(this.id);
this.uri = encodeURIComponent(this.id);
@ -78,7 +82,10 @@ mc.room = class
this.sync = Function.bindtree(room.sync, this);
// Generate some initial pseudo-state from the summary data.
this.timeline.insert(room.state.summary.parse(summary));
if(!Array.isArray(summary))
this.timeline.insert(room.state.summary.parse(summary));
else
this.timeline.insert(summary);
}
get summary()

View file

@ -158,8 +158,8 @@ mc.rooms.get = function(summary, opts = {})
{
let room_id = typeswitch(summary,
{
"object": summary.room_id,
"string": summary,
"object": () => Array.isArray(summary)? summary[0].room_id : summary.room_id,
});
let room = mc.rooms[room_id];
@ -168,10 +168,5 @@ mc.rooms.get = function(summary, opts = {})
// Ensures the summary is valid when the argument
// to this function is just a quick room_id string.
summary = typeof(summary) == "object"? summary:
{
room_id: room_id,
};
return mc.rooms.create.room(summary, opts);
};

View file

@ -127,7 +127,7 @@ mc.rooms.search.commit = async function(value)
return;
let handler = mc.rooms.search.by[type];
if(!handler)
if(typeof(handler) != "function")
return;
if(mc.rooms.search.request)
@ -152,8 +152,7 @@ mc.rooms.search.by.id = async function(room_id)
let event_id = room_id.split(' ')[1];
room_id = room_id.split(' ')[0];
let summary = await mc.rooms.search.by.state(room_id, undefined, undefined, event_id);
return [mc.rooms.get(summary)];
return [await mc.rooms.search.by.state(room_id, undefined, undefined, event_id)];
};
mc.rooms.search.by.alias = async function(alias)
@ -164,8 +163,8 @@ mc.rooms.search.by.alias = async function(alias)
if(!Array.isArray(summary.aliases))
summary.aliases = [];
summary.aliases.push(alias);
summary.aliases.push(alias);
return [mc.rooms.get(summary)];
}
catch(error)
@ -195,7 +194,7 @@ mc.rooms.search.by.state = async function(room_id, type = undefined, state_key =
mc.rooms.search.request = mc.m.rooms.state.get(room_id, type, state_key, opts); try
{
let summary = await mc.rooms.search.request.response;
return [mc.rooms.get(summary)];
return mc.rooms.get(summary);
}
catch(error)
{