feat: emit signals on saving profile showcase preferences

Close #13968
This commit is contained in:
MishkaRogachev 2024-03-14 12:42:48 +01:00 committed by Noelia
parent 3a3c3204fa
commit 8a5164db68
6 changed files with 48 additions and 1 deletions

View File

@ -58,6 +58,12 @@ proc init*(self: Controller) =
let args = SocialLinksArgs(e)
self.delegate.onSocialLinksUpdated(args.socialLinks, args.error)
self.events.on(SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_SUCCEEDED) do(e: Args):
self.delegate.onProfileShowcasePreferencesSaveSucceeded()
self.events.on(SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_FAILED) do(e: Args):
self.delegate.onProfileShowcasePreferencesSaveFailed()
self.events.on(SIGNAL_PROFILE_SHOWCASE_PREFERENCES_UPDATED) do(e: Args):
let args = ProfileShowcasePreferencesArgs(e)
self.delegate.updateProfileShowcasePreferences(args.preferences)

View File

@ -49,6 +49,12 @@ method saveSocialLinks*(self: AccessInterface) {.base.} =
method onSocialLinksUpdated*(self: AccessInterface, socialLinks: SocialLinks, error: string) {.base.} =
raise newException(ValueError, "No implementation available")
method onProfileShowcasePreferencesSaveSucceeded*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onProfileShowcasePreferencesSaveFailed*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method saveProfileIdentityInfo*(self: AccessInterface, identity: IdentitySaveData) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -112,6 +112,12 @@ method onSocialLinksUpdated*(self: Module, socialLinks: SocialLinks, error: stri
return
self.updateSocialLinks(socialLinks)
method onProfileShowcasePreferencesSaveSucceeded*(self: Module) =
self.view.emitProfileShowcasePreferencesSaveSucceededSignal()
method onProfileShowcasePreferencesSaveFailed*(self: Module) =
self.view.emitProfileShowcasePreferencesSaveFailedSignal()
method getProfileShowcaseSocialLinksLimit*(self: Module): int =
return self.controller.getProfileShowcaseSocialLinksLimit()

View File

@ -197,6 +197,14 @@ QtObject:
proc emitBioChangedSignal*(self: View) =
self.bioChanged()
proc profileShowcasePreferencesSaveSucceeded*(self: View) {.signal.}
proc emitProfileShowcasePreferencesSaveSucceededSignal*(self: View) =
self.profileShowcasePreferencesSaveSucceeded()
proc profileShowcasePreferencesSaveFailed*(self: View) {.signal.}
proc emitProfileShowcasePreferencesSaveFailedSignal*(self: View) =
self.profileShowcasePreferencesSaveFailed()
# TODO: remove old models
proc getCollectiblesModel(self: View): QVariant {.slot.} =
return self.delegate.getCollectiblesModel()

View File

@ -27,9 +27,13 @@ type
# Signals which may be emitted by this service:
const SIGNAL_PROFILE_SHOWCASE_PREFERENCES_UPDATED* = "profileShowcasePreferencesUpdated"
const SIGNAL_PROFILE_SHOWCASE_FOR_CONTACT_UPDATED* = "profileShowcaseForContactUpdated"
const SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_SUCCEEDED* = "profileShowcasePreferencesSaveSucceeded"
const SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_FAILED* = "profileShowcasePreferencesSaveFailed"
const SIGNAL_PROFILE_SHOWCASE_ACCOUNTS_BY_ADDRESS_FETCHED* = "profileShowcaseAccountsByAddressFetched"
# TODO: move to contacts service
const SIGNAL_PROFILE_SHOWCASE_FOR_CONTACT_UPDATED* = "profileShowcaseForContactUpdated"
QtObject:
type Service* = ref object of QObject
threadpool: ThreadPool
@ -192,7 +196,10 @@ QtObject:
let rpcResponseObj = rpcResponse.parseJson
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
error "Error saving profile showcase preferences", msg = rpcResponseObj{"error"}
self.events.emit(SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_FAILED, Args())
return
self.events.emit(SIGNAL_PROFILE_SHOWCASE_PREFERENCES_SAVE_SUCCEEDED, Args())
self.requestProfileShowcasePreferences()
except Exception as e:
error "Error saving profile showcase preferences", msg = e.msg

View File

@ -102,6 +102,20 @@ QtObject {
root.profileModule.setIsFirstShowcaseInteraction()
}
signal profileShowcasePreferencesSaveSucceeded()
signal profileShowcasePreferencesSaveFailed()
readonly property Connections profileModuleConnections: Connections {
target: root.profileModule
function onProfileShowcasePreferencesSaveSucceeded() {
root.profileShowcasePreferencesSaveSucceeded()
}
function onProfileShowcasePreferencesSaveFailed() {
root.profileShowcasePreferencesSaveFailed()
}
}
// Social links related: All to be removed: Deprecated --> Issue #13688
function containsSocialLink(text, url) {
return root.profileModule.containsSocialLink(text, url)