mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-13 11:42:17 -04:00
better message status support
This commit is contained in:
parent
4f02435964
commit
809f6d69bf
31 changed files with 1046 additions and 248 deletions
34
lib/chat/models/message_state.dart
Normal file
34
lib/chat/models/message_state.dart
Normal file
|
@ -0,0 +1,34 @@
|
|||
import 'package:change_case/change_case.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
part 'message_state.freezed.dart';
|
||||
part 'message_state.g.dart';
|
||||
|
||||
// Whether or not a message has been fully sent
|
||||
enum MessageSendState {
|
||||
// message is still being sent
|
||||
sending,
|
||||
// message issued has not reached the network
|
||||
sent,
|
||||
// message was sent and has reached the network
|
||||
delivered;
|
||||
|
||||
factory MessageSendState.fromJson(dynamic j) =>
|
||||
MessageSendState.values.byName((j as String).toCamelCase());
|
||||
String toJson() => name.toPascalCase();
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MessageState with _$MessageState {
|
||||
const factory MessageState({
|
||||
required TypedKey author,
|
||||
required Timestamp timestamp,
|
||||
required String text,
|
||||
required MessageSendState? sendState,
|
||||
}) = _MessageState;
|
||||
|
||||
factory MessageState.fromJson(dynamic json) =>
|
||||
_$MessageStateFromJson(json as Map<String, dynamic>);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue