mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 10:38:41 +00:00
fix #92
This commit is contained in:
parent
85dbac37fb
commit
c98c044f3c
5 changed files with 15 additions and 6 deletions
|
|
@ -152,7 +152,11 @@ class _MessageSendStateIconState extends State<MessageSendStateIcon> {
|
|||
text = "Unknown error.";
|
||||
}
|
||||
|
||||
icons.add(icon);
|
||||
if (message.kind == MessageKind.media) {
|
||||
icons.insert(0, icon);
|
||||
} else {
|
||||
icons.add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
if (icons.isEmpty) return Container();
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ Future initFCMService() async {
|
|||
String title = message.notification!.title ?? "";
|
||||
String body = message.notification!.body ?? "";
|
||||
customLocalPushNotification(title, body);
|
||||
}
|
||||
if (message.data["push_data"] != null) {
|
||||
} else if (message.data["push_data"] != null) {
|
||||
handlePushData(message.data["push_data"]);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
twonlyDatabase.messagesDao.watchAllMessagesFrom(widget.userid);
|
||||
messageSub = msgStream.listen((msgs) {
|
||||
if (!context.mounted) return;
|
||||
flutterLocalNotificationsPlugin.cancel(widget.userid);
|
||||
var updated = false;
|
||||
List<Message> displayedMessages = [];
|
||||
// should be cleared
|
||||
|
|
@ -239,7 +240,6 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
msg.messageOtherId != null &&
|
||||
msg.openedAt == null) {
|
||||
updated = true;
|
||||
flutterLocalNotificationsPlugin.cancel(msg.messageId);
|
||||
notifyContactAboutOpeningMessage(widget.userid, msg.messageOtherId!);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,8 @@ class _UserListItem extends State<UserListItem> {
|
|||
List<Message> lastMessages = [];
|
||||
late StreamSubscription<List<Message>> lastMessageStream;
|
||||
|
||||
List<Message> previewMessages = [];
|
||||
|
||||
Timer? updateTime;
|
||||
|
||||
@override
|
||||
|
|
@ -195,9 +197,11 @@ class _UserListItem extends State<UserListItem> {
|
|||
if (newLastMessages.isEmpty) {
|
||||
// there are no messages at all
|
||||
currentMessage = null;
|
||||
previewMessages = [];
|
||||
} else if (newMessagesNotOpened.isEmpty) {
|
||||
// there are no not opened messages show just the last message in the table
|
||||
currentMessage = newLastMessages.first;
|
||||
previewMessages = newLastMessages;
|
||||
} else {
|
||||
// filter first for received messages
|
||||
final receivedMessages =
|
||||
|
|
@ -213,6 +217,7 @@ class _UserListItem extends State<UserListItem> {
|
|||
} else {
|
||||
currentMessage = receivedMessages.first;
|
||||
}
|
||||
previewMessages = receivedMessages;
|
||||
} else {
|
||||
// The not opened message was send
|
||||
final mediaMessages =
|
||||
|
|
@ -223,6 +228,7 @@ class _UserListItem extends State<UserListItem> {
|
|||
} else {
|
||||
currentMessage = newMessagesNotOpened.first;
|
||||
}
|
||||
previewMessages = [currentMessage!];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +274,7 @@ class _UserListItem extends State<UserListItem> {
|
|||
? Text(context.lang.chatsTapToSend)
|
||||
: Row(
|
||||
children: [
|
||||
MessageSendStateIcon(lastMessages),
|
||||
MessageSendStateIcon(previewMessages),
|
||||
Text("•"),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
}
|
||||
}
|
||||
}
|
||||
flutterLocalNotificationsPlugin.cancel(current.messageId);
|
||||
flutterLocalNotificationsPlugin.cancel(current.contactId);
|
||||
if (current.downloadState == DownloadState.pending) {
|
||||
setState(() {
|
||||
isDownloading = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue