make sure messages aren't sent to unsynced channels

This commit is contained in:
emerson 2022-01-24 18:45:34 -05:00
parent d701496130
commit 79a1228544
3 changed files with 8 additions and 3 deletions

View file

@ -35,7 +35,7 @@ That said, it is usable for basic chatting.
| Channel lists/searching | ⬜ | ❌ ||
| Encrypted rooms | ❌ | ⬜ ||
| Rich text | ❌ | ❌ ||
| Presence | ❌ | ❌ ||
| Presence | ❌ | ❌ | Note that not all homeservers have presence enabled |
| Channel renaming <small>(IRCv3)</small> | 🟨 | ❌ | Only when the canonical alias changes |
| Message replies <small>(IRCv3)</small> | ✅ | ✅ | Clients without support will still receive the reply message, but it won't be marked as a reply |
| Message reactions <small>(IRCv3)</small> | 🟨 | 🟨 | Can't undo reactions yet |

View file

@ -30,6 +30,10 @@ export class Channel {
this.initialSyncID = setInterval(this.checkChannelSync.bind(this), 2000);
}
isSynced() {
return this.syncLocks.size === 0;
}
doInitialSync() {
this.syncLocks.add("m.room.canonical_alias");
axios.get(`https://${this.ircUser.homeserver}/_matrix/client/v3/rooms/${this.roomId}/event/m.room.canonical_alias?access_token=${this.ircUser.accessToken}`).then(response => {
@ -69,7 +73,7 @@ export class Channel {
}
checkChannelSync() {
if (this.syncLocks.size === 0) {
if (this.isSynced()) {
if (this.matrixUsers.size === 2 && this.name === this.roomId) {
const otherUser = [...this.matrixUsers.values()].filter(m => m.nick !== this.ircUser.nick);
this.name = `&${otherUser[0].mxid.substring(1)}`

View file

@ -151,6 +151,7 @@ export class IRCUser {
for (const roomId of Object.keys(rooms.join)) {
const targetChannel = this.getOrCreateIRCChannel(roomId);
rooms.join[roomId].timeline.events.forEach((nextEvent: any) => {
if (targetChannel.isSynced())
this.routeMatrixEvent(nextEvent, targetChannel);
});
}