Skip to content

Commit

Permalink
MessageLogger - Fix setting not saving correctly (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
RazerTexz authored Jul 16, 2024
1 parent b4aaa78 commit d1a13c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion MessageLogger/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
version = "1.1.3"
version = "1.1.4"
description = "Saves deleted / edited messages to a SQLite database and restores them when the channel is opened."

aliucord.changelog.set("""
1.1.4
======================
* fix setting not saving correctly
1.1.3
======================
* fix spamming debug logs with NPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ public void clearChannels() {
}

public void setBoolSetting(String key, Boolean value) {
String query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?";
String query = "SELECT * FROM " + TABLE_NAME_SETTINGS + " WHERE name = ?";
try (Cursor cursor = db.rawQuery(query, new String[]{ key })) {
if (cursor.getCount() == 0) {
query = "INSERT INTO " + TABLE_NAME_SETTINGS + " (name, value) VALUES (?, ?)";
db.execSQL(query, new Object[]{ key, String.valueOf(value) });
} else {
query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?";
db.execSQL(query, new Object[]{ String.valueOf(value), key });
}
}
}
Expand Down

0 comments on commit d1a13c2

Please sign in to comment.