This commit is contained in:
otsmr 2025-07-24 22:27:28 +02:00
parent 02045e8fc0
commit 8979c44e53

View file

@ -298,6 +298,7 @@ class _UserListItem extends State<UserListItem> {
late StreamSubscription<List<Message>> lastMessageStream;
List<Message> previewMessages = [];
bool hasNonOpenedMediaFile = false;
@override
void initState() {
@ -352,6 +353,17 @@ class _UserListItem extends State<UserListItem> {
}
}
final msgs =
previewMessages.where((x) => x.kind == MessageKind.media).toList();
if (msgs.isNotEmpty &&
msgs.first.kind == MessageKind.media &&
msgs.first.messageOtherId != null &&
msgs.first.openedAt == null) {
hasNonOpenedMediaFile = true;
} else {
hasNonOpenedMediaFile = false;
}
lastMessages = newLastMessages;
messagesNotOpened = newMessagesNotOpened;
setState(() {
@ -368,12 +380,10 @@ class _UserListItem extends State<UserListItem> {
));
return;
}
if (hasNonOpenedMediaFile) {
final msgs =
previewMessages.where((x) => x.kind == MessageKind.media).toList();
if (msgs.isNotEmpty &&
msgs.first.kind == MessageKind.media &&
msgs.first.messageOtherId != null &&
msgs.first.openedAt == null) {
switch (msgs.first.downloadState) {
case DownloadState.pending:
await startDownloadMedia(msgs.first, true);
@ -447,12 +457,18 @@ class _UserListItem extends State<UserListItem> {
onPressed: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) {
if (hasNonOpenedMediaFile) {
return ChatMessagesView(widget.user);
} else {
return CameraSendToView(widget.user);
}
},
));
},
icon: FaIcon(
FontAwesomeIcons.camera,
hasNonOpenedMediaFile
? FontAwesomeIcons.solidComments
: FontAwesomeIcons.camera,
color: context.color.outline.withAlpha(150),
),
),