From bc580a1ff80f8a88519aaae3a1dbbc87646bb5f5 Mon Sep 17 00:00:00 2001 From: Mikhail Rogachev Date: Fri, 24 May 2024 12:21:42 +0200 Subject: [PATCH] chore(Profile): remove old social links code (#14899) Close #13938 --- .../core/signals/remote_signals/messages.nim | 5 - src/app/modules/main/module.nim | 2 - .../profile_section/profile/controller.nim | 13 -- .../profile_section/profile/io_interface.nim | 7 - .../main/profile_section/profile/module.nim | 21 +-- .../main/profile_section/profile/view.nim | 101 ------------ .../shared_models/social_link_item.nim | 32 ---- .../shared_models/social_links_model.nim | 155 ------------------ src/app_service/common/social_links.nim | 47 ------ .../service/accounts/dto/accounts.nim | 5 - .../service/contacts/dto/contacts.nim | 6 - src/app_service/service/contacts/service.nim | 1 - src/app_service/service/settings/service.nim | 52 ------ src/backend/settings.nim | 6 - vendor/status-go | 2 +- 15 files changed, 2 insertions(+), 453 deletions(-) delete mode 100644 src/app/modules/shared_models/social_link_item.nim delete mode 100644 src/app/modules/shared_models/social_links_model.nim delete mode 100644 src/app_service/common/social_links.nim diff --git a/src/app/core/signals/remote_signals/messages.nim b/src/app/core/signals/remote_signals/messages.nim index 90118f2422..25b06c8bd4 100644 --- a/src/app/core/signals/remote_signals/messages.nim +++ b/src/app/core/signals/remote_signals/messages.nim @@ -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()) diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index dbf4a19eef..b64b44a83d 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -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 } diff --git a/src/app/modules/main/profile_section/profile/controller.nim b/src/app/modules/main/profile_section/profile/controller.nim index 6bc77e96e0..6dfd5adb00 100644 --- a/src/app/modules/main/profile_section/profile/controller.nim +++ b/src/app/modules/main/profile_section/profile/controller.nim @@ -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() diff --git a/src/app/modules/main/profile_section/profile/io_interface.nim b/src/app/modules/main/profile_section/profile/io_interface.nim index f91ab347c9..0e184facfb 100644 --- a/src/app/modules/main/profile_section/profile/io_interface.nim +++ b/src/app/modules/main/profile_section/profile/io_interface.nim @@ -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") diff --git a/src/app/modules/main/profile_section/profile/module.nim b/src/app/modules/main/profile_section/profile/module.nim index d327edb5d8..f0d2bbcca8 100644 --- a/src/app/modules/main/profile_section/profile/module.nim +++ b/src/app/modules/main/profile_section/profile/module.nim @@ -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() diff --git a/src/app/modules/main/profile_section/profile/view.nim b/src/app/modules/main/profile_section/profile/view.nim index 59e5883805..3e89c2d11e 100644 --- a/src/app/modules/main/profile_section/profile/view.nim +++ b/src/app/modules/main/profile_section/profile/view.nim @@ -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() diff --git a/src/app/modules/shared_models/social_link_item.nim b/src/app/modules/shared_models/social_link_item.nim deleted file mode 100644 index 4b6ccdb9cc..0000000000 --- a/src/app/modules/shared_models/social_link_item.nim +++ /dev/null @@ -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 diff --git a/src/app/modules/shared_models/social_links_model.nim b/src/app/modules/shared_models/social_links_model.nim deleted file mode 100644 index e193cc9512..0000000000 --- a/src/app/modules/shared_models/social_links_model.nim +++ /dev/null @@ -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) diff --git a/src/app_service/common/social_links.nim b/src/app_service/common/social_links.nim deleted file mode 100644 index e124856e97..0000000000 --- a/src/app_service/common/social_links.nim +++ /dev/null @@ -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 diff --git a/src/app_service/service/accounts/dto/accounts.nim b/src/app_service/service/accounts/dto/accounts.nim index f9fecf4b8c..24ff23281a 100644 --- a/src/app_service/service/accounts/dto/accounts.nim +++ b/src/app_service/service/accounts/dto/accounts.nim @@ -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) diff --git a/src/app_service/service/contacts/dto/contacts.nim b/src/app_service/service/contacts/dto/contacts.nim index d41272327b..e973c02f5d 100644 --- a/src/app_service/service/contacts/dto/contacts.nim +++ b/src/app_service/service/contacts/dto/contacts.nim @@ -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) diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index 0a9c4f79dc..92a21c7208 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -397,7 +397,6 @@ QtObject: ), trustStatus: TrustStatus.Trusted, bio: self.settingsService.getBio(), - socialLinks: self.settingsService.getSocialLinks() ) ) diff --git a/src/app_service/service/settings/service.nim b/src/app_service/service/settings/service.nim index 7d045be5be..26a570e926 100644 --- a/src/app_service/service/settings/service.nim +++ b/src/app_service/service/settings/service.nim @@ -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 diff --git a/src/backend/settings.nim b/src/backend/settings.nim index 0b8db4bee7..0932e64207 100644 --- a/src/backend/settings.nim +++ b/src/backend/settings.nim @@ -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") diff --git a/vendor/status-go b/vendor/status-go index c8dfbe682d..4f493a533e 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit c8dfbe682dfd299d1ab5701837864eda2588bab4 +Subproject commit 4f493a533ef1b3199e1ae4a5501cb909752b719f