mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-22 17:02:21 -05:00
Workaround: Remove identity assigned to server if server is deleted until we have some kind of identity manager
This commit is contained in:
parent
58bd63debd
commit
7e20226b51
@ -281,6 +281,16 @@ public class Database extends SQLiteOpenHelper
|
||||
*/
|
||||
public void removeServerById(int serverId)
|
||||
{
|
||||
// XXX: Workaround: Remove identity assigned to this server
|
||||
// until we have some kind of identity manager
|
||||
int identityId = this.getIdentityIdByServerId(serverId);
|
||||
if (identityId != -1) {
|
||||
this.getWritableDatabase().execSQL(
|
||||
"DELETE FROM " + IdentityConstants.TABLE_NAME + " WHERE " + IdentityConstants._ID + " = " + identityId + ";"
|
||||
);
|
||||
}
|
||||
|
||||
// Now delete the server entry
|
||||
this.getWritableDatabase().execSQL(
|
||||
"DELETE FROM " + ServerConstants.TABLE_NAME + " WHERE " + ServerConstants._ID + " = " + serverId + ";"
|
||||
);
|
||||
@ -361,4 +371,29 @@ public class Database extends SQLiteOpenHelper
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a server by its id
|
||||
*
|
||||
* @param serverId
|
||||
* @return
|
||||
*/
|
||||
private int getIdentityIdByServerId(int serverId)
|
||||
{
|
||||
Cursor cursor = this.getReadableDatabase().query(
|
||||
ServerConstants.TABLE_NAME,
|
||||
ServerConstants.ALL,
|
||||
ServerConstants._ID + "=" + serverId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
if (cursor.moveToNext()) {
|
||||
return cursor.getInt(cursor.getColumnIndex(ServerConstants.IDENTITY));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user