@@ 365,54 365,55 @@ func (app *App) sync() chan func() {
}
})
- onEvent := func(t event.Type, h mautrix.EventHandler) {
- syncer.OnEventType(t, func(src mautrix.EventSource, ev *event.Event) {
+ hook := func(t event.Type, f func(ev *event.Event)) {
+ syncer.OnEventType(t, func(_ mautrix.EventSource, ev *event.Event) {
updates <- func() {
- h(src, ev)
+ f(ev)
}
})
}
- onEvent(event.StateEncryption, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateEncryption, func(ev *event.Event) {
app.refreshRoomDetails(ev.RoomID)
})
- onEvent(event.StateCanonicalAlias, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateCanonicalAlias, func(ev *event.Event) {
app.refreshRoomDetails(ev.RoomID)
})
- onEvent(event.StateCreate, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateCreate, func(ev *event.Event) {
app.refreshRoomSoul(ev.RoomID)
})
- onEvent(event.StateHistoryVisibility, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateHistoryVisibility, func(ev *event.Event) {
app.refreshRoomDetails(ev.RoomID)
})
- onEvent(event.StateJoinRules, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateJoinRules, func(ev *event.Event) {
+ app.refreshRoomDetails(ev.RoomID)
})
- onEvent(event.StateMember, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateMember, func(ev *event.Event) {
if ev.Sender == app.Client.UserID {
app.refreshRoomSoul(ev.RoomID)
}
app.AddMessage(eventMessage(ev))
})
- onEvent(event.StateRoomName, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateRoomName, func(ev *event.Event) {
app.refreshRoomName(ev.RoomID)
})
- onEvent(event.StateTopic, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.StateTopic, func(ev *event.Event) {
app.refreshRoomDetails(ev.RoomID)
})
- onEvent(event.EventEncrypted, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.EventEncrypted, func(ev *event.Event) {
app.AddMessage(encryptedMessage(ev))
})
- onEvent(event.EventMessage, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.EventMessage, func(ev *event.Event) {
app.AddMessage(normalMessage(ev))
})
- onEvent(event.AccountDataDirectChats, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.AccountDataDirectChats, func(ev *event.Event) {
app.storeDirectChats(ev.Content.AsDirectChats())
app.refreshRoomSoul(ev.RoomID)
})
- onEvent(event.EphemeralEventReceipt, func(src mautrix.EventSource, ev *event.Event) {
+ hook(event.EphemeralEventReceipt, func(ev *event.Event) {
c := ev.Content.AsReceipt()
for eid, receipts := range *c {
if userReceipts, ok := receipts[event.ReceiptTypeRead]; ok {