chore(Profile): remove old social links code (#14899)

Close #13938
This commit is contained in:
Mikhail Rogachev 2024-05-24 12:21:42 +02:00 committed by GitHub
parent 2958a03c2c
commit bc580a1ff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 2 additions and 453 deletions

View File

@ -2,7 +2,6 @@ import json, chronicles, tables
import base
import ../../../../app_service/common/social_links
import ../../../../app_service/service/message/dto/[message, pinned_message_update, reaction, removed_message]
import ../../../../app_service/service/chat/dto/[chat]
import ../../../../app_service/service/bookmarks/dto/[bookmark]
@ -32,7 +31,6 @@ type MessageSignal* = ref object of Signal
removedChats*: seq[string]
currentStatus*: seq[StatusUpdateDto]
settings*: seq[SettingsFieldDto]
socialLinksInfo*: SocialLinksInfo
clearedHistories*: seq[ClearedHistoryDto]
verificationRequests*: seq[VerificationRequest]
savedAddresses*: seq[SavedAddressDto]
@ -143,9 +141,6 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
for jsonSettingsField in e["settings"]:
signal.settings.add(jsonSettingsField.toSettingsFieldDto())
if e.contains("socialLinksInfo"):
signal.socialLinksInfo = toSocialLinksInfo(e["socialLinksInfo"])
if e.contains("verificationRequests"):
for jsonVerificationRequest in e["verificationRequests"]:
signal.verificationRequests.add(jsonVerificationRequest.toVerificationRequest())

View File

@ -68,7 +68,6 @@ import ../../../app_service/service/shared_urls/service as urls_service
import ../../../app_service/service/network_connection/service as network_connection_service
import ../../../app_service/service/visual_identity/service as procs_from_visual_identity_service
import ../../../app_service/common/types
import ../../../app_service/common/social_links
import ../../../app_service/common/utils as common_utils
import app_service/service/network/network_item
@ -1160,7 +1159,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string, getVerifi
"contactRequestState": contactDetails.dto.contactRequestState.int,
"verificationStatus": contactDetails.dto.verificationStatus.int,
"incomingVerificationStatus": requestStatus,
"socialLinks": $contactDetails.dto.socialLinks.toJsonNode(),
"bio": contactDetails.dto.bio,
"onlineStatus": onlineStatus.int
}

View File

@ -7,7 +7,6 @@ import app_service/service/settings/service as settings_service
import app_service/service/community/service as community_service
import app_service/service/wallet_account/service as wallet_account_service
import app_service/service/token/service as token_service
import app_service/common/social_links
import app_service/common/types
import app_service/service/profile/dto/profile_showcase_preferences
@ -43,16 +42,10 @@ proc delete*(self: Controller) =
discard
proc init*(self: Controller) =
self.settingsService.fetchAndStoreSocialLinks()
self.events.on(SIGNAL_BIO_UPDATED) do(e: Args):
let args = SettingsTextValueArgs(e)
self.delegate.onBioChanged(args.value)
self.events.on(SIGNAL_SOCIAL_LINKS_UPDATED) do(e: Args):
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()
@ -72,9 +65,6 @@ proc deleteIdentityImage*(self: Controller, address: string): bool =
proc setDisplayName*(self: Controller, displayName: string): bool =
self.profileService.setDisplayName(displayName)
proc getSocialLinks*(self: Controller): SocialLinks =
self.settingsService.getSocialLinks()
proc getCommunityById*(self: Controller, id: string): CommunityDto =
self.communityService.getCommunityById(id)
@ -84,9 +74,6 @@ proc getAccountByAddress*(self: Controller, address: string): WalletAccountDto =
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
self.walletAccountService.getWalletAccounts(true)
proc setSocialLinks*(self: Controller, links: SocialLinks) =
self.settingsService.setSocialLinks(links)
proc getBio*(self: Controller): string =
self.settingsService.getBio()

View File

@ -1,6 +1,5 @@
import NimQml
import app_service/common/social_links
import app_service/service/profile/dto/profile_showcase_preferences
import models/profile_save_data
@ -33,12 +32,6 @@ method onBioChanged*(self: AccessInterface, bio: string) {.base.} =
method setDisplayName*(self: AccessInterface, displayName: string) {.base.} =
raise newException(ValueError, "No implementation available")
method saveSocialLinks*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
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")

View File

@ -1,4 +1,4 @@
import NimQml, chronicles, sequtils, sugar, strutils
import NimQml, chronicles, strutils
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
@ -11,10 +11,6 @@ import app_service/service/community/service as community_service
import app_service/service/wallet_account/service as wallet_account_service
import app_service/service/profile/dto/profile_showcase_preferences
import app_service/service/token/service as token_service
import app_service/common/social_links
import app/modules/shared_models/social_links_model
import app/modules/shared_models/social_link_item
import models/showcase_preferences_generic_model
import models/showcase_preferences_social_links_model
@ -63,12 +59,7 @@ method isLoaded*(self: Module): bool =
method getModuleAsVariant*(self: Module): QVariant =
return self.viewVariant
proc updateSocialLinks(self: Module, socialLinks: SocialLinks) =
var socialLinkItems = toSocialLinkItems(socialLinks)
self.view.socialLinksSaved(socialLinkItems)
method viewDidLoad*(self: Module) =
self.updateSocialLinks(self.controller.getSocialLinks())
self.moduleLoaded = true
self.delegate.profileModuleDidLoad()
@ -78,16 +69,6 @@ method getBio(self: Module): string =
method onBioChanged*(self: Module, bio: string) =
self.view.emitBioChangedSignal()
method saveSocialLinks*(self: Module) =
let socialLinks = map(self.view.temporarySocialLinksModel.items(), x => SocialLink(text: x.text, url: x.url, icon: x.icon))
self.controller.setSocialLinks(socialLinks)
method onSocialLinksUpdated*(self: Module, socialLinks: SocialLinks, error: string) =
if error.len > 0:
# maybe we want in future popup or somehow display an error to a user
return
self.updateSocialLinks(socialLinks)
method onProfileShowcasePreferencesSaveSucceeded*(self: Module) =
self.view.emitProfileShowcasePreferencesSaveSucceededSignal()

View File

@ -1,8 +1,6 @@
import NimQml, json, sequtils
import io_interface
import app/modules/shared_models/social_links_model
import app/modules/shared_models/social_link_item
import models/profile_save_data
import models/showcase_preferences_generic_model
@ -12,12 +10,6 @@ QtObject:
type
View* = ref object of QObject
delegate: io_interface.AccessInterface
# TODO: remove old models
socialLinksModel: SocialLinksModel
socialLinksModelVariant: QVariant
temporarySocialLinksModel: SocialLinksModel # used for editing purposes
temporarySocialLinksModelVariant: QVariant
showcasePreferencesCommunitiesModel: ShowcasePreferencesGenericModel
showcasePreferencesCommunitiesModelVariant: QVariant
showcasePreferencesAccountsModel: ShowcasePreferencesGenericModel
@ -30,12 +22,6 @@ QtObject:
showcasePreferencesSocialLinksModelVariant: QVariant
proc delete*(self: View) =
# TODO: remove old models
self.socialLinksModel.delete
self.socialLinksModelVariant.delete
self.temporarySocialLinksModel.delete
self.temporarySocialLinksModelVariant.delete
self.showcasePreferencesCommunitiesModel.delete
self.showcasePreferencesCommunitiesModelVariant.delete
self.showcasePreferencesAccountsModel.delete
@ -52,12 +38,6 @@ QtObject:
new(result, delete)
result.QObject.setup
result.delegate = delegate
# TODO: remove old models
result.socialLinksModel = newSocialLinksModel()
result.socialLinksModelVariant = newQVariant(result.socialLinksModel)
result.temporarySocialLinksModel = newSocialLinksModel()
result.temporarySocialLinksModelVariant = newQVariant(result.temporarySocialLinksModel)
result.showcasePreferencesCommunitiesModel = newShowcasePreferencesGenericModel()
result.showcasePreferencesCommunitiesModelVariant = newQVariant(result.showcasePreferencesCommunitiesModel)
result.showcasePreferencesAccountsModel = newShowcasePreferencesGenericModel()
@ -72,87 +52,6 @@ QtObject:
proc load*(self: View) =
self.delegate.viewDidLoad()
proc socialLinksModel*(self: View): SocialLinksModel =
return self.socialLinksModel
proc getSocialLinksModel(self: View): QVariant {.slot.} =
return self.socialLinksModelVariant
QtProperty[QVariant] socialLinksModel:
read = getSocialLinksModel
proc temporarySocialLinksModel*(self: View): SocialLinksModel =
return self.temporarySocialLinksModel
proc getTemporarySocialLinksModel(self: View): QVariant {.slot.} =
return self.temporarySocialLinksModelVariant
QtProperty[QVariant] temporarySocialLinksModel:
read = getTemporarySocialLinksModel
proc socialLinksDirtyChanged*(self: View) {.signal.}
proc areSocialLinksDirty(self: View): bool {.slot.} =
self.socialLinksModel.items != self.temporarySocialLinksModel.items
proc socialLinksJsonChanged*(self: View) {.signal.}
proc getSocialLinksJson(self: View): string {.slot.} =
$(%*self.socialLinksModel.items)
proc temporarySocialLinksJsonChanged*(self: View) {.signal.}
proc getTemporarySocialLinksJson(self: View): string {.slot.} =
$(%*self.temporarySocialLinksModel.items)
QtProperty[string] socialLinksJson:
read = getSocialLinksJson
notify = socialLinksJsonChanged
QtProperty[string] temporarySocialLinksJson:
read = getTemporarySocialLinksJson
notify = temporarySocialLinksJsonChanged
QtProperty[bool] socialLinksDirty:
read = areSocialLinksDirty
notify = socialLinksDirtyChanged
proc containsSocialLink*(self: View, text: string, url: string): bool {.slot.} =
return self.temporarySocialLinksModel.containsSocialLink(text, url)
proc createLink(self: View, text: string, url: string, linkType: int, icon: string) {.slot.} =
self.temporarySocialLinksModel.appendItem(initSocialLinkItem(text, url, (LinkType)linkType, icon))
self.temporarySocialLinksJsonChanged()
self.socialLinksDirtyChanged()
proc removeLink(self: View, uuid: string) {.slot.} =
if (self.temporarySocialLinksModel.removeItem(uuid)):
self.temporarySocialLinksJsonChanged()
self.socialLinksDirtyChanged()
proc updateLink(self: View, uuid: string, text: string, url: string) {.slot.} =
if (self.temporarySocialLinksModel.updateItem(uuid, text, url)):
self.temporarySocialLinksJsonChanged()
self.socialLinksDirtyChanged()
proc moveLink(self: View, fromRow: int, toRow: int) {.slot.} =
discard self.temporarySocialLinksModel.moveItem(fromRow, toRow)
proc resetSocialLinks(self: View) {.slot.} =
if (self.areSocialLinksDirty()):
self.temporarySocialLinksModel.setItems(self.socialLinksModel.items)
self.socialLinksDirtyChanged()
self.temporarySocialLinksJsonChanged()
proc socialLinksSaved*(self: View, items: seq[SocialLinkItem]) =
self.socialLinksModel.setItems(items)
self.temporarySocialLinksModel.setItems(items)
self.socialLinksJsonChanged()
self.temporarySocialLinksJsonChanged()
proc saveSocialLinks(self: View, silent: bool = false) {.slot.} =
self.delegate.saveSocialLinks()
if not silent:
self.socialLinksDirtyChanged()
proc bioChanged*(self: View) {.signal.}
proc getBio(self: View): string {.slot.} =
self.delegate.getBio()

View File

@ -1,32 +0,0 @@
import uuids
type
LinkType* {.pure.} = enum
Custom,
Twitter,
PersonalSite,
Github,
Youtube,
Discord,
Telegram
SocialLinkItem* = object
uuid: string
text*: string
url*: string
linkType: LinkType
icon*: string
proc initSocialLinkItem*(text, url: string, linkType: LinkType, icon: string = ""): SocialLinkItem =
result = SocialLinkItem()
result.uuid = $genUUID()
result.text = text
result.url = url
result.linkType = linkType
result.icon = icon
proc uuid*(self: SocialLinkItem): string {.inline.} =
self.uuid
proc linkType*(self: SocialLinkItem): LinkType {.inline.} =
self.linkType

View File

@ -1,155 +0,0 @@
import NimQml, tables, strutils, sequtils, sugar
import ../../../app_service/common/social_links
import social_link_item
proc toSocialLinkItems*(source: SocialLinks): seq[SocialLinkItem] =
proc textToType(text: string): LinkType =
if (text == SOCIAL_LINK_TWITTER_ID): return LinkType.Twitter
if (text == SOCIAL_LINK_PERSONAL_SITE_ID): return LinkType.PersonalSite
if (text == SOCIAL_LINK_GITHUB_ID): return LinkType.Github
if (text == SOCIAL_LINK_YOUTUBE_ID): return LinkType.Youtube
if (text == SOCIAL_LINK_DISCORD_ID): return LinkType.Discord
if (text == SOCIAL_LINK_TELEGRAM_ID): return LinkType.Telegram
return LinkType.Custom
result = map(source, x => initSocialLinkItem(x.text, x.url, textToType(x.text), x.icon))
type
ModelRole {.pure.} = enum
Uuid = UserRole + 1
Text
Url
LinkType
Icon
QtObject:
type
SocialLinksModel* = ref object of QAbstractListModel
items: seq[SocialLinkItem]
proc delete(self: SocialLinksModel) =
self.items = @[]
self.QAbstractListModel.delete
proc setup(self: SocialLinksModel) =
self.QAbstractListModel.setup
proc newSocialLinksModel*(): SocialLinksModel =
new(result, delete)
result.setup
proc countChanged(self: SocialLinksModel) {.signal.}
proc getCount(self: SocialLinksModel): int {.slot.} =
self.items.len
QtProperty[int] count:
read = getCount
notify = countChanged
proc containsSocialLink*(self: SocialLinksModel, text, url: string): bool =
return self.items.any(item => cmpIgnoreCase(item.text, text) == 0 and cmpIgnoreCase(item.url, url) == 0)
proc setItems*(self: SocialLinksModel, items: seq[SocialLinkItem]) =
self.beginResetModel()
self.items = items
self.endResetModel()
self.countChanged()
proc appendItem*(self: SocialLinksModel, item: SocialLinkItem) =
let parentModelIndex = newQModelIndex()
defer: parentModelIndex.delete
self.beginInsertRows(parentModelIndex, self.items.len, self.items.len)
self.items.add(item)
self.endInsertRows()
self.countChanged()
proc removeItem*(self: SocialLinksModel, uuid: string): bool =
for i in 0 ..< self.items.len:
if (self.items[i].uuid == uuid):
let parentModelIndex = newQModelIndex()
defer: parentModelIndex.delete
self.beginRemoveRows(parentModelIndex, i, i)
self.items.delete(i)
self.endRemoveRows()
self.countChanged()
return true
return false
# used only by the temp model to reorder items with DND; compat with ListModel::move(from, to, count)
proc moveItem*(self: SocialLinksModel, fromRow: int, toRow: int): bool =
if toRow < 0 or toRow > self.items.len - 1:
return false
let sourceIndex = newQModelIndex()
defer: sourceIndex.delete
let destIndex = newQModelIndex()
defer: destIndex.delete
var destRow = toRow
if toRow > fromRow:
inc(destRow)
let currentItem = self.items[fromRow]
self.beginMoveRows(sourceIndex, fromRow, fromRow, destIndex, destRow)
self.items.delete(fromRow)
self.items.insert(@[currentItem], toRow)
self.endMoveRows()
return true
proc updateItem*(self: SocialLinksModel, uuid, text, url: string): bool =
for i in 0 ..< self.items.len:
if (self.items[i].uuid == uuid):
var changedRoles: seq[int] = @[]
if (self.items[i].text != text):
self.items[i].text = text
changedRoles.add(ModelRole.Text.int)
if (self.items[i].url != url):
self.items[i].url = url
changedRoles.add(ModelRole.Url.int)
if changedRoles.len > 0:
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.dataChanged(index, index, changedRoles)
return true
return false
proc items*(self: SocialLinksModel): seq[SocialLinkItem] =
self.items
method rowCount(self: SocialLinksModel, index: QModelIndex = nil): int =
return self.items.len
method roleNames(self: SocialLinksModel): Table[int, string] =
{
ModelRole.Uuid.int: "uuid",
ModelRole.Text.int: "text",
ModelRole.Url.int: "url",
ModelRole.LinkType.int: "linkType",
ModelRole.Icon.int: "icon"
}.toTable
method data(self: SocialLinksModel, index: QModelIndex, role: int): QVariant =
if (not index.isValid):
return
if (index.row < 0 or index.row >= self.items.len):
return
let item = self.items[index.row]
let enumRole = role.ModelRole
case enumRole:
of ModelRole.Uuid:
result = newQVariant(item.uuid)
of ModelRole.Text:
result = newQVariant(item.text)
of ModelRole.Url:
result = newQVariant(item.url)
of ModelRole.LinkType:
result = newQVariant(item.linkType.int)
of ModelRole.Icon:
result = newQVariant(item.icon)

View File

@ -1,47 +0,0 @@
import json, sequtils, sugar
include json_utils
const SOCIAL_LINK_TWITTER_ID* = "__twitter"
const SOCIAL_LINK_PERSONAL_SITE_ID* = "__personal_site"
const SOCIAL_LINK_GITHUB_ID* = "__github"
const SOCIAL_LINK_YOUTUBE_ID* = "__youtube"
const SOCIAL_LINK_DISCORD_ID* = "__discord"
const SOCIAL_LINK_TELEGRAM_ID* = "__telegram"
type
SocialLink* = object
text*: string
url*: string
icon*: string
SocialLinks* = seq[SocialLink]
SocialLinksInfo* = object
links*: seq[SocialLink]
removed*: bool
proc socialLinkTextToIcon(text: string): string =
if (text == SOCIAL_LINK_TWITTER_ID): return "xtwitter"
if (text == SOCIAL_LINK_PERSONAL_SITE_ID): return "language"
if (text == SOCIAL_LINK_GITHUB_ID): return "github"
if (text == SOCIAL_LINK_YOUTUBE_ID): return "youtube"
if (text == SOCIAL_LINK_DISCORD_ID): return "discord"
if (text == SOCIAL_LINK_TELEGRAM_ID): return "telegram"
return "link"
proc toSocialLinks*(jsonObj: JsonNode): SocialLinks =
result = map(jsonObj.getElems(),
node => SocialLink(text: node["text"].getStr(),
url: node["url"].getStr(),
icon: socialLinkTextToIcon(node["text"].getStr()))
)
proc toSocialLinksInfo*(jsonObj: JsonNode): SocialLinksInfo =
discard jsonObj.getProp("removed", result.removed)
var linksObj: JsonNode
if jsonObj.getProp("links", linksObj):
result.links = toSocialLinks(linksObj)
proc toJsonNode*(links: SocialLinks): JsonNode =
%*links

View File

@ -4,7 +4,6 @@ import json
import ../../visual_identity/dto
include ../../../common/json_utils
import ../../../common/social_links
type
Image* = object
@ -29,7 +28,6 @@ type AccountDto* = object
type WakuBackedUpProfileDto* = object
displayName*: string
images*: seq[Image]
socialLinks*: SocialLinks
proc isValid*(self: AccountDto): bool =
result = self.name.len > 0 and self.keyUid.len > 0
@ -75,6 +73,3 @@ proc toWakuBackedUpProfileDto*(jsonObj: JsonNode): WakuBackedUpProfileDto =
if(jsonObj.getProp("images", obj) and obj.kind == JArray):
for imgObj in obj:
result.images.add(toImage(imgObj))
if(jsonObj.getProp("socialLinks", obj) and obj.kind == JArray):
result.socialLinks = toSocialLinks(obj)

View File

@ -1,7 +1,6 @@
{.used.}
import json, stew/shims/strformat, strutils
import ../../../common/social_links
include ../../../common/json_utils
include ../../../common/utils
@ -52,7 +51,6 @@ type ContactsDto* = object
lastUpdatedLocally*: int64
localNickname*: string
bio*: string
socialLinks*: SocialLinks
image*: Images
added*: bool
blocked*: bool
@ -163,10 +161,6 @@ proc toContactsDto*(jsonObj: JsonNode): ContactsDto =
if(jsonObj.getProp("images", imageObj)):
result.image = toImages(imageObj)
var socialLinksObj: JsonNode
if(jsonObj.getProp("socialLinks", socialLinksObj)):
result.socialLinks = toSocialLinks(socialLinksObj)
discard jsonObj.getProp("added", result.added)
discard jsonObj.getProp("blocked", result.blocked)
discard jsonObj.getProp("hasAddedUs", result.hasAddedUs)

View File

@ -397,7 +397,6 @@ QtObject:
),
trustStatus: TrustStatus.Trusted,
bio: self.settingsService.getBio(),
socialLinks: self.settingsService.getSocialLinks()
)
)

View File

@ -1,8 +1,6 @@
import NimQml, chronicles, json, strutils, sequtils, tables
import app_service/common/types as common_types
import app_service/common/social_links
import app_service/common/utils as common_utils
import app/core/eventemitter
import app/core/fleets/fleet_configuration
import app/core/signals/types
@ -25,7 +23,6 @@ const SIGNAL_CURRENCY_UPDATED* = "currencyUpdated"
const SIGNAL_DISPLAY_NAME_UPDATED* = "displayNameUpdated"
const SIGNAL_BIO_UPDATED* = "bioUpdated"
const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved"
const SIGNAL_SOCIAL_LINKS_UPDATED* = "socialLinksUpdated"
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated"
const SIGNAL_URL_UNFURLING_MODE_UPDATED* = "urlUnfurlingModeUpdated"
@ -41,10 +38,6 @@ type
statusType*: StatusType
text*: string
SocialLinksArgs* = ref object of Args
socialLinks*: SocialLinks
error*: string
SettingsBoolValueArgs* = ref object of Args
value*: bool
@ -55,12 +48,10 @@ QtObject:
type Service* = ref object of QObject
events: EventEmitter
settings: SettingsDto
socialLinks: SocialLinks
initialized: bool
notifExemptionsCache: Table[string, NotificationsExemptions]
# Forward declaration
proc storeSocialLinksAndNotify(self: Service, data: SocialLinksArgs)
proc initNotificationSettings*(self: Service)
proc getNotifSettingAllowNotifications*(self: Service): bool
proc getNotifSettingOneToOneChats*(self: Service): string
@ -121,10 +112,6 @@ QtObject:
self.settings.urlUnfurlingMode = toUrlUnfurlingMode(settingsField.value.getInt)
self.events.emit(SIGNAL_URL_UNFURLING_MODE_UPDATED, UrlUnfurlingModeArgs(value: self.settings.urlUnfurlingMode))
if receivedData.socialLinksInfo.links.len > 0 or
receivedData.socialLinksInfo.removed:
self.storeSocialLinksAndNotify(SocialLinksArgs(socialLinks: receivedData.socialLinksInfo.links))
self.initialized = true
proc initNotificationSettings(self: Service) =
@ -996,45 +983,6 @@ QtObject:
return true
return false
proc getSocialLinks*(self: Service): SocialLinks =
return self.socialLinks
proc storeSocialLinksAndNotify(self: Service, data: SocialLinksArgs) =
self.socialLinks = data.socialLinks
self.events.emit(SIGNAL_SOCIAL_LINKS_UPDATED, data)
proc fetchAndStoreSocialLinks*(self: Service) =
var data = SocialLinksArgs()
try:
let response = status_settings.getSocialLinks()
if(not response.error.isNil):
data.error = response.error.message
error "error getting social links", errDescription = response.error.message
data.socialLinks = toSocialLinks(response.result)
except Exception as e:
data.error = e.msg
error "error getting social links", errDesription = e.msg
self.storeSocialLinksAndNotify(data)
proc setSocialLinks*(self: Service, links: SocialLinks) =
var data = SocialLinksArgs()
let isValid = all(links, proc (link: SocialLink): bool = common_utils.validateLink(link.url))
if not isValid:
data.error = "invalid link provided"
error "validation error", errDescription=data.error
return
try:
let response = status_settings.addOrReplaceSocialLinks(%*links)
if not response.error.isNil:
data.error = response.error.message
error "error saving social links", errDescription=data.error
return
data.socialLinks = links
except Exception as e:
data.error = e.msg
error "error saving social links", errDescription=data.error
self.storeSocialLinksAndNotify(data)
proc getProfileMigrationNeeded*(self: Service): bool =
self.settings.profileMigrationNeeded

View File

@ -96,11 +96,5 @@ proc setExemptions*(id: string, muteAllMessages: bool, personalMentions: string,
proc deleteExemptions*(id: string): RpcResponse[JsonNode] =
return core.callPrivateRPC("settings_deleteExemptions", %* [id])
proc addOrReplaceSocialLinks*(value: JsonNode): RpcResponse[JsonNode] =
return core.callPrivateRPC("settings_addOrReplaceSocialLinks", %* [value])
proc getSocialLinks*(): RpcResponse[JsonNode] =
return core.callPrivateRPC("settings_getSocialLinks")
proc mnemonicWasShown*(): RpcResponse[JsonNode] =
return core.callPrivateRPC("settings_mnemonicWasShown")

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit c8dfbe682dfd299d1ab5701837864eda2588bab4
Subproject commit 4f493a533ef1b3199e1ae4a5501cb909752b719f