fixing multiple bugs

This commit is contained in:
otsmr 2025-10-26 23:06:49 +01:00
parent 7fe0f16a5c
commit c67bd6b464
4 changed files with 63 additions and 34 deletions

View file

@ -10,13 +10,13 @@ This repository contains the complete source code of the [twonly](https://twonly
- End-to-End encryption using the [Signal Protocol](https://de.wikipedia.org/wiki/Signal-Protokoll)
- No email or phone number required to register
- Privacy friendly - Everything is stored on the device
- Open-Source
## In work
- For Android: Using [UnifiedPush](https://unifiedpush.org/) instead of FCM
- For Android: Reproducible Builds + Publishing on Github/F-Droid
- For Android: Reproducible Builds + Publishing F-Droid
- Implementing [Sealed Sender](https://signal.org/blog/sealed-sender/) to minimize metadata
- Maybe: Switching from the Signal Protocol to [MLS](https://openmls.tech/).
## Security Issues
If you discover a security issue in twonly, please adhere to the coordinated vulnerability disclosure model. Please send
@ -33,8 +33,6 @@ guarantee a bounty currently :/
Some dependencies are downloaded directly from the source as there are some new changes which are not yet published on
pub.dev or because they require some special installation.
- `flutter_secure_storage`: We need the 10.0.0-beta version, but this version has some issues which are fixed but [not yet published](https://github.com/juliansteenbakker/flutter_secure_storage/issues/866):
```bash
git submodule update --init --recursive

View file

@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:twonly/globals.dart';
import 'package:twonly/src/database/daos/groups.dao.dart';
import 'package:twonly/src/database/tables/mediafiles.table.dart';
import 'package:twonly/src/database/twonly.db.dart';
import 'package:twonly/src/services/api/mediafiles/upload.service.dart';
import 'package:twonly/src/services/mediafiles/mediafile.service.dart';
@ -65,7 +64,6 @@ class _ShareImageView extends State<ShareImageView> {
await widget.mediaStoreFuture;
}
mediaStoreFutureReady = true;
await widget.mediaFileService.setUploadState(UploadState.preprocessing);
unawaited(startBackgroundMediaUpload(widget.mediaFileService));
if (!mounted) return;
setState(() {});

View file

@ -36,7 +36,30 @@ class ChatMediaEntry extends StatefulWidget {
class _ChatMediaEntryState extends State<ChatMediaEntry> {
GlobalKey reopenMediaFile = GlobalKey();
bool canBeReopened = false;
bool _canBeReopened = false;
@override
void initState() {
super.initState();
unawaited(initAsync());
}
Future<void> initAsync() async {
if (widget.message.senderId == null || widget.message.mediaStored) {
return;
}
if (widget.mediaService.mediaFile.requiresAuthentication ||
widget.mediaService.mediaFile.displayLimitInMilliseconds != null) {
return;
}
if (widget.mediaService.tempPath.existsSync()) {
if (mounted) {
setState(() {
_canBeReopened = true;
});
}
}
}
Future<void> onDoubleTap() async {
if (widget.message.openedAt == null || widget.message.mediaStored) {
@ -109,7 +132,7 @@ class _ChatMediaEntryState extends State<ChatMediaEntry> {
mediaService: widget.mediaService,
color: color,
galleryItems: widget.galleryItems,
canBeReopened: canBeReopened,
canBeReopened: _canBeReopened,
),
),
),

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:twonly/globals.dart';
import 'package:twonly/src/database/daos/contacts.dao.dart';
import 'package:twonly/src/database/tables/mediafiles.table.dart';
import 'package:twonly/src/database/tables/messages.table.dart';
import 'package:twonly/src/database/twonly.db.dart';
@ -128,22 +129,34 @@ class ResponsePreview extends StatefulWidget {
}
class _ResponsePreviewState extends State<ResponsePreview> {
Message? message;
MediaFileService? mediaService;
Message? _message;
MediaFileService? _mediaService;
String _username = '';
@override
void initState() {
message = widget.message;
_message = widget.message;
initAsync();
super.initState();
}
Future<void> initAsync() async {
message ??= await twonlyDB.messagesDao
_message ??= await twonlyDB.messagesDao
.getMessageById(widget.messageId!)
.getSingleOrNull();
if (message?.mediaId != null) {
mediaService = await MediaFileService.fromMediaId(message!.mediaId!);
if (_message?.mediaId != null) {
_mediaService = await MediaFileService.fromMediaId(_message!.mediaId!);
}
if (_message?.senderId != null) {
final contact = await twonlyDB.contactsDao
.getContactByUserId(_message!.senderId!)
.getSingleOrNull();
if (contact != null) {
_username = getContactDisplayName(contact);
}
}
if (_message == null && mounted) {
_username = context.lang.quotedMessageWasDeleted;
}
if (mounted) setState(() {});
}
@ -152,28 +165,27 @@ class _ResponsePreviewState extends State<ResponsePreview> {
Widget build(BuildContext context) {
String? subtitle;
var color = const Color.fromARGB(233, 68, 137, 255);
var username = '';
if (message != null) {
if (message!.type == MessageType.text) {
if (message!.content != null) {
subtitle = truncateString(message!.content!);
if (_message != null) {
if (_message!.type == MessageType.text) {
if (_message!.content != null) {
subtitle = truncateString(_message!.content!);
}
}
if (message!.type == MessageType.media && mediaService != null) {
subtitle = mediaService!.mediaFile.type == MediaType.video
if (_message!.type == MessageType.media && _mediaService != null) {
subtitle = _mediaService!.mediaFile.type == MediaType.video
? context.lang.video
: context.lang.image;
}
username = context.lang.you;
if (message!.senderId != null) {
username = message!.senderId.toString();
if (_message!.senderId == null) {
_username = context.lang.you;
// _username = _message!.senderId.toString();
}
color = getMessageColor(message!);
color = getMessageColor(_message!);
if (!message!.mediaStored) {
if (!_message!.mediaStored) {
return Container(
padding: widget.showBorder
? const EdgeInsets.only(left: 10, right: 10)
@ -192,7 +204,7 @@ class _ResponsePreviewState extends State<ResponsePreview> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
username,
_username,
style: const TextStyle(fontWeight: FontWeight.bold),
),
if (subtitle != null) Text(subtitle),
@ -200,8 +212,6 @@ class _ResponsePreviewState extends State<ResponsePreview> {
),
);
}
} else {
username = context.lang.quotedMessageWasDeleted;
}
return Container(
@ -222,20 +232,20 @@ class _ResponsePreviewState extends State<ResponsePreview> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
username,
_username,
style: const TextStyle(fontWeight: FontWeight.bold),
),
if (subtitle != null) Text(subtitle),
],
),
),
if (mediaService != null)
if (_mediaService != null)
SizedBox(
height: widget.showBorder ? 100 : 210,
child: Image.file(
mediaService!.mediaFile.type == MediaType.video
? mediaService!.thumbnailPath
: mediaService!.storedPath,
_mediaService!.mediaFile.type == MediaType.video
? _mediaService!.thumbnailPath
: _mediaService!.storedPath,
),
),
],