Compare commits
3 Commits
e04bb29bb2
...
dfddd3d3d0
Author | SHA1 | Date | |
---|---|---|---|
dfddd3d3d0 | |||
26e01bb7f8 | |||
5f88626ddf |
@ -89,7 +89,10 @@
|
||||
"speeddialJoinGroupchat": "Join groupchat",
|
||||
"overlaySettings": "Settings",
|
||||
"noOpenChats": "You have no open chats",
|
||||
"startChat": "Start a chat"
|
||||
"startChat": "Start a chat",
|
||||
"closeChat": "Close chat",
|
||||
"closeChatBody": "Are you sure you want to close the chat with ${conversationTitle}?",
|
||||
"markAsRead": "Mark as read"
|
||||
},
|
||||
"conversation": {
|
||||
"unencrypted": "Unencrypted",
|
||||
|
@ -89,7 +89,10 @@
|
||||
"speeddialJoinGroupchat": "Gruppenchat beitreten",
|
||||
"overlaySettings": "Einstellungen",
|
||||
"noOpenChats": "Du hast keine offenen chats",
|
||||
"startChat": "Einen chat anfangen"
|
||||
"startChat": "Einen chat anfangen",
|
||||
"closeChat": "Chat schließen",
|
||||
"closeChatBody": "Bist du dir sicher, dass du den Chat mit ${conversationTitle} schließen möchtest?",
|
||||
"markAsRead": "Als gelesen markieren"
|
||||
},
|
||||
"conversation": {
|
||||
"unencrypted": "Unverschlüsselt",
|
||||
|
@ -387,13 +387,19 @@ files:
|
||||
implements:
|
||||
- JsonImplementation
|
||||
attributes:
|
||||
- name: RetractMessageComment
|
||||
- name: RetractMessageCommentCommand
|
||||
extends: BackgroundCommand
|
||||
implements:
|
||||
- JsonImplementation
|
||||
attributes:
|
||||
originId: String
|
||||
conversationJid: String
|
||||
- name: MarkConversationAsReadCommand
|
||||
extends: BackgroundCommand
|
||||
implements:
|
||||
- JsonImplementation
|
||||
attributes:
|
||||
conversationId: int
|
||||
generate_builder: true
|
||||
# get${builder_Name}FromJson
|
||||
builder_name: "Command"
|
||||
|
@ -62,7 +62,8 @@ void setupBackgroundEventHandler() {
|
||||
EventTypeMatcher<GetOwnOmemoFingerprintsCommand>(performGetOwnOmemoFingerprints),
|
||||
EventTypeMatcher<RemoveOwnDeviceCommand>(performRemoveOwnDevice),
|
||||
EventTypeMatcher<RegenerateOwnDeviceCommand>(performRegenerateOwnDevice),
|
||||
EventTypeMatcher<RetractMessageComment>(performMessageRetraction),
|
||||
EventTypeMatcher<RetractMessageCommentCommand>(performMessageRetraction),
|
||||
EventTypeMatcher<MarkConversationAsReadCommand>(performMarkConversationAsRead),
|
||||
]);
|
||||
|
||||
GetIt.I.registerSingleton<EventHandler>(handler);
|
||||
@ -584,7 +585,7 @@ Future<void> performRegenerateOwnDevice(RegenerateOwnDeviceCommand command, { dy
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> performMessageRetraction(RetractMessageComment command, { dynamic extra }) async {
|
||||
Future<void> performMessageRetraction(RetractMessageCommentCommand command, { dynamic extra }) async {
|
||||
await GetIt.I.get<MessageService>().retractMessage(
|
||||
command.conversationJid,
|
||||
command.originId,
|
||||
@ -604,3 +605,18 @@ Future<void> performMessageRetraction(RetractMessageComment command, { dynamic e
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> performMarkConversationAsRead(MarkConversationAsReadCommand command, { dynamic extra }) async {
|
||||
final conversation = await GetIt.I.get<ConversationService>().updateConversation(
|
||||
command.conversationId,
|
||||
unreadCounter: 0,
|
||||
);
|
||||
|
||||
// TODO(PapaTutuWawa): Send read marker as well
|
||||
sendEvent(ConversationUpdatedEvent(conversation: conversation));
|
||||
|
||||
// Dismiss notifications for that chat
|
||||
await GetIt.I.get<NotificationsService>().dismissNotificationsByJid(
|
||||
conversation.jid,
|
||||
);
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ class ConversationBloc extends Bloc<ConversationEvent, ConversationState> {
|
||||
|
||||
Future<void> _onMessageRetracted(MessageRetractedEvent event, Emitter<ConversationState> emit) async {
|
||||
await MoxplatformPlugin.handler.getDataSender().sendData(
|
||||
RetractMessageComment(
|
||||
RetractMessageCommentCommand(
|
||||
originId: event.id,
|
||||
conversationJid: state.conversation!.jid,
|
||||
),
|
||||
|
@ -17,6 +17,7 @@ class ConversationsBloc extends Bloc<ConversationsEvent, ConversationsState> {
|
||||
on<ConversationsUpdatedEvent>(_onConversationsUpdated);
|
||||
on<AvatarChangedEvent>(_onAvatarChanged);
|
||||
on<ConversationClosedEvent>(_onConversationClosed);
|
||||
on<ConversationMarkedAsReadEvent>(_onConversationMarkedAsRead);
|
||||
}
|
||||
|
||||
Future<void> _onInit(ConversationsInitEvent event, Emitter<ConversationsState> emit) async {
|
||||
@ -81,4 +82,11 @@ class ConversationsBloc extends Bloc<ConversationsEvent, ConversationsState> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onConversationMarkedAsRead(ConversationMarkedAsReadEvent event, Emitter<ConversationsState> emit) async {
|
||||
await MoxplatformPlugin.handler.getDataSender().sendData(
|
||||
MarkConversationAsReadCommand(conversationId: event.id),
|
||||
awaitable: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ abstract class ConversationsEvent {}
|
||||
|
||||
/// Triggered when we got the first data
|
||||
class ConversationsInitEvent extends ConversationsEvent {
|
||||
|
||||
ConversationsInitEvent(
|
||||
this.displayName,
|
||||
this.jid,
|
||||
@ -21,28 +20,31 @@ class ConversationsInitEvent extends ConversationsEvent {
|
||||
|
||||
/// Triggered when a conversation has been added.
|
||||
class ConversationsAddedEvent extends ConversationsEvent {
|
||||
|
||||
ConversationsAddedEvent(this.conversation);
|
||||
final Conversation conversation;
|
||||
}
|
||||
|
||||
/// Triggered when a conversation got updated
|
||||
class ConversationsUpdatedEvent extends ConversationsEvent {
|
||||
|
||||
ConversationsUpdatedEvent(this.conversation);
|
||||
final Conversation conversation;
|
||||
}
|
||||
|
||||
/// Triggered when the avatar of the logged-in user has changed
|
||||
class AvatarChangedEvent extends ConversationsEvent {
|
||||
|
||||
AvatarChangedEvent(this.path);
|
||||
final String path;
|
||||
}
|
||||
|
||||
/// Triggered by the UI when a conversation has been closed
|
||||
class ConversationClosedEvent extends ConversationsEvent {
|
||||
|
||||
ConversationClosedEvent(this.jid);
|
||||
final String jid;
|
||||
}
|
||||
|
||||
/// Triggered by the UI when a conversation has been marked as read, i.e.
|
||||
/// its unreadCounter should be set to zero
|
||||
class ConversationMarkedAsReadEvent extends ConversationsEvent {
|
||||
ConversationMarkedAsReadEvent(this.id);
|
||||
final int id;
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
||||
|
||||
return Dismissible(
|
||||
key: ValueKey('conversation;$item'),
|
||||
// TODO(Unknown): Show a snackbar allowing the user to revert the action
|
||||
onDismissed: (direction) => context.read<ConversationsBloc>().add(
|
||||
ConversationClosedEvent(item.jid),
|
||||
),
|
||||
@ -111,25 +112,38 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
||||
...item.unreadCounter != 0 ? [
|
||||
OverviewMenuItem(
|
||||
icon: Icons.done_all,
|
||||
text: 'Mark as read',
|
||||
text: t.pages.conversations.markAsRead,
|
||||
onPressed: () {
|
||||
// TODO(PapaTutuWawa): Implement
|
||||
showNotImplementedDialog(
|
||||
'marking as read',
|
||||
context,
|
||||
context.read<ConversationsBloc>().add(
|
||||
ConversationMarkedAsReadEvent(item.id),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
] : [],
|
||||
OverviewMenuItem(
|
||||
icon: Icons.close,
|
||||
text: 'Close chat',
|
||||
onPressed: () {
|
||||
// TODO(PapaTutuWawa): Implement
|
||||
showNotImplementedDialog(
|
||||
'closing the chat from here',
|
||||
text: t.pages.conversations.closeChat,
|
||||
onPressed: () async {
|
||||
// ignore: use_build_context_synchronously
|
||||
final result = await showConfirmationDialog(
|
||||
t.pages.conversations.closeChat,
|
||||
t.pages.conversations.closeChatBody(
|
||||
conversationTitle: item.title,
|
||||
),
|
||||
context,
|
||||
);
|
||||
|
||||
if (result) {
|
||||
// TODO(Unknown): Show a snackbar allowing the user to revert the action
|
||||
// ignore: use_build_context_synchronously
|
||||
context.read<ConversationsBloc>().add(
|
||||
ConversationClosedEvent(item.jid),
|
||||
);
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user