mirror of
https://github.com/etkecc/synapse-admin.git
synced 2024-11-21 23:35:22 +03:00
Fix room state events display (#100)
* Fix room state events table display * update readme
This commit is contained in:
parent
865e53388e
commit
28ef08de03
4 changed files with 22 additions and 6 deletions
|
@ -71,6 +71,7 @@ The following changes are already implemented:
|
|||
* [Custom Menu Items](https://github.com/etkecc/synapse-admin/pull/79)
|
||||
* [Add user profile to the top menu](https://github.com/etkecc/synapse-admin/pull/80)
|
||||
* [Enable visual customization](https://github.com/etkecc/synapse-admin/pull/81)
|
||||
* [Fix room state events display](https://github.com/etkecc/synapse-admin/pull/100)
|
||||
|
||||
_the list will be updated as new changes are added_
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ export const RoomShow = (props: ShowProps) => {
|
|||
<Datagrid style={{ width: "100%" }} bulkActionButtons={false}>
|
||||
<TextField source="type" sortable={false} />
|
||||
<DateField source="origin_server_ts" showTime options={DATE_FORMAT} sortable={false} />
|
||||
<TextField source="content" sortable={false} />
|
||||
<FunctionField source="content" sortable={false} render={record => `${JSON.stringify(record.content, null, 2)}`} />
|
||||
<ReferenceField source="sender" reference="users" sortable={false}>
|
||||
<TextField source="id" />
|
||||
</ReferenceField>
|
||||
|
|
|
@ -75,7 +75,7 @@ const authProvider: AuthProvider = {
|
|||
|
||||
response = await fetchUtils.fetchJson(login_api_url, options);
|
||||
const json = response.json;
|
||||
storage.setItem("home_server", accessToken ? base_url : json.home_server);
|
||||
storage.setItem("home_server", accessToken ? json.user_id.split(":")[1] : json.home_server);
|
||||
storage.setItem("user_id", json.user_id);
|
||||
storage.setItem("access_token", accessToken ? accessToken : json.access_token);
|
||||
storage.setItem("device_id", json.device_id);
|
||||
|
|
|
@ -575,13 +575,28 @@ const baseDataProvider: SynapseDataProvider = {
|
|||
|
||||
getMany: async (resource, params) => {
|
||||
console.log("getMany " + resource);
|
||||
const homeserver = storage.getItem("base_url");
|
||||
if (!homeserver || !(resource in resourceMap)) throw Error("Homerserver not set");
|
||||
const base_url = storage.getItem("base_url");
|
||||
const homeserver = storage.getItem("home_server");
|
||||
if (!base_url || !(resource in resourceMap)) throw Error("base_url not set");
|
||||
|
||||
const res = resourceMap[resource];
|
||||
|
||||
const endpoint_url = homeserver + res.path;
|
||||
const responses = await Promise.all(params.ids.map(id => jsonClient(`${endpoint_url}/${encodeURIComponent(id)}`)));
|
||||
const endpoint_url = base_url + res.path;
|
||||
const responses = await Promise.all(params.ids.map(id => {
|
||||
// edge case: when user is external / federated, homeserver will return error, as querying external users via
|
||||
// /_synapse/admin/v2/users is not allowed.
|
||||
// That leads to an issue when a user is referenced (e.g., in room state datagrid) - the user cell is just empty.
|
||||
// To avoid that, we fake the response with one specific field (name) which is used in the datagrid.
|
||||
if (homeserver && resource === "users") {
|
||||
if (!(<string>id).endsWith(homeserver)) {
|
||||
const json = {
|
||||
name: id,
|
||||
};
|
||||
return Promise.resolve({ json });
|
||||
}
|
||||
}
|
||||
return jsonClient(`${endpoint_url}/${encodeURIComponent(id)}`);
|
||||
}));
|
||||
return {
|
||||
data: responses.map(({ json }) => res.map(json)),
|
||||
total: responses.length,
|
||||
|
|
Loading…
Reference in a new issue