refactor(settings): make calling settings_getSocialLinks only once
Fixes #8549 That status-go call was done A LOT because we try to access our own data often and we didn't use to cache it.
This commit is contained in:
parent
d60a4b0c97
commit
a94750fb2d
|
@ -39,6 +39,11 @@ QtObject:
|
|||
type Service* = ref object of QObject
|
||||
events: EventEmitter
|
||||
settings: SettingsDto
|
||||
socialLinks: SocialLinks
|
||||
|
||||
# Forward declaration
|
||||
proc fetchSocialLinks*(self: Service): SocialLinks
|
||||
|
||||
|
||||
proc delete*(self: Service) =
|
||||
self.QObject.delete
|
||||
|
@ -52,6 +57,8 @@ QtObject:
|
|||
try:
|
||||
let response = status_settings.getSettings()
|
||||
self.settings = response.result.toSettingsDto()
|
||||
|
||||
self.socialLinks = self.fetchSocialLinks()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "error: ", errDesription
|
||||
|
@ -819,7 +826,11 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "error setting bio", errDesription = e.msg
|
||||
|
||||
|
||||
proc getSocialLinks*(self: Service): SocialLinks =
|
||||
return self.socialLinks
|
||||
|
||||
proc fetchSocialLinks*(self: Service): SocialLinks =
|
||||
try:
|
||||
let response = status_settings.getSocialLinks()
|
||||
|
||||
|
@ -843,6 +854,8 @@ QtObject:
|
|||
if(not response.error.isNil):
|
||||
error "error setting social links", errDescription = response.error.message
|
||||
|
||||
self.socialLinks = self.fetchSocialLinks()
|
||||
|
||||
result = true
|
||||
except Exception as e:
|
||||
error "error setting social links", errDesription = e.msg
|
||||
|
|
Loading…
Reference in New Issue