Skip to content

Commit

Permalink
Added explicit types to prevent confusion on type dec collision
Browse files Browse the repository at this point in the history
Also a little tidy up
  • Loading branch information
Samyoul committed Feb 18, 2021
1 parent 7b0751c commit a748542
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
26 changes: 15 additions & 11 deletions multiaccounts/accounts/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ const (
uniqueWalletConstraint = "UNIQUE constraint failed: accounts.wallet"
)

type ProfilePicturesVisibilityType int

const (
ProfilePicturesVisibilityContactsOnly = iota + 1
ProfilePicturesVisibilityContactsOnly ProfilePicturesVisibilityType = iota + 1
ProfilePicturesVisibilityEveryone
ProfilePicturesVisibilityNone
)

type ProfilePicturesShowToType int

const (
ProfilePicturesShowToContactsOnly = iota + 1
ProfilePicturesShowToContactsOnly ProfilePicturesShowToType = iota + 1
ProfilePicturesShowToEveryone
ProfilePicturesShowToNone
)
Expand Down Expand Up @@ -112,16 +116,16 @@ type Settings struct {
SendPushNotifications bool `json:"send-push-notifications?,omitempty"`
Appearance uint `json:"appearance"`
// ProfilePicturesShowTo indicates to whom the user shows their profile picture to (contacts, everyone)
ProfilePicturesShowTo uint `json:"profile-pictures-show-to"`
ProfilePicturesShowTo ProfilePicturesShowToType `json:"profile-pictures-show-to"`
// ProfilePicturesVisibility indicates who we want to see profile pictures of (contacts, everyone or none)
ProfilePicturesVisibility uint `json:"profile-pictures-visibility"`
UseMailservers bool `json:"use-mailservers?"`
Usernames *json.RawMessage `json:"usernames,omitempty"`
WalletRootAddress types.Address `json:"wallet-root-address,omitempty"`
WalletSetUpPassed bool `json:"wallet-set-up-passed?,omitempty"`
WalletVisibleTokens *json.RawMessage `json:"wallet/visible-tokens,omitempty"`
WakuBloomFilterMode bool `json:"waku-bloom-filter-mode,omitempty"`
WebViewAllowPermissionRequests bool `json:"webview-allow-permission-requests?,omitempty"`
ProfilePicturesVisibility ProfilePicturesVisibilityType `json:"profile-pictures-visibility"`
UseMailservers bool `json:"use-mailservers?"`
Usernames *json.RawMessage `json:"usernames,omitempty"`
WalletRootAddress types.Address `json:"wallet-root-address,omitempty"`
WalletSetUpPassed bool `json:"wallet-set-up-passed?,omitempty"`
WalletVisibleTokens *json.RawMessage `json:"wallet/visible-tokens,omitempty"`
WakuBloomFilterMode bool `json:"waku-bloom-filter-mode,omitempty"`
WebViewAllowPermissionRequests bool `json:"webview-allow-permission-requests?,omitempty"`
}

func NewDB(db *sql.DB) *Database {
Expand Down
6 changes: 0 additions & 6 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,6 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci *
return err
}

if s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityContactsOnly {
m.logger.Info("settings.ProfilePicturesVisibility is there")
}

// TODO check that all the migration code is in place use ProfilePicturesVisibility as a guide
// getting an error of no such column: profile_pictures_show_to
if s.ProfilePicturesShowTo == accounts.ProfilePicturesShowToNone {
m.logger.Info(fmt.Sprintf("settings.ProfilePicturesShowTo is set to '%d', skipping attaching IdentityImages", s.ProfilePicturesShowTo))
return nil
Expand Down

0 comments on commit a748542

Please sign in to comment.