Whole in timelines due to cache bug

This commit is contained in:
Thomas 2023-08-14 16:56:40 +02:00
parent 9b91ebf317
commit be54c49918
2 changed files with 58 additions and 10 deletions

View file

@ -555,15 +555,28 @@ public class StatusCache {
String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_TYPE + "= '" + Timeline.TimeLineEnum.NOTIFICATION.getValue() + "' "; String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_TYPE + "= '" + Timeline.TimeLineEnum.NOTIFICATION.getValue() + "' ";
String limit = String.valueOf(MastodonHelper.statusesPerCall(context)); String limit = String.valueOf(MastodonHelper.statusesPerCall(context));
if (min_id != null) { if (min_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' "; if (Helper.isNumeric(min_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + min_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' ";
}
order = " ASC"; order = " ASC";
} else if (max_id != null) { } else if (max_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' "; if (Helper.isNumeric(max_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < cast(" + max_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' ";
}
} else if (since_id != null) { } else if (since_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' "; if (Helper.isNumeric(since_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + since_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' ";
}
limit = null; limit = null;
} }
if (exclude_type != null && exclude_type.size() > 0) { if (exclude_type != null && exclude_type.size() > 0) {
StringBuilder exclude = new StringBuilder(); StringBuilder exclude = new StringBuilder();
for (String excluded : exclude_type) { for (String excluded : exclude_type) {
@ -600,12 +613,25 @@ public class StatusCache {
String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_TYPE + "= '" + Timeline.TimeLineEnum.CONVERSATION.getValue() + "' "; String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_TYPE + "= '" + Timeline.TimeLineEnum.CONVERSATION.getValue() + "' ";
String limit = String.valueOf(MastodonHelper.statusesPerCall(context)); String limit = String.valueOf(MastodonHelper.statusesPerCall(context));
if (min_id != null) { if (min_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' "; if (Helper.isNumeric(min_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + min_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' ";
}
order = " ASC"; order = " ASC";
} else if (max_id != null) { } else if (max_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' ";
if (Helper.isNumeric(max_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < cast(" + max_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' ";
}
} else if (since_id != null) { } else if (since_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' "; if (Helper.isNumeric(since_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + since_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' ";
}
limit = null; limit = null;
} }
try { try {
@ -636,12 +662,25 @@ public class StatusCache {
String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_SLUG + "= '" + slug + "' "; String selection = Sqlite.COL_INSTANCE + "='" + instance + "' AND " + Sqlite.COL_USER_ID + "= '" + user_id + "' AND " + Sqlite.COL_SLUG + "= '" + slug + "' ";
String limit = String.valueOf(MastodonHelper.statusesPerCall(context)); String limit = String.valueOf(MastodonHelper.statusesPerCall(context));
if (min_id != null) { if (min_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' ";
if (Helper.isNumeric(min_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + min_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + min_id + "' ";
}
order = " ASC"; order = " ASC";
} else if (max_id != null) { } else if (max_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' "; if (Helper.isNumeric(max_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " < cast(" + max_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' ";
}
} else if (since_id != null) { } else if (since_id != null) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' "; if (Helper.isNumeric(since_id)) {
selection += "AND " + Sqlite.COL_STATUS_ID + " > cast(" + since_id + " as int) ";
} else {
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' ";
}
limit = null; limit = null;
} }
try { try {

View file

@ -2072,4 +2072,13 @@ public class Helper {
public interface OnFileCopied { public interface OnFileCopied {
void onFileCopied(File file); void onFileCopied(File file);
} }
public static boolean isNumeric(String str) {
try {
Double.parseDouble(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
} }