update gap in database when deleting status
closes sk22#898
This commit is contained in:
@@ -273,7 +273,28 @@ public class CacheController{
|
|||||||
|
|
||||||
public void deleteStatus(String id){
|
public void deleteStatus(String id){
|
||||||
runOnDbThread((db)->{
|
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});
|
db.delete("home_timeline", "`id`=?", new String[]{id});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user