mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-31 03:54:30 -04:00
messages wip
This commit is contained in:
parent
17f6dfce46
commit
9c5feed732
18 changed files with 274 additions and 171 deletions
|
@ -30,10 +30,28 @@ class MessageState with _$MessageState {
|
|||
required proto.Message content,
|
||||
// Received or delivered timestamp
|
||||
required Timestamp timestamp,
|
||||
// The state of the mssage
|
||||
// The state of the message
|
||||
required MessageSendState? sendState,
|
||||
}) = _MessageState;
|
||||
|
||||
factory MessageState.fromJson(dynamic json) =>
|
||||
_$MessageStateFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
extension MessageStateExt on MessageState {
|
||||
String get uniqueId {
|
||||
final author = content.author.toVeilid().toString();
|
||||
final id = base64UrlNoPadEncode(content.id);
|
||||
return '$author|$id';
|
||||
}
|
||||
|
||||
static (proto.TypedKey, Uint8List) splitUniqueId(String uniqueId) {
|
||||
final parts = uniqueId.split('|');
|
||||
if (parts.length != 2) {
|
||||
throw Exception('invalid unique id');
|
||||
}
|
||||
final author = TypedKey.fromString(parts[0]).toProto();
|
||||
final id = base64UrlNoPadDecode(parts[1]);
|
||||
return (author, id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue