update gap in database when deleting status
closes sk22#898
This commit is contained in:
parent
375b5b3133
commit
a18a4383e5
|
@ -273,7 +273,28 @@ public class CacheController{
|
|||
|
||||
public void deleteStatus(String id){
|
||||
runOnDbThread((db)->{
|
||||
// TODO: set previous status's hasGapAfter flag if the deleted status hasGapAfter
|
||||
String gapId=null;
|
||||
int gapFlags=0;
|
||||
// select to-be-removed and newer row
|
||||
try(Cursor cursor=db.query("home_timeline", new String[]{"id", "flags"}, "`time`>=(SELECT `time` FROM `home_timeline` WHERE `id`=?)", new String[]{id}, null, null, "`time` ASC", "2")){
|
||||
boolean hadGapAfter=false;
|
||||
// always either one or two iterations (only one if there's no newer post)
|
||||
while(cursor.moveToNext()){
|
||||
String currentId=cursor.getString(0);
|
||||
int currentFlags=cursor.getInt(1);
|
||||
if(currentId.equals(id)){
|
||||
hadGapAfter=((currentFlags & POST_FLAG_GAP_AFTER)!=0);
|
||||
}else if(hadGapAfter){
|
||||
gapFlags=currentFlags|POST_FLAG_GAP_AFTER;
|
||||
gapId=currentId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(gapId!=null){
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("flags", gapFlags);
|
||||
db.update("home_timeline", values, "`id`=?", new String[]{gapId});
|
||||
}
|
||||
db.delete("home_timeline", "`id`=?", new String[]{id});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue