Commit 90016769 authored by Thomas's avatar Thomas
Browse files

Fix async actions with cached notifications

parent ef6319b7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
import static app.fedilab.android.mastodon.helper.Helper.TAG;
import static app.fedilab.android.mastodon.helper.Helper.displayReleaseNotesIfNeeded;
import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor;
import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.sendAction;
+0 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.activities;

import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.emojis;
import static app.fedilab.android.mastodon.helper.Helper.TAG;

import android.Manifest;
import android.annotation.SuppressLint;
@@ -35,7 +34,6 @@ import android.os.Looper;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ public class Status implements Serializable, Cloneable {
    @SerializedName("reactions")
    public List<Reaction> reactions;

    public String attachedNotification = null;

    public transient boolean isFetchMore = false;
    public transient boolean isFetching = false;
+16 −2
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.client.entities.app;
 * You should have received a copy of the GNU General Public License along with Fedilab; if not,
 * see <http://www.gnu.org/licenses>. */

import static app.fedilab.android.mastodon.helper.Helper.TAG;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@@ -289,7 +291,6 @@ public class StatusCache {
        if (statusCache.type != null) {
            query += " AND " + Sqlite.COL_TYPE + " = '" + statusCache.type.getValue() + "'";
        }

        Cursor mCount = db.rawQuery(query, null);
        mCount.moveToFirst();
        int count = mCount.getInt(0);
@@ -352,7 +353,11 @@ public class StatusCache {
            values.put(Sqlite.COL_STATUS, mastodonStatusToStringStorage(statusCache.status));
        }
        if (statusCache.notification != null) {
            values.put(Sqlite.COL_STATUS, mastodonNotificationToStringStorage(statusCache.notification));
            Notification currentNotification = getCachedNotification(statusCache);
            if(currentNotification != null && currentNotification.status != null) {
                currentNotification.status = statusCache.notification.status;
                values.put(Sqlite.COL_STATUS, mastodonNotificationToStringStorage(currentNotification));
            }
        }
        if (statusCache.conversation != null) {
            values.put(Sqlite.COL_STATUS, mastodonConversationToStringStorage(statusCache.conversation));
@@ -594,6 +599,15 @@ public class StatusCache {
        }
    }

    public Notification getCachedNotification(StatusCache statusCache) throws DBException  {
        if (db == null) {
            throw new DBException("db is null. Wrong initialization.");
        }
        Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, Sqlite.COL_STATUS_ID + " = ? AND " + Sqlite.COL_USER_ID + " =  ? AND " + Sqlite.COL_INSTANCE + " =?",
                new String[]{statusCache.status_id, statusCache.user_id, statusCache.instance}, null, null, null, "1");
        c.moveToFirst();
        return convertCursorToNotification(c);
    }

    /**
     * Get paginated conversations from db
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
 * see <http://www.gnu.org/licenses>. */


import static app.fedilab.android.mastodon.helper.Helper.TAG;

import android.content.Context;
import android.content.SharedPreferences;
Loading