Skip to content

Commit

Permalink
refactor(contacts): remove hack force refreshing images with a timestamp
Browse files Browse the repository at this point in the history
Fixes #16814
  • Loading branch information
jrainville committed Jan 10, 2025
1 parent 06d5499 commit f82f0c1
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 62 deletions.
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

0 comments on commit f82f0c1

Please sign in to comment.