mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Display canonical alias if no room name is set; display errors on UI
This commit is contained in:
parent
02003cb31e
commit
852d3b4ae0
@ -15,6 +15,12 @@ $ ./syncv3 -server "https://matrix-client.matrix.org" -db "user=$(whoami) dbname
|
||||
|
||||
Then visit http://localhost:8008/client/ (with trailing slash) and paste in the `access_token` for any account on `-server`.
|
||||
|
||||
When you hit the Sync button nothing will happen initially, but you should see:
|
||||
```
|
||||
INF Poller: v2 poll loop started ip=::1 since= user_id=@kegan:matrix.org
|
||||
```
|
||||
Wait for the first initial v2 sync to be processed (this can take minutes!) and then v3 APIs will be responsive.
|
||||
|
||||
## API
|
||||
|
||||
API is under active development and is not stable.
|
||||
|
@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<title>Sync v3 experiments</title>
|
||||
<script>
|
||||
let lastError = null;
|
||||
let activeAbortController = new AbortController();
|
||||
let activeSessionId;
|
||||
let activeRanges = [[0,20]];
|
||||
@ -140,6 +141,7 @@
|
||||
const doSyncLoop = async(accessToken, sessionId) => {
|
||||
console.log("Starting sync loop. Active: ", activeSessionId, " this:", sessionId);
|
||||
let currentPos;
|
||||
let currentError = null;
|
||||
while (sessionId === activeSessionId) {
|
||||
let resp;
|
||||
try {
|
||||
@ -154,6 +156,12 @@
|
||||
} catch (err) {
|
||||
if (err.name !== "AbortError") {
|
||||
console.error("/sync failed:",err);
|
||||
console.log("current", currentError, "last", lastError);
|
||||
if (currentError != lastError) {
|
||||
console.log("set!");
|
||||
document.getElementById("errorMsg").textContent = lastError ? lastError : "";
|
||||
}
|
||||
currentError = lastError;
|
||||
await sleep(1000);
|
||||
}
|
||||
}
|
||||
@ -236,6 +244,13 @@
|
||||
if (respBody.ops) {
|
||||
console.log(respBody);
|
||||
}
|
||||
if (resp.status != 200) {
|
||||
if (respBody.error) {
|
||||
lastError = respBody.error;
|
||||
}
|
||||
throw new Error("/sync returned HTTP " + resp.status + " " + respBody.error);
|
||||
}
|
||||
lastError = null;
|
||||
return respBody;
|
||||
}
|
||||
|
||||
@ -285,6 +300,7 @@
|
||||
<input id="accessToken" type="password" placeholder="matrix.org access token" />
|
||||
<input id="syncButton" type="button" value="Sync" />
|
||||
<input id="resetButton" type="button" value="New Session" />
|
||||
<span id="errorMsg"></span>
|
||||
<div id="listContainer" style="background: #f7f7f7;" ></div>
|
||||
<template id="roomCellTemplate">
|
||||
<div style="padding: 5px; display: flex; align-items: center; cursor: pointer; border-bottom: 1px solid #8d99a5; height: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
||||
|
@ -218,7 +218,9 @@ func (m *ConnMap) onNewEvent(
|
||||
}
|
||||
}
|
||||
if eventType == "m.room.name" && stateKey != nil && *stateKey == "" {
|
||||
globalRoom.Name = gjson.ParseBytes(event).Get("content.name").Str
|
||||
globalRoom.Name = ev.Get("content.name").Str
|
||||
} else if eventType == "m.room.canonical_alias" && stateKey != nil && *stateKey == "" && globalRoom.Name == "" {
|
||||
globalRoom.Name = ev.Get("content.alias").Str
|
||||
}
|
||||
eventTimestamp := ev.Get("origin_server_ts").Int()
|
||||
globalRoom.LastMessageTimestamp = eventTimestamp
|
||||
|
Loading…
x
Reference in New Issue
Block a user