Fix removing blocked things

This commit is contained in:
Balazs Toldi 2023-08-11 23:59:42 +02:00
parent 6621748de5
commit f5172a17db
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
3 changed files with 6 additions and 6 deletions

View File

@ -79,19 +79,19 @@ public class InsertBlockedThings {
for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) { for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
if (newIndex >= newSubscribedSubreddits.size()) { if (newIndex >= newSubscribedSubreddits.size()) {
for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) { for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getName()); unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getQualified_name());
} }
return; return;
} }
BlockedCommunityData old = oldSubscribedSubreddits.get(oldIndex); BlockedCommunityData old = oldSubscribedSubreddits.get(oldIndex);
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) { for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) { if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) == 0) {
newIndex++; newIndex++;
break; break;
} }
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) { if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) > 0) {
unsubscribedSubredditNames.add(old.getName()); unsubscribedSubredditNames.add(old.getQualified_name());
break; break;
} }
} }

View File

@ -25,6 +25,6 @@ public interface BlockedCommunityDao {
@Query("SELECT * FROM blocked_communities WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1") @Query("SELECT * FROM blocked_communities WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
BlockedCommunityData getBlockedCommunity(String name, String accountName); BlockedCommunityData getBlockedCommunity(String name, String accountName);
@Query("DELETE FROM blocked_communities WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE") @Query("DELETE FROM blocked_communities WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
void deleteBlockedCommunity(String name, String accountName); void deleteBlockedCommunity(String name, String accountName);
} }

View File

@ -26,6 +26,6 @@ public interface BlockedUserDao {
@Query("SELECT * FROM blocked_users WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1") @Query("SELECT * FROM blocked_users WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
BlockedUserData getBlockedUser(String name, String accountName); BlockedUserData getBlockedUser(String name, String accountName);
@Query("DELETE FROM blocked_users WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE") @Query("DELETE FROM blocked_users WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
void deleteBlockedUser(String name, String accountName); void deleteBlockedUser(String name, String accountName);
} }