@wtfalch/chat 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/dist/chat/client.js +509 -20
- package/dist/chat/fake/server.d.ts +61 -0
- package/dist/chat/fake/server.js +249 -15
- package/dist/chat/types.d.ts +228 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,47 @@ the person reaches the newest message. `chat.connectionStatus()` (and
|
|
|
60
60
|
`onConnectionStatusChanged`) is `'connected'`, `'catching-up'` or
|
|
61
61
|
`'offline'`, for a status the UI can render.
|
|
62
62
|
|
|
63
|
+
**Mute** ([#5](https://github.com/wtfalch/chat/issues/5)).
|
|
64
|
+
`chat.muteRoom(roomId, muted)` writes (or, unmuting, removes) a room-scoped
|
|
65
|
+
push rule carrying the `dont_notify` action, through matrix-js-sdk's own
|
|
66
|
+
`setRoomMutePushRule` -- scoped `'global'`, so muting mutes every device
|
|
67
|
+
signed into the account, not just this one. `room.muted` is what a list
|
|
68
|
+
dims. Muting only ever changes that: `unreadCount` keeps climbing regardless,
|
|
69
|
+
because a muted room stops notifying and nothing else.
|
|
70
|
+
|
|
71
|
+
**Presence and typing** ([#7](https://github.com/wtfalch/chat/issues/7)).
|
|
72
|
+
Both are ephemeral and both are Matrix-native, which is why they are one
|
|
73
|
+
ticket: `chat.presence(userId)` reads someone's `m.presence` as `'online'`,
|
|
74
|
+
`'busy'`, `'away'` or `'offline'`, and `chat.onPresenceChanged(listener)`
|
|
75
|
+
hears about it changing. `chat.sendTyping(roomId, typing)` sends `m.typing`;
|
|
76
|
+
`chat.onTypingChanged(roomId, listener)` hears who else is typing in a room.
|
|
77
|
+
`@wtfalch/design`'s `Presence` and `Typing` components draw whatever these
|
|
78
|
+
return.
|
|
79
|
+
|
|
80
|
+
**Presence is off in production.** Every company's Synapse is generated by
|
|
81
|
+
`bootstrap/steps/chat-instance.ts:142` in `wtfalch/app-template`, which
|
|
82
|
+
still hardcodes it off, tracked at that project's
|
|
83
|
+
[#352](https://github.com/wtfalch/app-template/issues/352). Until that
|
|
84
|
+
lands, `presence()` reports `'offline'` for everyone, always -- not because
|
|
85
|
+
nobody is online, but because Synapse never says. The test stack turns it
|
|
86
|
+
on, so the integration suite proves all four states against a real server.
|
|
87
|
+
`sendTyping` and `onTypingChanged` are unaffected and work today.
|
|
88
|
+
|
|
89
|
+
**Announcing idleness** ([#20](https://github.com/wtfalch/chat/issues/20)).
|
|
90
|
+
`chat.announcePresence('away' | 'online')` is the only way `'away'` ever
|
|
91
|
+
happens. Left alone a syncing client re-asserts `'online'` on every poll,
|
|
92
|
+
so a tab open overnight reads as available until morning. The SDK cannot
|
|
93
|
+
judge this for itself -- a cron job calling `timeline()` looks exactly like
|
|
94
|
+
a person reading -- so the app calls it from what it alone can see: the
|
|
95
|
+
Page Visibility API, a locked screen, real keystrokes.
|
|
96
|
+
|
|
97
|
+
It changes the `set_presence` the sync itself carries, not only the
|
|
98
|
+
`PUT .../presence/status` that Synapse's next sync would undo, and it is
|
|
99
|
+
re-applied across this client's own restarts. `sendTyping`, by contrast,
|
|
100
|
+
is a single call and not a heartbeat -- Matrix auto-expires a typing state
|
|
101
|
+
after its own timeout, so a composer that wants "typing" to keep showing
|
|
102
|
+
through a long pause has to call this again itself on further keystrokes.
|
|
103
|
+
|
|
63
104
|
**Direct messages** ([#16](https://github.com/wtfalch/messaging/issues/16)).
|
|
64
105
|
`chat.people()` is everyone in the company space but the signed-in person --
|
|
65
106
|
the space is where a company's membership lives, and a guest is never in it,
|
|
@@ -145,6 +186,24 @@ from anybody but the original sender, and the default power levels let a
|
|
|
145
186
|
member redact their own event and nobody else's. Moderating other people's
|
|
146
187
|
messages is the manage app's, later.
|
|
147
188
|
|
|
189
|
+
**Pinned messages** ([#8](https://github.com/wtfalch/chat/issues/8)).
|
|
190
|
+
`chat.pinMessage(roomId, eventId)` and `chat.unpinMessage(roomId, eventId)` add
|
|
191
|
+
to and take from Matrix's own `m.room.pinned_events` state, one list the whole
|
|
192
|
+
room shares; `chat.pinnedMessages(roomId)` reads it back, each pinned id
|
|
193
|
+
reduced the same way `timeline()` reduces a message, in the order the state
|
|
194
|
+
lists them.
|
|
195
|
+
|
|
196
|
+
Ordinary members can call these
|
|
197
|
+
([wtfalch/agora#255](https://github.com/wtfalch/agora/issues/255) overrides
|
|
198
|
+
the chat plan's "nobody but `@chat-admin` ... pins", for pinning only):
|
|
199
|
+
`apps/chat-service`'s `powerLevels()` grants `m.room.pinned_events` its own
|
|
200
|
+
power level, 0. That reaches only a room created after the change lands --
|
|
201
|
+
an existing room's power levels are never backfilled, so a member's pin in an
|
|
202
|
+
older channel still fails. `pinMessage` **rejects** rather than resolving
|
|
203
|
+
quietly when that happens: a silently-ignored pin reads as "the button does
|
|
204
|
+
nothing," and this package would rather a caller catch a real error than
|
|
205
|
+
draw a pin that never took.
|
|
206
|
+
|
|
148
207
|
**Redacted text does leave the database, but not at once.** A redaction
|
|
149
208
|
empties the event for every client immediately; Synapse replaces its own
|
|
150
209
|
stored copy with the redacted form after `redaction_retention_period`, which
|
|
@@ -241,6 +300,18 @@ homeserver token and a media id may retrieve that file without membership in the
|
|
|
241
300
|
room where it was posted. Deleting the message removes its visible reference;
|
|
242
301
|
it does not delete the stored media. No malware scanning or file search is included.
|
|
243
302
|
|
|
303
|
+
**Every file in a room** ([#9](https://github.com/wtfalch/chat/issues/9)).
|
|
304
|
+
`chat.roomFiles(roomId, { limit, before })` lists a room's files without paging
|
|
305
|
+
its timeline: `GET .../messages` takes Matrix's own `contains_url` filter, and
|
|
306
|
+
Synapse answers with only file-bearing events no matter how much plain
|
|
307
|
+
conversation sits between them, confirmed live against this package's own test
|
|
308
|
+
Synapse. `limit` stops once that many are collected; omitted, this walks pages
|
|
309
|
+
until Synapse says there is nothing older. `before` continues where a walk left
|
|
310
|
+
off -- Synapse's own opaque `/messages` token, not an event id; `roomFiles`
|
|
311
|
+
does not hand one back yet, so there is no way to obtain one from this package
|
|
312
|
+
alone. It returns `ChatAttachment`s, the same shape `event.attachment` already
|
|
313
|
+
carries, and bytes still only ever come through `loadMedia`.
|
|
314
|
+
|
|
244
315
|
## First-ship local proof
|
|
245
316
|
|
|
246
317
|
See [the browser/Electron fixture](test/acceptance/README.md) for the repeatable
|