Add banner that indicates history archive downloads are in progress
This needs: https://github.com/status-im/status-go/pull/2995
This commit is contained in:
parent
9ded9d4ffa
commit
d5db1e6356
|
@ -125,6 +125,11 @@ proc historyArchiveDownloadedFromEvent*(T: type HistoryArchivesSignal, event: Js
|
|||
result = HistoryArchivesSignal.createFromEvent(event)
|
||||
result.signalType = SignalType.HistoryArchiveDownloaded
|
||||
|
||||
proc downloadingHistoryArchivesStartedFromEvent*(T: type HistoryArchivesSignal, event: JsonNode): HistoryArchivesSignal =
|
||||
result = HistoryArchivesSignal()
|
||||
result.communityId = event["event"]{"communityId"}.getStr()
|
||||
result.signalType = SignalType.DownloadingHistoryArchivesStarted
|
||||
|
||||
proc downloadingHistoryArchivesFinishedFromEvent*(T: type HistoryArchivesSignal, event: JsonNode): HistoryArchivesSignal =
|
||||
result = HistoryArchivesSignal()
|
||||
result.communityId = event["event"]{"communityId"}.getStr()
|
||||
|
|
|
@ -39,6 +39,7 @@ type SignalType* {.pure.} = enum
|
|||
HistoryArchivesSeeding = "community.historyArchivesSeeding"
|
||||
HistoryArchivesUnseeded = "community.historyArchivesUnseeded"
|
||||
HistoryArchiveDownloaded = "community.historyArchiveDownloaded"
|
||||
DownloadingHistoryArchivesStarted = "community.downloadingHistoryArchivesStarted"
|
||||
DownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished"
|
||||
UpdateAvailable = "update.available"
|
||||
DiscordCategoriesAndChannelsExtracted = "community.discordCategoriesAndChannelsExtracted"
|
||||
|
|
|
@ -93,6 +93,7 @@ QtObject:
|
|||
of SignalType.HistoryArchivesSeeding: HistoryArchivesSignal.historyArchivesSeedingFromEvent(jsonSignal)
|
||||
of SignalType.HistoryArchivesUnseeded: HistoryArchivesSignal.historyArchivesUnseededFromEvent(jsonSignal)
|
||||
of SignalType.HistoryArchiveDownloaded: HistoryArchivesSignal.historyArchiveDownloadedFromEvent(jsonSignal)
|
||||
of SignalType.DownloadingHistoryArchivesStarted: HistoryArchivesSignal.downloadingHistoryArchivesStartedFromEvent(jsonSignal)
|
||||
of SignalType.DownloadingHistoryArchivesFinished: HistoryArchivesSignal.downloadingHistoryArchivesFinishedFromEvent(jsonSignal)
|
||||
of SignalType.UpdateAvailable: UpdateAvailableSignal.fromEvent(jsonSignal)
|
||||
of SignalType.DiscordCategoriesAndChannelsExtracted: DiscordCategoriesAndChannelsExtractedSignal.fromEvent(jsonSignal)
|
||||
|
|
|
@ -74,6 +74,14 @@ proc init*(self: Controller) =
|
|||
let args = DiscordImportProgressArgs(e)
|
||||
self.delegate.discordImportProgressUpdated(args.communityId, args.communityName, args.communityImage, args.tasks, args.progress, args.errorsCount, args.warningsCount, args.stopped)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_STARTED) do(e:Args):
|
||||
let args = CommunityIdArgs(e)
|
||||
self.delegate.communityHistoryArchivesDownloadStarted(args.communityId)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_FINISHED) do(e:Args):
|
||||
let args = CommunityIdArgs(e)
|
||||
self.delegate.communityHistoryArchivesDownloadFinished(args.communityId)
|
||||
|
||||
proc getCommunityTags*(self: Controller): string =
|
||||
result = self.communityService.getCommunityTags()
|
||||
|
||||
|
|
|
@ -136,3 +136,10 @@ method discordImportProgressUpdated*(self: AccessInterface, communityId: string,
|
|||
|
||||
method requestCancelDiscordCommunityImport*(self: AccessInterface, id: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityHistoryArchivesDownloadStarted*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityHistoryArchivesDownloadFinished*(self: AccessInterface, communityId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -252,6 +252,12 @@ method communityMuted*(self: Module, communityId: string, muted: bool) =
|
|||
method communityAccessRequested*(self: Module, communityId: string) =
|
||||
self.view.communityAccessRequested(communityId)
|
||||
|
||||
method communityHistoryArchivesDownloadStarted*(self: Module, communityId: string) =
|
||||
self.view.setDownloadingCommunityHistoryArchives(true)
|
||||
|
||||
method communityHistoryArchivesDownloadFinished*(self: Module, communityId: string) =
|
||||
self.view.setDownloadingCommunityHistoryArchives(false)
|
||||
|
||||
method discordCategoriesAndChannelsExtracted*(self: Module, categories: seq[DiscordCategoryDto], channels: seq[DiscordChannelDto], oldestMessageTimestamp: int, errors: Table[string, DiscordImportError], errorsCount: int) =
|
||||
|
||||
for filePath in errors.keys:
|
||||
|
|
|
@ -45,6 +45,7 @@ QtObject:
|
|||
discordImportCommunityName: string
|
||||
discordImportCommunityImage: string
|
||||
discordImportHasCommunityImage: bool
|
||||
downloadingCommunityHistoryArchives: bool
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.model.delete
|
||||
|
@ -89,6 +90,7 @@ QtObject:
|
|||
result.discordImportTasksModel = newDiscordDiscordImportTasksModel()
|
||||
result.discordImportTasksModelVariant = newQVariant(result.discordImportTasksModel)
|
||||
result.observedItem = newActiveSection()
|
||||
result.downloadingCommunityHistoryArchives = false
|
||||
|
||||
proc load*(self: View) =
|
||||
self.delegate.viewDidLoad()
|
||||
|
@ -114,6 +116,20 @@ QtObject:
|
|||
read = getDiscordOldestMessageTimestamp
|
||||
notify = discordOldestMessageTimestampChanged
|
||||
|
||||
proc downloadingCommunityHistoryArchivesChanged*(self: View) {.signal.}
|
||||
|
||||
proc setDownloadingCommunityHistoryArchives*(self: View, flag: bool) {.slot.} =
|
||||
if (self.downloadingCommunityHistoryArchives == flag): return
|
||||
self.downloadingCommunityHistoryArchives = flag
|
||||
self.downloadingCommunityHistoryArchivesChanged()
|
||||
|
||||
proc getDownloadingCommunityHistoryArchives*(self: View): bool {.slot.} =
|
||||
return self.downloadingCommunityHistoryArchives
|
||||
|
||||
QtProperty[bool] downloadingCommunityHistoryArchives:
|
||||
read = getDownloadingCommunityHistoryArchives
|
||||
notify = downloadingCommunityHistoryArchivesChanged
|
||||
|
||||
proc discordImportHasCommunityImageChanged*(self: View) {.signal.}
|
||||
|
||||
proc setDiscordImportHasCommunityImage*(self: View, hasImage: bool) {.slot.} =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, json, sequtils, std/algorithm, strformat, strutils, chronicles, json_serialization, sugar
|
||||
import NimQml, Tables, json, sequtils, std/sets, std/algorithm, strformat, strutils, chronicles, json_serialization, sugar
|
||||
|
||||
import ./dto/community as community_dto
|
||||
|
||||
|
@ -119,6 +119,8 @@ const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
|
|||
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
|
||||
const SIGNAL_CATEGORY_MUTED* = "categoryMuted"
|
||||
const SIGNAL_CATEGORY_UNMUTED* = "categoryUnmuted"
|
||||
const SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_STARTED* = "communityHistoryArchivesDownloadStarted"
|
||||
const SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_FINISHED* = "communityHistoryArchivesDownloadFinished"
|
||||
|
||||
const SIGNAL_DISCORD_CATEGORIES_AND_CHANNELS_EXTRACTED* = "discordCategoriesAndChannelsExtracted"
|
||||
const SIGNAL_DISCORD_COMMUNITY_IMPORT_FINISHED* = "discordCommunityImportFinished"
|
||||
|
@ -136,6 +138,7 @@ QtObject:
|
|||
curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity]
|
||||
allCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
|
||||
myCommunityRequests*: seq[CommunityMembershipRequestDto]
|
||||
historyArchiveDownloadTaskCommunityIds*: HashSet[string]
|
||||
|
||||
# Forward declaration
|
||||
proc loadCommunityTags(self: Service): string
|
||||
|
@ -172,6 +175,7 @@ QtObject:
|
|||
result.curatedCommunities = initTable[string, CuratedCommunity]()
|
||||
result.allCommunities = initTable[string, CommunityDto]()
|
||||
result.myCommunityRequests = @[]
|
||||
result.historyArchiveDownloadTaskCommunityIds = initHashSet[string]()
|
||||
|
||||
proc doConnect(self: Service) =
|
||||
self.events.on(SignalType.CommunityFound.event) do(e: Args):
|
||||
|
@ -250,6 +254,28 @@ QtObject:
|
|||
stopped: receivedData.stopped
|
||||
))
|
||||
|
||||
self.events.on(SignalType.DownloadingHistoryArchivesStarted.event) do(e: Args):
|
||||
var receivedData = HistoryArchivesSignal(e)
|
||||
if receivedData.communityId notin self.historyArchiveDownloadTaskCommunityIds:
|
||||
self.historyArchiveDownloadTaskCommunityIds.incl(receivedData.communityId)
|
||||
self.events.emit(SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_STARTED, CommunityIdArgs(communityId: receivedData.communityId))
|
||||
|
||||
self.events.on(SignalType.DownloadingHistoryArchivesFinished.event) do(e: Args):
|
||||
var receivedData = HistoryArchivesSignal(e)
|
||||
if receivedData.communityId in self.historyArchiveDownloadTaskCommunityIds:
|
||||
self.historyArchiveDownloadTaskCommunityIds.excl(receivedData.communityId)
|
||||
|
||||
if self.historyArchiveDownloadTaskCommunityIds.len == 0:
|
||||
# Right now we're only emitting this signal when all download tasks have been marked as finished
|
||||
# so passing the `CommunityIdArgs` is not very useful because it'll always emit the latest community
|
||||
# id that has finished. We'll handle signals related to individual communities in the future
|
||||
# once we've figured out what this should look like in the UI
|
||||
#
|
||||
# TODO(pascal):
|
||||
# Don't just emit this signal when all communities are done downloading history data,
|
||||
# but implement a solution for individual updates
|
||||
self.events.emit(SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_FINISHED, CommunityIdArgs(communityId: receivedData.communityId))
|
||||
|
||||
proc updateMissingFields(chatDto: var ChatDto, chat: ChatDto) =
|
||||
# This proc sets fields of `chatDto` which are available only for community channels.
|
||||
chatDto.position = chat.position
|
||||
|
|
|
@ -24,6 +24,7 @@ QtObject {
|
|||
property url discordImportCommunityImage: root.communitiesModuleInst.discordImportCommunityImage
|
||||
property bool discordImportHasCommunityImage: root.communitiesModuleInst.discordImportHasCommunityImage
|
||||
property var discordImportTasks: root.communitiesModuleInst.discordImportTasks
|
||||
property bool downloadingCommunityHistoryArchives: root.communitiesModuleInst.downloadingCommunityHistoryArchives
|
||||
property string locale: localAppSettings.language
|
||||
property var advancedModule: profileSectionModule.advancedModule
|
||||
|
||||
|
|
|
@ -653,6 +653,15 @@ Item {
|
|||
}
|
||||
|
||||
|
||||
ModuleWarning {
|
||||
id: downloadingArchivesBanner
|
||||
Layout.fillWidth: true
|
||||
active: communitiesPortalLayoutContainer.communitiesStore.downloadingCommunityHistoryArchives
|
||||
type: ModuleWarning.Danger
|
||||
text: qsTr("Downloading message history archives, DO NOT CLOSE THE APP until this banner disappears.")
|
||||
closeBtnVisible: false
|
||||
}
|
||||
|
||||
Component {
|
||||
id: connectedBannerComponent
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4c29c97591f5a68cb6c8f63290db8d1f1b778398
|
||||
Subproject commit 194f26f3b4503494702be4e8148a166f61730c4d
|
Loading…
Reference in New Issue