mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Use WebSocket to update likes
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// WebSocket message
|
||||
@ -14,12 +16,21 @@ class WsMessage {
|
||||
@required this.title,
|
||||
@required this.data,
|
||||
}) : assert(id != null),
|
||||
assert(title != null);
|
||||
assert(title != null),
|
||||
assert(title.length > 0);
|
||||
|
||||
/// Construct a message from a JSON document (messages coming from the server)
|
||||
static WsMessage fromJSON(final Map<dynamic, dynamic> m) {
|
||||
return WsMessage(id: m["id"], title: m["title"], data: m["data"]);
|
||||
}
|
||||
|
||||
/// Turn a message into a JSON object to send it to the API
|
||||
String toJSON() =>
|
||||
jsonEncode({
|
||||
"id": id,
|
||||
"title": title,
|
||||
"data": data,
|
||||
});
|
||||
|
||||
bool get hasId => this.id != null && this.id.isNotEmpty;
|
||||
}
|
||||
|
Reference in New Issue
Block a user