feat: add signal to inform clients when all archives have been downloaded and handled

This adds a new `DownloadingHistoryArchivesFinished` signal to the
family of community archive signals. It's emitted when all to be
downloaded archives have been downloaded and handled.
This commit is contained in:
Pascal Precht 2022-09-15 09:59:02 +02:00 committed by r4bbit.eth
parent 11e432d341
commit fd4488e504
5 changed files with 28 additions and 8 deletions

View File

@ -116,6 +116,7 @@ type Subscription struct {
HistoryArchivesSeedingSignal *signal.HistoryArchivesSeedingSignal
HistoryArchivesUnseededSignal *signal.HistoryArchivesUnseededSignal
HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal
DownloadingHistoryArchivesFinishedSignal *signal.DownloadingHistoryArchivesFinishedSignal
}
type CommunityResponse struct {

View File

@ -45,6 +45,7 @@ type MessengerSignalsHandler interface {
HistoryArchivesSeeding(communityID string)
HistoryArchivesUnseeded(communityID string)
HistoryArchiveDownloaded(communityID string, from int, to int)
DownloadingHistoryArchivesFinished(communityID string)
StatusUpdatesTimedOut(statusUpdates *[]UserStatus)
DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError)
}

View File

@ -949,6 +949,7 @@ func (m *Messenger) HandleHistoryArchiveMagnetlinkMessage(state *ReceivedMessage
signal.SendNewMessages(response)
localnotifications.PushMessages(notifications)
}
m.config.messengerSignalsHandler.DownloadingHistoryArchivesFinished(types.EncodeHex(id))
}()
return m.communitiesManager.UpdateMagnetlinkMessageClock(id, clock)

View File

@ -120,6 +120,10 @@ func (m *MessengerSignalsHandler) HistoryArchiveDownloaded(communityID string, f
signal.SendHistoryArchiveDownloaded(communityID, from, to)
}
func (m *MessengerSignalsHandler) DownloadingHistoryArchivesFinished(communityID string) {
signal.SendDownloadingHistoryArchivesFinished(communityID)
}
func (m *MessengerSignalsHandler) StatusUpdatesTimedOut(statusUpdates *[]protocol.UserStatus) {
signal.SendStatusUpdatesTimedOut(statusUpdates)
}

View File

@ -27,6 +27,9 @@ const (
// EventHistoryArchiveDownloaded is triggered when the community member node
// has downloaded an individual community archive
EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded"
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
// has downloaded all archives
EventDownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished"
)
type CreatingHistoryArchivesSignal struct {
@ -59,6 +62,10 @@ type HistoryArchiveDownloadedSignal struct {
To int `json:"to"`
}
type DownloadingHistoryArchivesFinishedSignal struct {
CommunityID string `json:"communityId"`
}
func SendHistoryArchivesProtocolEnabled() {
send(EventHistoryArchivesProtocolEnabled, nil)
}
@ -102,3 +109,9 @@ func SendHistoryArchiveDownloaded(communityID string, from int, to int) {
To: to,
})
}
func SendDownloadingHistoryArchivesFinished(communityID string) {
send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{
CommunityID: communityID,
})
}