Skip to content

Conversation

ariloc
Copy link
Contributor

@ariloc ariloc commented Jul 10, 2025

Hi, I was testing the app after a while of not using it and noticed right away that refreshing the memo list by swiping down in the main screen didn't ever finish, so I looked into the code to find out the cause.

It seems like the implementation for copying links for memos relied on collecting updates of the currentAccount variable at the AccountService to find out the host for the current account. However, using .collect{} with DataStore.data (the underlaying structure currentAccount gets its value from) may never finish, as it suspends for every update in the store, impeding the loadMemos() function in the view model from finishing, by trying to load the host each time the memo list was loaded.
I saw the recommended way was to use .first() with runBlocking{} if needed, but thought using a StateFlow tied to the lifecycle of the view model may be better to keep the latest value loaded (though it shouldn't change unless the current account was switched). This way I also avoided deeply passing the host to each card, and instead reading it from the view model (to avoid injecting the AccountService to each card). Not sure if this is the best decision though, but as the list view model was already referenced and frequently used in each card, thought it would be better this way.

I also noticed that the link generated was formed with the format ${host}/m/${identifier} which was invalid from what I tested with the latest version v0.24.4 of memos. Therefore, I changed it to just use ${host}/${memo.identifier}, after reading the API v1 docs. I'm not sure if I may be breaking compatibility with the v0 API, but the docs I could find of that weren't clear enough about the format of the identifiers, and any mention I could find of it was accompanied by a strong encouragement to use API v1, so please let me know if I need to make any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant