feat(communities): add community images to import progress signal

This is needed so clients can render the selected community image
while the import is running.
This commit is contained in:
Pascal Precht 2022-11-04 14:56:13 +01:00 committed by r4bbit.eth
parent 4bf5fcfe61
commit d216840db8
2 changed files with 18 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/status-im/status-go/images"
"github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/protocol/protobuf"
) )
@ -149,14 +150,15 @@ type ImportTaskProgress struct {
type ImportTasks map[ImportTask]*ImportTaskProgress type ImportTasks map[ImportTask]*ImportTaskProgress
type ImportProgress struct { type ImportProgress struct {
CommunityID string `json:"communityId,omitempty"` CommunityID string `json:"communityId,omitempty"`
CommunityName string `json:"communityName"` CommunityName string `json:"communityName"`
Tasks []*ImportTaskProgress `json:"tasks"` CommunityImages map[string]images.IdentityImage `json:"communityImages"`
Progress float32 `json:"progress"` Tasks []*ImportTaskProgress `json:"tasks"`
ErrorsCount uint `json:"errorsCount"` Progress float32 `json:"progress"`
WarningsCount uint `json:"warningsCount"` ErrorsCount uint `json:"errorsCount"`
Stopped bool `json:"stopped"` WarningsCount uint `json:"warningsCount"`
m sync.Mutex Stopped bool `json:"stopped"`
m sync.Mutex
} }
func (progress *ImportProgress) Init(tasks []ImportTask) { func (progress *ImportProgress) Init(tasks []ImportTask) {

View File

@ -23,6 +23,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/images"
"github.com/status-im/status-go/multiaccounts/accounts" "github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/communities" "github.com/status-im/status-go/protocol/communities"
@ -2221,6 +2222,13 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
// marking import as not cancelled // marking import as not cancelled
m.importingCommunities[communityID] = false m.importingCommunities[communityID] = false
importProgress.CommunityID = communityID importProgress.CommunityID = communityID
importProgress.CommunityImages = make(map[string]images.IdentityImage)
imgs := discordCommunity.Images()
for t, i := range imgs {
importProgress.CommunityImages[t] = images.IdentityImage{Name: t, Payload: i.Payload}
}
importProgress.UpdateTaskProgress(discord.CommunityCreationTask, 0.75) importProgress.UpdateTaskProgress(discord.CommunityCreationTask, 0.75)
progressUpdates <- importProgress progressUpdates <- importProgress