(fix/desktop) removing custom picture is not reflected on contact's side (#13197)
* chore: bump status-go * (fix/desktop) removing custom picture is not reflected on contact's side This PR fixes [9947](#9947) and contains : - Commit to fix the changing of custom picture and having the change reflected on contact's side - Commit to fix the deleting of picture and having the change reflected on contact's side
This commit is contained in:
parent
5080499d29
commit
ab61784816
|
@ -1,6 +1,7 @@
|
||||||
import NimQml, strutils, uri, strformat, strutils, stint, re
|
import NimQml, strutils, uri, strformat, strutils, stint, re
|
||||||
import stew/byteutils
|
import stew/byteutils
|
||||||
import ./utils/qrcodegen
|
import ./utils/qrcodegen
|
||||||
|
import ./utils/time_utils
|
||||||
|
|
||||||
# Services as instances shouldn't be used in this class, just some general/global procs
|
# Services as instances shouldn't be used in this class, just some general/global procs
|
||||||
import ../../app_service/common/conversion
|
import ../../app_service/common/conversion
|
||||||
|
@ -174,4 +175,7 @@ QtObject:
|
||||||
proc removeHexPrefix*(self: Utils, value: string): string =
|
proc removeHexPrefix*(self: Utils, value: string): string =
|
||||||
if value.startsWith("0x"):
|
if value.startsWith("0x"):
|
||||||
return value[2..^1]
|
return value[2..^1]
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
proc addTimestampToURL*(self: Utils, url: string): string {.slot.} =
|
||||||
|
return time_utils.addTimestampToURL(url)
|
|
@ -0,0 +1,12 @@
|
||||||
|
import times
|
||||||
|
|
||||||
|
proc addTimestampToURL*(url: string): string =
|
||||||
|
if url.len == 0:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
let timestamp = epochTime()
|
||||||
|
|
||||||
|
if '?' in url:
|
||||||
|
return url & "×tamp=" & $timestamp
|
||||||
|
else:
|
||||||
|
return url & "?timestamp=" & $timestamp
|
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, chronicles, sequtils, uuids, sets, times, tables
|
import NimQml, chronicles, sequtils, uuids, sets, times, tables, strutils, system
|
||||||
import io_interface
|
import io_interface
|
||||||
import ../io_interface as delegate_interface
|
import ../io_interface as delegate_interface
|
||||||
import view, controller
|
import view, controller
|
||||||
|
@ -17,6 +17,8 @@ import ../../../../../../app_service/service/message/service as message_service
|
||||||
import ../../../../../../app_service/service/mailservers/service as mailservers_service
|
import ../../../../../../app_service/service/mailservers/service as mailservers_service
|
||||||
import ../../../../../../app_service/service/shared_urls/service as shared_urls_service
|
import ../../../../../../app_service/service/shared_urls/service as shared_urls_service
|
||||||
import ../../../../../../app_service/common/types
|
import ../../../../../../app_service/common/types
|
||||||
|
import ../../../../../global/utils as utils
|
||||||
|
import ../../../../../global/global_singleton
|
||||||
|
|
||||||
export io_interface
|
export io_interface
|
||||||
|
|
||||||
|
@ -533,11 +535,13 @@ method getNumberOfPinnedMessages*(self: Module): int =
|
||||||
|
|
||||||
method updateContactDetails*(self: Module, contactId: string) =
|
method updateContactDetails*(self: Module, contactId: string) =
|
||||||
let updatedContact = self.controller.getContactDetails(contactId)
|
let updatedContact = self.controller.getContactDetails(contactId)
|
||||||
|
|
||||||
|
let updatedSenderIcon = singletonInstance.utils().addTimestampToURL(updatedContact.icon)
|
||||||
for item in self.view.model().modelContactUpdateIterator(contactId):
|
for item in self.view.model().modelContactUpdateIterator(contactId):
|
||||||
if item.senderId == contactId:
|
if item.senderId == contactId:
|
||||||
item.senderDisplayName = updatedContact.defaultDisplayName
|
item.senderDisplayName = updatedContact.defaultDisplayName
|
||||||
item.senderOptionalName = updatedContact.optionalName
|
item.senderOptionalName = updatedContact.optionalName
|
||||||
item.senderIcon = updatedContact.icon
|
item.senderIcon = updatedSenderIcon
|
||||||
item.senderColorHash = updatedContact.colorHash
|
item.senderColorHash = updatedContact.colorHash
|
||||||
item.senderIsAdded = updatedContact.dto.added
|
item.senderIsAdded = updatedContact.dto.added
|
||||||
item.senderTrustStatus = updatedContact.dto.trustStatus
|
item.senderTrustStatus = updatedContact.dto.trustStatus
|
||||||
|
@ -546,7 +550,7 @@ method updateContactDetails*(self: Module, contactId: string) =
|
||||||
if item.quotedMessageAuthorDetails.dto.id == contactId:
|
if item.quotedMessageAuthorDetails.dto.id == contactId:
|
||||||
item.quotedMessageAuthorDetails = updatedContact
|
item.quotedMessageAuthorDetails = updatedContact
|
||||||
item.quotedMessageAuthorDisplayName = updatedContact.defaultDisplayName
|
item.quotedMessageAuthorDisplayName = updatedContact.defaultDisplayName
|
||||||
item.quotedMessageAuthorAvatar = updatedContact.icon
|
item.quotedMessageAuthorAvatar = updatedSenderIcon
|
||||||
|
|
||||||
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId):
|
||||||
let communityChats = self.controller.getCommunityDetails().chats
|
let communityChats = self.controller.getCommunityDetails().chats
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import NimQml, Tables, strutils, strformat, json, sequtils
|
import NimQml, Tables, strutils, strformat, json, sequtils, times, system
|
||||||
import ../../../../app_service/common/types
|
import ../../../../app_service/common/types
|
||||||
import ../../../../app_service/service/chat/dto/chat
|
import ../../../../app_service/service/chat/dto/chat
|
||||||
from ../../../../app_service/service/contacts/dto/contacts import TrustStatus
|
from ../../../../app_service/service/contacts/dto/contacts import TrustStatus
|
||||||
import item
|
import item
|
||||||
|
import ../../../global/utils as utils
|
||||||
|
import ../../../global/global_singleton
|
||||||
|
|
||||||
type
|
type
|
||||||
ModelRole {.pure.} = enum
|
ModelRole {.pure.} = enum
|
||||||
|
@ -345,7 +347,10 @@ QtObject:
|
||||||
if index == -1:
|
if index == -1:
|
||||||
return
|
return
|
||||||
self.items[index].name = name
|
self.items[index].name = name
|
||||||
self.items[index].icon = icon
|
|
||||||
|
var updatedIcon = singletonInstance.utils().addTimestampToURL(icon)
|
||||||
|
|
||||||
|
self.items[index].icon = updatedIcon
|
||||||
self.items[index].trustStatus = trustStatus
|
self.items[index].trustStatus = trustStatus
|
||||||
let modelIndex = self.createIndex(index, 0, nil)
|
let modelIndex = self.createIndex(index, 0, nil)
|
||||||
defer: modelIndex.delete
|
defer: modelIndex.delete
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import unittest, strutils
|
||||||
|
|
||||||
|
import app/global/utils/time_utils
|
||||||
|
|
||||||
|
suite "adding timestamp to url":
|
||||||
|
test "adding timestamp to an image url with query containing ?":
|
||||||
|
let url = "https://Localhost:35651/contactImages?imageName=thumbnail?publicKey=0x04d76f84ec"
|
||||||
|
let result = time_utils.addTimestampToURL(url)
|
||||||
|
|
||||||
|
check(result.startsWith(url & "×tamp="))
|
||||||
|
|
||||||
|
test "adding timestamp to an image url with query containing &":
|
||||||
|
let url = "https://Localhost:35651/contactImages&imageName=thumbnail&publicKey=0x04d76f84e8dc"
|
||||||
|
let result = time_utils.addTimestampToURL(url)
|
||||||
|
|
||||||
|
check(result.startsWith(url & "?timestamp="))
|
||||||
|
|
||||||
|
test "image contains a mix of & and ? queries, & is added":
|
||||||
|
let url = "https://Localhost:35651/contactImages?imageName=thumbnail&publicKey=0x04d76f84e8dc"
|
||||||
|
let result = time_utils.addTimestampToURL(url)
|
||||||
|
|
||||||
|
check(result.startsWith(url & "×tamp="))
|
||||||
|
|
||||||
|
test "adding timestamp to an empty image url":
|
||||||
|
let result = time_utils.addTimestampToURL("")
|
||||||
|
|
||||||
|
let expectedResult = ""
|
||||||
|
check(result == expectedResult)
|
|
@ -264,6 +264,7 @@ Item {
|
||||||
|
|
||||||
StatusChatInfoButton {
|
StatusChatInfoButton {
|
||||||
readonly property string emojiIcon: chatContentModule? chatContentModule.chatDetails.emoji : "" // Needed for test
|
readonly property string emojiIcon: chatContentModule? chatContentModule.chatDetails.emoji : "" // Needed for test
|
||||||
|
readonly property string assetName: chatContentModule && Utils.addTimestampToURL(chatContentModule.chatDetails.icon)
|
||||||
|
|
||||||
objectName: "chatInfoBtnInHeader"
|
objectName: "chatInfoBtnInHeader"
|
||||||
title: chatContentModule? chatContentModule.chatDetails.name : ""
|
title: chatContentModule? chatContentModule.chatDetails.name : ""
|
||||||
|
@ -283,7 +284,7 @@ Item {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asset.name: chatContentModule? chatContentModule.chatDetails.icon : ""
|
asset.name: assetName
|
||||||
asset.isImage: chatContentModule && chatContentModule.chatDetails.icon !== ""
|
asset.isImage: chatContentModule && chatContentModule.chatDetails.icon !== ""
|
||||||
asset.isLetterIdenticon: chatContentModule && chatContentModule.chatDetails.icon === ""
|
asset.isLetterIdenticon: chatContentModule && chatContentModule.chatDetails.icon === ""
|
||||||
ringSettings.ringSpecModel: chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
ringSettings.ringSpecModel: chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
||||||
|
|
|
@ -278,7 +278,7 @@ Pane {
|
||||||
: d.mainDisplayName
|
: d.mainDisplayName
|
||||||
pubkey: root.publicKey
|
pubkey: root.publicKey
|
||||||
image: root.dirty ? root.dirtyValues.profileLargeImage
|
image: root.dirty ? root.dirtyValues.profileLargeImage
|
||||||
: d.contactDetails.largeImage
|
: Utils.addTimestampToURL(d.contactDetails.largeImage)
|
||||||
interactive: false
|
interactive: false
|
||||||
imageWidth: 80
|
imageWidth: 80
|
||||||
imageHeight: imageWidth
|
imageHeight: imageWidth
|
||||||
|
|
|
@ -938,4 +938,8 @@ QtObject {
|
||||||
function isPunct(c) {
|
function isPunct(c) {
|
||||||
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addTimestampToURL(url) {
|
||||||
|
return globalUtilsInst.addTimestampToURL(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fb98ee93ceaacddce77aaf9df605c6a8ba3fda74
|
Subproject commit 7c9977b780675ab0fa00fb14b10321e4d078b2c4
|
Loading…
Reference in New Issue