Fix pagination from db

This commit is contained in:
Thomas 2022-11-22 12:32:16 +01:00
parent 0bcb4e0fca
commit 28e10ddc82
2 changed files with 5 additions and 7 deletions

View File

@ -242,7 +242,6 @@ public class StatusCache {
} }
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_STATUS_CACHE Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_STATUS_CACHE
+ " where " + Sqlite.COL_TYPE + " != '" + Timeline.TimeLineEnum.HOME.getValue() + "'" + " where " + Sqlite.COL_TYPE + " != '" + Timeline.TimeLineEnum.HOME.getValue() + "'"
+ " AND " + Sqlite.COL_INSTANCE + " = '" + baseAccount.instance + "'"
+ " AND " + Sqlite.COL_USER_ID + "= '" + baseAccount.user_id + "'", null); + " AND " + Sqlite.COL_USER_ID + "= '" + baseAccount.user_id + "'", null);
mCount.moveToFirst(); mCount.moveToFirst();
int count = mCount.getInt(0); int count = mCount.getInt(0);
@ -465,8 +464,8 @@ public class StatusCache {
} }
try { try {
return db.delete(Sqlite.TABLE_STATUS_CACHE, return db.delete(Sqlite.TABLE_STATUS_CACHE,
Sqlite.COL_TYPE + " != ? AND " + Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?", Sqlite.COL_TYPE + " != ? AND " + Sqlite.COL_USER_ID + " = ?",
new String[]{Timeline.TimeLineEnum.HOME.getValue(), account.user_id, account.instance}); new String[]{Timeline.TimeLineEnum.HOME.getValue(), account.user_id});
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return -1; return -1;
@ -552,7 +551,7 @@ public class StatusCache {
selection += "AND " + Sqlite.COL_SLUG + " NOT IN (" + exclude + ") "; selection += "AND " + Sqlite.COL_SLUG + " NOT IN (" + exclude + ") ";
} }
try { try {
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + order, limit); Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + " + 0 " + order, limit);
return cursorToListOfNotifications(c); return cursorToListOfNotifications(c);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -588,7 +587,7 @@ public class StatusCache {
limit = null; limit = null;
} }
try { try {
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + order, limit); Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + " + 0 " + order, limit);
return cursorToListOfConversations(c); return cursorToListOfConversations(c);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -624,7 +623,7 @@ public class StatusCache {
limit = null; limit = null;
} }
try { try {
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + order, limit); Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, Sqlite.COL_STATUS_ID, null, Sqlite.COL_STATUS_ID + " + 0 " + order, limit);
return cursorToListOfStatuses(c); return cursorToListOfStatuses(c);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -177,7 +177,6 @@ public class TimelineHelper {
public static List<Notification> filterNotification(Context context, List<Notification> notifications) { public static List<Notification> filterNotification(Context context, List<Notification> notifications) {
//A security to make sure filters have been fetched before displaying messages //A security to make sure filters have been fetched before displaying messages
List<Notification> notificationToRemove = new ArrayList<>(); List<Notification> notificationToRemove = new ArrayList<>();
if (!BaseMainActivity.filterFetched) { if (!BaseMainActivity.filterFetched) {
try { try {
FiltersVM filtersVM = new ViewModelProvider((ViewModelStoreOwner) context).get(FiltersVM.class); FiltersVM filtersVM = new ViewModelProvider((ViewModelStoreOwner) context).get(FiltersVM.class);