Update cache with actions

This commit is contained in:
tom79 2019-05-18 12:10:08 +02:00
parent 6a4f1e659f
commit 8a4f7f65a2
2 changed files with 10 additions and 0 deletions

View File

@ -2138,6 +2138,8 @@ public class API {
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).update(targetedId, resp);
}
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -2153,6 +2155,8 @@ public class API {
HttpsConnection httpsConnection = new HttpsConnection(context);
httpsConnection.delete(getAbsoluteUrl(action), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).remove(targetedId);
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {

View File

@ -53,6 +53,7 @@ import app.fedilab.android.fragments.DisplayNotificationsFragment;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.sqlite.AccountDAO;
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.TimelineCacheDAO;
import static app.fedilab.android.helper.Helper.PREF_KEY_OAUTH_TOKEN;
@ -1393,6 +1394,11 @@ public class GNUAPI {
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).update(targetedId, resp);
}else if( statusAction == API.StatusAction.UNSTATUS){
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).remove(targetedId);
}
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);