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

[Community] Changing logo doesn't get propagated #16688

Open
caybro opened this issue Nov 1, 2024 · 7 comments
Open

[Community] Changing logo doesn't get propagated #16688

caybro opened this issue Nov 1, 2024 · 7 comments

Comments

@caybro
Copy link
Member

caybro commented Nov 1, 2024

Perhaps related (or the same issue):

Image

If I change the community logo, it's persisted but will update only after app restart (I suspect the banner too but this one is hard to check as it's not visible anywhere else in the app)

Originally posted by @caybro in #16672

@jrainville
Copy link
Member

Turns out adding the role is not enough. I'm very confused why it doesn't want to update. I checked the url from the localhost and it's indeed the new image. I've been banging my head on this for a while and I can't understand. The model is passed correctly as far as I can see, so the dataChanged should propagate correctly.

I'll give it a rest and come back to it.

In the meantime, I found and fixed this: status-im/status-go#6026

@caybro
Copy link
Member Author

caybro commented Nov 1, 2024

Turns out adding the role is not enough. I'm very confused why it doesn't want to update. I checked the url from the localhost and it's indeed the new image. I've been banging my head on this for a while and I can't understand. The model is passed correctly as far as I can see, so the dataChanged should propagate correctly.

I'll give it a rest and come back to it.

In the meantime, I found and fixed this: status-im/status-go#6026

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

@jrainville
Copy link
Member

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

yes. It's something like localhost://communityId="0x1234...890"&format="thumbnail".

Is there a way to force the QML to reload the image?

@caybro
Copy link
Member Author

caybro commented Nov 4, 2024

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

yes. It's something like localhost://communityId="0x1234...890"&format="thumbnail".

Is there a way to force the QML to reload the image?

Yeah, sth like:

image.source = ""
image.source = newUrl

oh, and you probably have to set cache: false on the Image

@jrainville
Copy link
Member

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

yes. It's something like localhost://communityId="0x1234...890"&format="thumbnail".
Is there a way to force the QML to reload the image?

Yeah, sth like:

image.source = ""
image.source = newUrl
oh, and you probably have to set cache: false on the Image

This worked, but the code is very ugly.

I created a commit here 85dd85d, but I think I'll try to see if I can fix it on the status-go side by appending some sort of index at the end of the URL when it gets updated. It would be much cleaner

@caybro
Copy link
Member Author

caybro commented Nov 5, 2024

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

yes. It's something like localhost://communityId="0x1234...890"&format="thumbnail".
Is there a way to force the QML to reload the image?

Yeah, sth like:
image.source = ""
image.source = newUrl
oh, and you probably have to set cache: false on the Image

This worked, but the code is very ugly.

I created a commit here 85dd85d, but I think I'll try to see if I can fix it on the status-go side by appending some sort of index at the end of the URL when it gets updated. It would be much cleaner

Yeah this is indeed ugly 😄 BTW I just found out that we have this function in Utils.qml:

    function addTimestampToURL(url) {
        return globalUtilsInst.addTimestampToURL(url)
    }

which calls:

import times

proc addTimestampToURL*(url: string): string =
  if url.len == 0:
    return ""

  let timestamp = epochTime()

  if '?' in url:
    return url & "&timestamp=" & $timestamp
  else:
    return url & "?timestamp=" & $timestamp

and we wrap some images with it already in QML code (like profile icon).

The NIM code above is kinda naive but we could actually call sth like that already in the models serving images; this way the URL won't be the same, and thus no need to disable caching, or forcing an empty URL to reload the Image on the QML side

@jrainville
Copy link
Member

Is the URL still the same after the update, or a different one? Because if the former is true, the QML Image simply won't reload

yes. It's something like localhost://communityId="0x1234...890"&format="thumbnail".
Is there a way to force the QML to reload the image?

Yeah, sth like:
image.source = ""
image.source = newUrl
oh, and you probably have to set cache: false on the Image

This worked, but the code is very ugly.
I created a commit here 85dd85d, but I think I'll try to see if I can fix it on the status-go side by appending some sort of index at the end of the URL when it gets updated. It would be much cleaner

Yeah this is indeed ugly 😄 BTW I just found out that we have this function in Utils.qml:

function addTimestampToURL(url) {
    return globalUtilsInst.addTimestampToURL(url)
}

which calls:

import times

proc addTimestampToURL*(url: string): string =
if url.len == 0:
return ""

let timestamp = epochTime()

if '?' in url:
return url & "&timestamp=" & $timestamp
else:
return url & "?timestamp=" & $timestamp
and we wrap some images with it already in QML code (like profile icon).

The NIM code above is kinda naive but we could actually call sth like that already in the models serving images; this way the URL won't be the same, and thus no need to disable caching, or forcing an empty URL to reload the Image on the QML side

Ah that's very helpful! That explains why when I did the dataChaged on the profile image in another PR, it worked.

I do have a branch with status-go work to fix it (it adds a version to the URL). I just need to fix the tests.

It should be simpler and cleaner that way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

2 participants