Minor fix to updating subscribed communities

Previously, the app did not update any changes to a community after subscribing to it. Now the internal db is updated each time the list of subscribers is refreshed.
This commit is contained in:
Balazs Toldi 2023-10-22 18:40:01 +02:00
parent f8a21fa3ba
commit 741ec08386
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,7 @@ public class InsertSubscribedThings {
for (SubscribedSubredditData s : subscribedSubredditDataList) {
if (existingSubscribedSubredditDataList.contains(s)) {
subscribedSubredditDao.updateSubscribedSubreddit(s.getQualified_name(), s.getName(), s.getIconUrl());
continue;
}
subscribedSubredditDao.insert(s);

View File

@ -36,4 +36,7 @@ public interface SubscribedSubredditDao {
@Query("SELECT * from subscribed_subreddits WHERE username = :qualified_name AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE AND is_favorite = 1 ORDER BY name COLLATE NOCASE ASC")
LiveData<List<SubscribedSubredditData>> getAllFavoriteSubscribedSubredditsWithSearchQuery(String qualified_name, String searchQuery);
@Query("UPDATE subscribed_subreddits SET name = :displayName, icon = :icon WHERE qualified_name = :qualified_name")
void updateSubscribedSubreddit(String qualified_name, String displayName, String icon);
}