Fix the updating part of the community saving

In a previous commit, I've added a code snippet that made an update query for each fetched summary that is already in the internal database. However, it did not take in to account that the same community can be related to different accounts. This commit fixes this issue by adding an additional filter to the update db query.
This commit is contained in:
Balazs Toldi 2023-10-24 18:58:41 +02:00
parent 554dfff4ad
commit 81e1c73c65
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -37,6 +37,6 @@ 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);
@Query("UPDATE subscribed_subreddits SET name = :displayName, icon = :icon WHERE qualified_name = :qualified_name AND username = :accountName COLLATE NOCASE")
void updateSubscribedSubreddit(String qualified_name, String displayName, String icon, String accountName);
}