mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
client: Update room summary related; may break synapse compat; possibly issue with IRCd /state/ response.
This commit is contained in:
parent
7c4659e089
commit
1cbd0ab8ba
3 changed files with 14 additions and 13 deletions
|
@ -39,8 +39,12 @@ mc.room = class
|
||||||
if(maybe(() => summary.room_id.endsWith(":localhost")))
|
if(maybe(() => summary.room_id.endsWith(":localhost")))
|
||||||
this.opts.local = true;
|
this.opts.local = true;
|
||||||
|
|
||||||
|
if(!Array.isArray(summary))
|
||||||
|
this.id = summary.room_id;
|
||||||
|
else
|
||||||
|
this.id = summary[0].room_id;
|
||||||
|
|
||||||
// Identity
|
// Identity
|
||||||
this.id = summary.room_id;
|
|
||||||
this.sid = mc.m.sid(this.id);
|
this.sid = mc.m.sid(this.id);
|
||||||
this.uri = encodeURIComponent(this.id);
|
this.uri = encodeURIComponent(this.id);
|
||||||
|
|
||||||
|
@ -78,7 +82,10 @@ mc.room = class
|
||||||
this.sync = Function.bindtree(room.sync, this);
|
this.sync = Function.bindtree(room.sync, this);
|
||||||
|
|
||||||
// Generate some initial pseudo-state from the summary data.
|
// 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()
|
get summary()
|
||||||
|
|
|
@ -158,8 +158,8 @@ mc.rooms.get = function(summary, opts = {})
|
||||||
{
|
{
|
||||||
let room_id = typeswitch(summary,
|
let room_id = typeswitch(summary,
|
||||||
{
|
{
|
||||||
"object": summary.room_id,
|
|
||||||
"string": summary,
|
"string": summary,
|
||||||
|
"object": () => Array.isArray(summary)? summary[0].room_id : summary.room_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
let room = mc.rooms[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
|
// Ensures the summary is valid when the argument
|
||||||
// to this function is just a quick room_id string.
|
// 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);
|
return mc.rooms.create.room(summary, opts);
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@ mc.rooms.search.commit = async function(value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let handler = mc.rooms.search.by[type];
|
let handler = mc.rooms.search.by[type];
|
||||||
if(!handler)
|
if(typeof(handler) != "function")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(mc.rooms.search.request)
|
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];
|
let event_id = room_id.split(' ')[1];
|
||||||
room_id = room_id.split(' ')[0];
|
room_id = room_id.split(' ')[0];
|
||||||
|
|
||||||
let summary = await mc.rooms.search.by.state(room_id, undefined, undefined, event_id);
|
return [await mc.rooms.search.by.state(room_id, undefined, undefined, event_id)];
|
||||||
return [mc.rooms.get(summary)];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mc.rooms.search.by.alias = async function(alias)
|
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))
|
if(!Array.isArray(summary.aliases))
|
||||||
summary.aliases = [];
|
summary.aliases = [];
|
||||||
summary.aliases.push(alias);
|
|
||||||
|
|
||||||
|
summary.aliases.push(alias);
|
||||||
return [mc.rooms.get(summary)];
|
return [mc.rooms.get(summary)];
|
||||||
}
|
}
|
||||||
catch(error)
|
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
|
mc.rooms.search.request = mc.m.rooms.state.get(room_id, type, state_key, opts); try
|
||||||
{
|
{
|
||||||
let summary = await mc.rooms.search.request.response;
|
let summary = await mc.rooms.search.request.response;
|
||||||
return [mc.rooms.get(summary)];
|
return mc.rooms.get(summary);
|
||||||
}
|
}
|
||||||
catch(error)
|
catch(error)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue