Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(contacts): remove hack force refreshing images with a timestamp #17054

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/app/global/utils.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import NimQml, strutils, uri, stew/shims/strformat, strutils, stint, httpclient
import stew/byteutils
import ./utils/qrcodegen
import ./utils/time_utils

# Services as instances shouldn't be used in this class, just some general/global procs
import ../../app_service/common/conversion
Expand Down Expand Up @@ -143,9 +142,6 @@ QtObject:
return value[2..^1]
return value

proc addTimestampToURL*(self: Utils, url: string): string {.slot.} =
return time_utils.addTimestampToURL(url)

proc isValidURL*(self: Utils, url: string): bool {.slot.} =
var client = newHttpClient()
defer: client.close()
Expand Down
12 changes: 0 additions & 12 deletions src/app/global/utils/time_utils.nim

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import ../../../../../../app_service/service/mailservers/service as mailservers_
import ../../../../../../app_service/service/shared_urls/service as shared_urls_service
import ../../../../../../app_service/service/contacts/dto/contact_details
import ../../../../../../app_service/common/types
import ../../../../../global/utils as utils
import ../../../../../global/global_singleton

export io_interface
Expand Down Expand Up @@ -434,12 +433,11 @@ method getNumberOfPinnedMessages*(self: Module): int =
method updateContactDetails*(self: Module, contactId: string) =
let updatedContact = self.controller.getContactDetails(contactId)

let updatedSenderIcon = singletonInstance.utils().addTimestampToURL(updatedContact.icon)
for item in self.view.model().modelContactUpdateIterator(contactId):
if item.senderId == contactId:
item.senderDisplayName = updatedContact.defaultDisplayName
item.senderOptionalName = updatedContact.optionalName
item.senderIcon = updatedSenderIcon
item.senderIcon = updatedContact.icon
item.senderColorHash = updatedContact.colorHash
item.senderIsAdded = updatedContact.dto.added
item.senderTrustStatus = updatedContact.dto.trustStatus
Expand All @@ -448,7 +446,7 @@ method updateContactDetails*(self: Module, contactId: string) =
if item.quotedMessageAuthorDetails.dto.id == contactId:
item.quotedMessageAuthorDetails = updatedContact
item.quotedMessageAuthorDisplayName = updatedContact.defaultDisplayName
item.quotedMessageAuthorAvatar = updatedSenderIcon
item.quotedMessageAuthorAvatar = updatedContact.icon

if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
let communityChats = self.controller.getCommunityDetails().chats
Expand Down
4 changes: 1 addition & 3 deletions src/app/modules/main/chat_section/model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,7 @@ QtObject:
return
self.items[index].name = name

var updatedIcon = singletonInstance.utils().addTimestampToURL(icon)

self.items[index].icon = updatedIcon
self.items[index].icon = icon
self.items[index].trustStatus = trustStatus
let modelIndex = self.createIndex(index, 0, nil)
defer: modelIndex.delete
Expand Down
4 changes: 0 additions & 4 deletions src/app/modules/shared_models/user_model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ QtObject:
roles.add(ModelRole.IsUntrustworthy.int)
roles.add(ModelRole.IsVerified.int)

# The image is actually a URL that doesn't change. We need to force refresh it just in case
roles.add(ModelRole.ThumbnailImage.int)
roles.add(ModelRole.LargeImage.int)

if roles.len == 0:
return

Expand Down
28 changes: 0 additions & 28 deletions test/nim/utils_test.nim

This file was deleted.

2 changes: 1 addition & 1 deletion ui/imports/shared/popups/CommonContactDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ StatusDialog {
name: root.mainDisplayName
colorHash: contactDetails.colorHash
colorId: contactDetails.colorId
image: Utils.addTimestampToURL(contactDetails.largeImage)
image: contactDetails.largeImage
interactive: false
imageWidth: 60
imageHeight: 60
Expand Down
2 changes: 1 addition & 1 deletion ui/imports/shared/views/ProfileDialogView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Pane {
Layout.alignment: Qt.AlignTop
objectName: "ProfileDialog_userImage"
name: d.mainDisplayName
image: Utils.addTimestampToURL(contactDetails.largeImage)
image: contactDetails.largeImage
colorId: contactDetails.colorId
colorHash: contactDetails.colorHash

Expand Down
4 changes: 0 additions & 4 deletions ui/imports/utils/Utils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,4 @@ QtObject {

return ""
}

function addTimestampToURL(url) {
return globalUtilsInst.addTimestampToURL(url)
}
}
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 50 files
+1 −0 .codeclimate.yml
+10 −2 api/backend_test.go
+55 −5 api/default_networks.go
+4 −2 api/default_networks_test.go
+6 −0 api/defaults.go
+2 −0 contracts/balancechecker/address.go
+9 −6 contracts/community-tokens/deployer/address.go
+2 −0 contracts/ethscan/address.go
+2 −0 contracts/gas-price-oracle/address.go
+1 −0 contracts/hop/L2_BaseBrige.abi
+44 −0 contracts/hop/address.go
+3,392 −0 contracts/hop/l2Contracts/l2BaseBridge/l2BaseBridge.go
+2 −0 images/main.go
+24 −0 images/main_test.go
+2 −0 mobile/callog/status_request_log.go
+2 −2 multiaccounts/accounts/database.go
+1 −1 protocol/common/message_sender.go
+1 −0 protocol/common/raw_message.go
+7 −0 protocol/communities/community.go
+15 −1 protocol/communities/manager.go
+4 −0 protocol/communities/manager_archive.go
+2 −1 protocol/communities_messenger_token_permissions_test.go
+18 −2 protocol/messenger.go
+8 −1 protocol/messenger_communities.go
+1 −1 protocol/messenger_contacts.go
+2 −0 protocol/requests/create_account.go
+2 −2 rpc/network/network.go
+2 −2 server/server_media.go
+9 −0 server/server_test.go
+1 −1 services/wallet/activity/activity.go
+11 −4 services/wallet/common/const.go
+1 −1 services/wallet/onramp/provider_mercuryo.go
+1 −1 services/wallet/onramp/provider_moonpay.go
+1 −1 services/wallet/onramp/provider_ramp.go
+2 −0 services/wallet/router/common.go
+24 −0 services/wallet/router/pathprocessor/processor_bridge_hop.go
+2 −0 services/wallet/router/pathprocessor/processor_swap_paraswap.go
+786 −128 services/wallet/router/router_test_data.go
+4 −0 services/wallet/router/router_updates.go
+1 −0 services/wallet/router/sendtype/send_type.go
+4 −0 services/wallet/thirdparty/alchemy/client.go
+4 −0 services/wallet/thirdparty/mercuryo/types.go
+2 −2 services/wallet/thirdparty/opensea/client_v2.go
+6 −0 services/wallet/thirdparty/opensea/types_v2.go
+2 −2 services/wallet/thirdparty/rarible/client.go
+9 −0 services/wallet/thirdparty/rarible/types.go
+16 −0 services/wallet/token/tokenstore.go
+3 −0 services/wallet/transfer/commands.go
+3 −0 tests-unit-network/cryptocompare/cryptocompare_test.go
+4 −2 transactions/transactor.go