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