Commit b7ee38e3 authored by Thomas's avatar Thomas
Browse files

Fix notifications not removed from cache

parent b0eb52cf
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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
     *
+3 −0
Original line number Diff line number Diff line
@@ -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) {
+4 −0
Original line number Diff line number Diff line
@@ -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();