feat(community)_: send signals about member reevaluation in progress (#5120)

Needed for https://github.com/status-im/status-desktop/issues/14378
This commit is contained in:
Jonathan Rainville 2024-05-08 15:55:30 -04:00 committed by GitHub
parent a97f1bb681
commit 5f4aab3121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -1227,7 +1227,15 @@ func (m *Manager) DeleteCommunityTokenPermission(request *requests.DeleteCommuni
}
func (m *Manager) reevaluateCommunityMembersPermissions(communityID types.HexBytes) error {
// Publish when the reevluation started since it can take a while
signal.SendCommunityMemberReevaluationStarted(types.EncodeHex(communityID))
community, newPrivilegedMembers, err := m.ReevaluateMembers(communityID)
// Publish the reevaluation ending, even if it errored
// A possible improvement would be to pass the error here
signal.SendCommunityMemberReevaluationEnded(types.EncodeHex(communityID))
if err != nil {
return err
}

View File

@ -0,0 +1,26 @@
package signal
const (
MemberReevaluationStatus = "community.memberReevaluationStatus"
)
type ReevaluationStatus uint
const (
None ReevaluationStatus = iota
InProgress
Done
)
type CommunityMemberReevaluationSignal struct {
CommunityID string `json:"communityId"`
Status ReevaluationStatus `json:"status"`
}
func SendCommunityMemberReevaluationStarted(communityID string) {
send(MemberReevaluationStatus, CommunityMemberReevaluationSignal{CommunityID: communityID, Status: InProgress})
}
func SendCommunityMemberReevaluationEnded(communityID string) {
send(MemberReevaluationStatus, CommunityMemberReevaluationSignal{CommunityID: communityID, Status: Done})
}