mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 13:09:24 +01:00
Clean up
This commit is contained in:
parent
6f281bc0cd
commit
a861f221a3
@ -110,14 +110,12 @@ abstract class FirebaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the client
|
// Get the client
|
||||||
print("Get client");
|
|
||||||
Client client;
|
Client client;
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
client = Matrix.of(context).client;
|
client = Matrix.of(context).client;
|
||||||
} else {
|
} else {
|
||||||
final platform = kIsWeb ? "Web" : Platform.operatingSystem;
|
final platform = kIsWeb ? "Web" : Platform.operatingSystem;
|
||||||
final clientName = "FluffyChat $platform";
|
final clientName = "FluffyChat $platform";
|
||||||
print("Clientname: $clientName");
|
|
||||||
client = Client(clientName, debug: false);
|
client = Client(clientName, debug: false);
|
||||||
client.storeAPI = ExtendedStore(client);
|
client.storeAPI = ExtendedStore(client);
|
||||||
await client.onLoginStateChanged.stream
|
await client.onLoginStateChanged.stream
|
||||||
@ -128,25 +126,23 @@ abstract class FirebaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the room
|
// Get the room
|
||||||
print("Get room");
|
|
||||||
Room room = client.getRoomById(roomId);
|
Room room = client.getRoomById(roomId);
|
||||||
if (room == null) {
|
if (room == null) {
|
||||||
await client.onRoomUpdate.stream
|
await client.onRoomUpdate.stream
|
||||||
.where((u) => u.id == roomId)
|
.where((u) => u.id == roomId)
|
||||||
.first
|
.first
|
||||||
.timeout(Duration(seconds: 10));
|
.timeout(Duration(seconds: 5));
|
||||||
room = client.getRoomById(roomId);
|
room = client.getRoomById(roomId);
|
||||||
if (room == null) return null;
|
if (room == null) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
print("Get event");
|
|
||||||
Event event = await client.store.getEventById(eventId, room);
|
Event event = await client.store.getEventById(eventId, room);
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
final EventUpdate eventUpdate = await client.onEvent.stream
|
final EventUpdate eventUpdate = await client.onEvent.stream
|
||||||
.where((u) => u.content["event_id"] == eventId)
|
.where((u) => u.content["event_id"] == eventId)
|
||||||
.first
|
.first
|
||||||
.timeout(Duration(seconds: 10));
|
.timeout(Duration(seconds: 5));
|
||||||
event = Event.fromJson(eventUpdate.content, room);
|
event = Event.fromJson(eventUpdate.content, room);
|
||||||
if (room == null) return null;
|
if (room == null) return null;
|
||||||
}
|
}
|
||||||
@ -209,6 +205,7 @@ abstract class FirebaseController {
|
|||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
debugPrint("[Push] Error while processing notification: " +
|
debugPrint("[Push] Error while processing notification: " +
|
||||||
exception.toString());
|
exception.toString());
|
||||||
|
return _handleOnBackgroundMessage(message);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user