Compare commits
3 Commits
ab49c32148
...
78d657111b
| Author | SHA1 | Date | |
|---|---|---|---|
| 78d657111b | |||
|
|
096fb2b207 | ||
|
|
737686006e |
@@ -1036,7 +1036,7 @@ Return the current user's session state.
|
|||||||
|
|
||||||
| Parameter | Type | Default | Description |
|
| Parameter | Type | Default | Description |
|
||||||
|-----------|--------|---------|-------------|
|
|-----------|--------|---------|-------------|
|
||||||
| `initChannelState` | string | (none) | When set to `1`, enqueues synthetic JOIN + TOPIC + NAMES messages for every channel the session belongs to into the calling client's queue. Used by the SPA on reconnect to restore channel tabs without re-sending JOIN commands. |
|
| `initChannelState` | string | (none) | When set to `1`, enqueues synthetic JOIN + TOPIC + NAMES messages for every channel the session belongs to into the calling client's queue. Used by the SPA on reconnect to restore channel tabs without re-sending JOIN commands. |
|
||||||
|
|
||||||
**Response:** `200 OK`
|
**Response:** `200 OK`
|
||||||
```json
|
```json
|
||||||
@@ -1070,7 +1070,7 @@ curl -s http://localhost:8080/api/v1/state \
|
|||||||
-H "Authorization: Bearer $TOKEN" | jq .
|
-H "Authorization: Bearer $TOKEN" | jq .
|
||||||
```
|
```
|
||||||
|
|
||||||
**Reconnect with channel state init:**
|
**Reconnect with channel state initialization:**
|
||||||
```bash
|
```bash
|
||||||
curl -s "http://localhost:8080/api/v1/state?initChannelState=1" \
|
curl -s "http://localhost:8080/api/v1/state?initChannelState=1" \
|
||||||
-H "Authorization: Bearer $TOKEN" | jq .
|
-H "Authorization: Bearer $TOKEN" | jq .
|
||||||
|
|||||||
@@ -445,10 +445,10 @@ func (hdlr *Handlers) enqueueNumeric(
|
|||||||
|
|
||||||
// HandleState returns the current session's info and
|
// HandleState returns the current session's info and
|
||||||
// channels. When called with ?initChannelState=1, it also
|
// channels. When called with ?initChannelState=1, it also
|
||||||
// enqueues synthetic JOIN + TOPIC + NAMES messages for every
|
// enqueues synthetic JOIN + TOPIC + NAMES messages for
|
||||||
// channel the session belongs to so that a reconnecting
|
// every channel the session belongs to so that a
|
||||||
// client can rebuild its channel tabs from the message
|
// reconnecting client can rebuild its channel tabs from
|
||||||
// stream.
|
// the message stream.
|
||||||
func (hdlr *Handlers) HandleState() http.HandlerFunc {
|
func (hdlr *Handlers) HandleState() http.HandlerFunc {
|
||||||
return func(
|
return func(
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ func (hdlr *Handlers) handleLogin(
|
|||||||
request, clientID, sessionID, payload.Nick,
|
request, clientID, sessionID, payload.Nick,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init channel state so the new client knows which
|
// Initialize channel state so the new client knows
|
||||||
// channels the session already belongs to.
|
// which channels the session already belongs to.
|
||||||
hdlr.initChannelState(
|
hdlr.initChannelState(
|
||||||
request, clientID, sessionID, payload.Nick,
|
request, clientID, sessionID, payload.Nick,
|
||||||
)
|
)
|
||||||
|
|||||||
4
web/dist/app.js
vendored
4
web/dist/app.js
vendored
File diff suppressed because one or more lines are too long
@@ -335,7 +335,7 @@ function App() {
|
|||||||
if (msg.to) addMessage(msg.to, { ...base, text, system: true });
|
if (msg.to) addMessage(msg.to, { ...base, text, system: true });
|
||||||
if (msg.to && msg.to.startsWith("#")) {
|
if (msg.to && msg.to.startsWith("#")) {
|
||||||
// Create a tab when the current user joins a channel
|
// Create a tab when the current user joins a channel
|
||||||
// (including initial JOINs on reconnect).
|
// (including JOINs from initChannelState on reconnect).
|
||||||
if (msg.from === nickRef.current) {
|
if (msg.from === nickRef.current) {
|
||||||
setTabs((prev) => {
|
setTabs((prev) => {
|
||||||
if (
|
if (
|
||||||
@@ -656,9 +656,10 @@ function App() {
|
|||||||
if (isResumed) {
|
if (isResumed) {
|
||||||
// Request MOTD on resumed sessions (new sessions
|
// Request MOTD on resumed sessions (new sessions
|
||||||
// get it automatically from the server during
|
// get it automatically from the server during
|
||||||
// creation). Channel state is initialised by the
|
// creation). Channel state is initialized by the
|
||||||
// server via the message queue (?initChannelState=1), so we
|
// server via the message queue
|
||||||
// do not need to re-JOIN channels here.
|
// (?initChannelState=1), so we do not need to
|
||||||
|
// re-JOIN channels here.
|
||||||
try {
|
try {
|
||||||
await api("/messages", {
|
await api("/messages", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
Reference in New Issue
Block a user