From 81e1c73c6569ebc5432b8a73a8805c1eb0829259 Mon Sep 17 00:00:00 2001 From: Balazs Toldi Date: Tue, 24 Oct 2023 18:58:41 +0200 Subject: [PATCH] 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. --- .../infinityforlemmy/asynctasks/InsertSubscribedThings.java | 2 +- .../subscribedsubreddit/SubscribedSubredditDao.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/asynctasks/InsertSubscribedThings.java b/app/src/main/java/eu/toldi/infinityforlemmy/asynctasks/InsertSubscribedThings.java index 844e60f3..98553250 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/asynctasks/InsertSubscribedThings.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/asynctasks/InsertSubscribedThings.java @@ -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); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/subscribedsubreddit/SubscribedSubredditDao.java b/app/src/main/java/eu/toldi/infinityforlemmy/subscribedsubreddit/SubscribedSubredditDao.java index f9f6d266..36954d59 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/subscribedsubreddit/SubscribedSubredditDao.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/subscribedsubreddit/SubscribedSubredditDao.java @@ -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> 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); }