thunder-app / thunder

Thunder - An open-source cross-platform Lemmy client for iOS and Android built with Flutter
https://thunderapp.dev
GNU Affero General Public License v3.0
712 stars 62 forks source link

Add support for managing uploaded media #1323

Open micahmo opened 3 weeks ago

micahmo commented 3 weeks ago

Pull Request Description

This PR adds the ability to delete uploaded images. There is a new section under account settings for managing media. Navigating to this new page will display all uploaded images with the option to delete any of them. This is only supported for instances running >= 0.19.4.

See: thunder-app/lemmy_api_client#21.

Screenshots / Recordings

https://github.com/thunder-app/thunder/assets/7417301/2e49593d-12d1-424e-9c6b-a64aa1ac438d


P.S. While working on this feature, I discovered something really interesting! I've always been annoyed at how seemingly quickly our image caches reset despite having the new aggressive image caching setting. It turns out that this is less about image caching and more about widget caching. The default behavior of SliverLists is to pretty aggressive dispose and rebuild widgets as they're scrolled off/on screen, and this naturally causes some loading artifacts, even for cached images. However, this trick seems to make things much better.

Pass these paramters to the SliverList.

addSemanticIndexes: false,
addAutomaticKeepAlives: false,
addRepaintBoundaries: false,

And then wrap whatever is the root widget in the list with a KeepAlive(keepAlive: true).

For now I've only done it here, but maybe we could consider doing this in other places of the app (respecting the aggressive image caching option). Here's a before/after of just that difference.

Before

https://github.com/thunder-app/thunder/assets/7417301/f15ba94e-8a12-4934-a224-f45d80fde45d

After

https://github.com/thunder-app/thunder/assets/7417301/f686bbc2-a1e0-4976-a4b5-d0b4747661f1

micahmo commented 3 weeks ago

I decided to add on a slight improvement to this feature. I added the ability to search for usages of the media link. It can help you to decide whether you really want to delete it. It should return cases where the link appears as the URL of a post, in the body of a post, or in the body of a comment. Of course, this method is not foolproof, as the link could be used in some other way (including not even on Lemmy). But it should at least help the user to make a more informed decision.

https://github.com/thunder-app/thunder/assets/7417301/5c80fe32-2d3a-4546-a38c-f9a4c5d2f4aa