fix(@desktop/onboarding): fetching waku data ui improvements
- icon added to the ui items we're syncing - in case data are fetched during 30 seconds timeframe the app is staying in success state
This commit is contained in:
parent
0cc64774af
commit
d7e4ee2395
|
@ -1,18 +1,23 @@
|
|||
type
|
||||
Item* = ref object
|
||||
entity: string
|
||||
icon: string
|
||||
trackOfLoadedMessages: seq[bool]
|
||||
totalMessages: int
|
||||
|
||||
proc newItem*(entity: string, totalMessages: int = 0): Item =
|
||||
proc newItem*(entity: string, icon: string, totalMessages: int = 0): Item =
|
||||
result = Item()
|
||||
result.entity = entity
|
||||
result.icon = icon
|
||||
result.trackOfLoadedMessages = @[]
|
||||
result.totalMessages = totalMessages
|
||||
|
||||
proc entity*(self: Item): string =
|
||||
return self.entity
|
||||
|
||||
proc icon*(self: Item): string =
|
||||
return self.icon
|
||||
|
||||
proc loadedMessages*(self: Item): int =
|
||||
if self.trackOfLoadedMessages.len == 0:
|
||||
return 0
|
||||
|
|
|
@ -5,6 +5,7 @@ import fetching_data_item
|
|||
type
|
||||
ModelRole {.pure.} = enum
|
||||
Entity = UserRole + 1
|
||||
Icon
|
||||
LoadedMessages
|
||||
TotalMessages
|
||||
|
||||
|
@ -39,6 +40,7 @@ QtObject:
|
|||
method roleNames(self: Model): Table[int, string] =
|
||||
{
|
||||
ModelRole.Entity.int:"entity",
|
||||
ModelRole.Icon.int:"icon",
|
||||
ModelRole.LoadedMessages.int:"loadedMessages",
|
||||
ModelRole.TotalMessages.int:"totalMessages"
|
||||
}.toTable
|
||||
|
@ -56,6 +58,8 @@ QtObject:
|
|||
case enumRole:
|
||||
of ModelRole.Entity:
|
||||
result = newQVariant(item.entity())
|
||||
of ModelRole.Icon:
|
||||
result = newQVariant(item.icon())
|
||||
of ModelRole.LoadedMessages:
|
||||
result = newQVariant(item.loadedMessages())
|
||||
of ModelRole.TotalMessages:
|
||||
|
@ -67,10 +71,10 @@ QtObject:
|
|||
return i
|
||||
return -1
|
||||
|
||||
proc init*(self: Model, entities: seq[string]) =
|
||||
proc init*(self: Model, entities: seq[tuple[entity: string, icon: string]]) =
|
||||
self.beginResetModel()
|
||||
for s in entities:
|
||||
self.items.add(newItem(s))
|
||||
for e in entities:
|
||||
self.items.add(newItem(e.entity, e.icon))
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
|
|
|
@ -23,9 +23,13 @@ logScope:
|
|||
topics = "startup-module"
|
||||
|
||||
const FetchingFromWakuProfile = "profile"
|
||||
const FetchingFromWakuProfileIcon = "profile"
|
||||
const FetchingFromWakuContacts = "contacts"
|
||||
const FetchingFromWakuContactsIcon = "contact-book"
|
||||
const FetchingFromWakuCommunities = "communities"
|
||||
const FetchingFromWakuCommunitiesIcon = "communities"
|
||||
const FetchingFromWakuSettings = "settings"
|
||||
const FetchingFromWakuSettingsIcon = "settings"
|
||||
|
||||
type
|
||||
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
||||
|
@ -319,8 +323,12 @@ method onFetchingFromWakuMessageReceived*[T](self: Module[T], section: string, t
|
|||
|
||||
proc prepareAndInitFetchingData[T](self: Module[T]) =
|
||||
# fetching data from waku starts when messenger starts
|
||||
const listOfEntitiesWeExpectToBeSynced = @[FetchingFromWakuProfile, FetchingFromWakuContacts, FetchingFromWakuCommunities,
|
||||
FetchingFromWakuSettings]
|
||||
const listOfEntitiesWeExpectToBeSynced = @[
|
||||
(FetchingFromWakuProfile, FetchingFromWakuProfileIcon),
|
||||
(FetchingFromWakuContacts, FetchingFromWakuContactsIcon),
|
||||
(FetchingFromWakuCommunities, FetchingFromWakuCommunitiesIcon),
|
||||
(FetchingFromWakuSettings, FetchingFromWakuSettingsIcon)
|
||||
]
|
||||
self.view.createAndInitFetchingDataModel(listOfEntitiesWeExpectToBeSynced)
|
||||
|
||||
proc delayStartingApp[T](self: Module[T]) =
|
||||
|
@ -331,11 +339,12 @@ proc delayStartingApp[T](self: Module[T]) =
|
|||
self.controller.connectToTimeoutEventAndStratTimer(timeoutInMilliseconds = 30000) # delay for 30 seconds
|
||||
|
||||
method startAppAfterDelay*[T](self: Module[T]) =
|
||||
let currStateObj = self.view.currentStartupStateObj()
|
||||
if currStateObj.isNil:
|
||||
error "cannot determine current startup state"
|
||||
quit() # quit the app
|
||||
self.view.setCurrentStartupState(newProfileFetchingState(currStateObj.flowType(), nil))
|
||||
if not self.view.fetchingDataModel().allMessagesLoaded():
|
||||
let currStateObj = self.view.currentStartupStateObj()
|
||||
if currStateObj.isNil:
|
||||
error "cannot determine current startup state"
|
||||
quit() # quit the app
|
||||
self.view.setCurrentStartupState(newProfileFetchingState(currStateObj.flowType(), nil))
|
||||
self.moveToStartupState()
|
||||
|
||||
proc logoutAndDisplayError[T](self: Module[T], error: string) =
|
||||
|
|
|
@ -291,7 +291,7 @@ QtObject:
|
|||
read = getFetchingDataModel
|
||||
notify = fetchingDataModelChanged
|
||||
|
||||
proc createAndInitFetchingDataModel*(self: View, sections: seq[string]) =
|
||||
proc createAndInitFetchingDataModel*(self: View, sections: seq[tuple[entity: string, icon: string]]) =
|
||||
if self.fetchingDataModel.isNil:
|
||||
self.fetchingDataModel = fetch_model.newModel()
|
||||
if self.fetchingDataModelVariant.isNil:
|
||||
|
|
Loading…
Reference in New Issue