Fix notifications not removed from cache

This commit is contained in:
Thomas 2022-10-17 17:51:26 +02:00
parent b0eb52cf94
commit b7ee38e37b
3 changed files with 27 additions and 0 deletions

View File

@ -409,6 +409,26 @@ public class StatusCache {
}
}
/**
* delete all cached notification for an account
*
* @return long - db id
* @throws DBException exception with database
*/
public long deleteNotifications() throws DBException {
if (db == null) {
throw new DBException("db is null. Wrong initialization.");
}
try {
return db.delete(Sqlite.TABLE_STATUS_CACHE,
Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =? AND " + Sqlite.COL_TYPE + "=?",
new String[]{MainActivity.currentUserID, MainActivity.currentInstance, Timeline.TimeLineEnum.NOTIFICATION.getValue()});
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
/**
* delete all cache for an account
*

View File

@ -420,6 +420,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
*/
public void addSharing(String url, String title, String description, String subject, String content, String saveFilePath) {
if (description == null && content == null) {
return;
}
int position = statusList.size() - 1;
statusList.get(position).text = "";
if (title != null && title.trim().length() > 0) {

View File

@ -231,6 +231,10 @@ public class NotificationsVM extends AndroidViewModel {
MastodonNotificationsService mastodonNotificationsService = init(instance);
new Thread(() -> {
Call<Void> voidCall = mastodonNotificationsService.clearAllNotifications(token);
try {
new StatusCache(getApplication().getApplicationContext()).deleteNotifications();
} catch (Exception ignored) {
}
if (voidCall != null) {
try {
voidCall.execute();