[Event] Make delete function async
This commit is contained in:
parent
4e3c1b271b
commit
de55c201fc
|
|
@ -171,10 +171,11 @@ class Event {
|
||||||
|
|
||||||
/// Removes this event if the status is < 1. This event will just be removed
|
/// Removes this event if the status is < 1. This event will just be removed
|
||||||
/// from the database and the timelines. Returns false if not removed.
|
/// from the database and the timelines. Returns false if not removed.
|
||||||
bool remove() {
|
Future<bool> remove() async {
|
||||||
if (status < 1) {
|
if (status < 1) {
|
||||||
if (room.client.store != null)
|
if (room.client.store != null)
|
||||||
room.client.store.db.rawDelete("DELETE FROM Events WHERE id=?", [id]);
|
await room.client.store.db
|
||||||
|
.rawDelete("DELETE FROM Events WHERE id=?", [id]);
|
||||||
|
|
||||||
room.client.connection.onEvent.add(EventUpdate(
|
room.client.connection.onEvent.add(EventUpdate(
|
||||||
roomID: room.id,
|
roomID: room.id,
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,11 @@ void main() {
|
||||||
test("remove", () async {
|
test("remove", () async {
|
||||||
Event event = Event.fromJson(
|
Event event = Event.fromJson(
|
||||||
jsonObj, Room(id: "1234", client: Client("testclient", debug: true)));
|
jsonObj, Room(id: "1234", client: Client("testclient", debug: true)));
|
||||||
expect(event.remove(), false);
|
final bool removed1 = await event.remove();
|
||||||
event.status = 0;
|
event.status = 0;
|
||||||
expect(event.remove(), true);
|
final bool removed2 = await event.remove();
|
||||||
|
expect(removed1, false);
|
||||||
|
expect(removed2, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sendAgain", () async {
|
test("sendAgain", () async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue