fix: media file not opened if downloaded

This commit is contained in:
otsmr 2026-04-24 11:29:42 +02:00
parent a29af4c914
commit eed5d292c6
3 changed files with 38 additions and 37 deletions

View file

@ -203,7 +203,8 @@ class _UserListItem extends State<GroupListItemComp> {
await startDownloadMedia(mediaFile, true);
return;
}
if (mediaFile.downloadState! == DownloadState.ready) {
if (mediaFile.downloadState! == DownloadState.ready ||
mediaFile.downloadState! == DownloadState.downloaded) {
if (!mounted) return;
await context.push(
Routes.chatsMediaViewer,

View file

@ -88,7 +88,9 @@ class _ChatMediaEntryState extends State<ChatMediaEntry> {
}
Future<void> onTap() async {
if (widget.mediaService.mediaFile.downloadState == DownloadState.ready &&
if ((widget.mediaService.mediaFile.downloadState == DownloadState.ready ||
widget.mediaService.mediaFile.downloadState ==
DownloadState.downloaded) &&
widget.message.openedAt == null) {
if (!mounted) return;
await Navigator.push(

View file

@ -107,11 +107,9 @@ class _MediaViewerViewState extends State<MediaViewerView> {
final Mutex _messageUpdateLock = Mutex();
Future<void> asyncLoadNextMedia(bool firstRun) async {
final messages = twonlyDB.messagesDao.watchMediaNotOpened(
widget.group.groupId,
);
_subscription = messages.listen((messages) async {
_subscription = twonlyDB.messagesDao
.watchMediaNotOpened(widget.group.groupId)
.listen((messages) async {
await _messageUpdateLock.protect(() async {
for (final msg in messages) {
if (_alreadyOpenedMediaIds.contains(msg.mediaId)) {