Skip to content

Commit

Permalink
fix: store color in db
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Jan 19, 2024
1 parent 1e1ae57 commit 04da0b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion protocol/messenger_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ func (r *MessengerResponse) IsEmpty() bool {
len(r.ensUsernameDetails) == 0 &&
r.currentStatus == nil &&
r.activityCenterState == nil &&
r.SocialLinksInfo == nil
r.SocialLinksInfo == nil &&
r.CustomizationColor == ""
}

// Merge takes another response and appends the new Chats & new Messages and replaces
Expand Down
15 changes: 13 additions & 2 deletions protocol/messenger_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@ func (m *Messenger) SetCustomNodes(request *requests.SetCustomNodes) error {
}

func (m *Messenger) SetCustomizationColor(ctx context.Context, request *requests.SetCustomizationColor) error {
updatedAt := timesource.GetCurrentTimeInMillis()

acc, err := m.multiAccounts.GetAccount(request.KeyUID)
if err != nil {
return err
}

acc.CustomizationColor = request.CustomizationColor
acc.CustomizationColorClock = updatedAt

tNow := timesource.GetCurrentTimeInMillis()
if acc.CustomizationColorClock >= tNow {
acc.CustomizationColorClock++
} else {
acc.CustomizationColorClock = tNow
}

err = m.multiAccounts.UpdateAccountCustomizationColor(request.KeyUID, string(acc.CustomizationColor), acc.CustomizationColorClock)
if err != nil {
return err
}
err = m.syncAccountCustomizationColor(ctx, acc)
if err != nil {
return err
Expand Down

0 comments on commit 04da0b0

Please sign in to comment.