mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 03:42:13 +00:00
fixes multiple issus
This commit is contained in:
parent
c9a704c44f
commit
c197cb797e
5 changed files with 53 additions and 18 deletions
|
|
@ -197,6 +197,8 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
||||||
await (delete(
|
await (delete(
|
||||||
messageHistories,
|
messageHistories,
|
||||||
)..where((t) => t.messageId.equals(messageId))).go();
|
)..where((t) => t.messageId.equals(messageId))).go();
|
||||||
|
|
||||||
|
await twonlyDB.receiptsDao.deleteReceiptsByMessageId(messageId);
|
||||||
|
|
||||||
await (update(messages)..where(
|
await (update(messages)..where(
|
||||||
(t) => t.messageId.equals(messageId),
|
(t) => t.messageId.equals(messageId),
|
||||||
|
|
@ -344,7 +346,7 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final rowId = await into(messages).insertOnConflictUpdate(insertMessage);
|
await into(messages).insertOnConflictUpdate(insertMessage);
|
||||||
|
|
||||||
await twonlyDB.groupsDao.updateGroup(
|
await twonlyDB.groupsDao.updateGroup(
|
||||||
message.groupId.value,
|
message.groupId.value,
|
||||||
|
|
@ -365,9 +367,11 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final messageId = insertMessage.messageId.value;
|
||||||
|
|
||||||
return await (select(
|
return await (select(
|
||||||
messages,
|
messages,
|
||||||
)..where((t) => t.rowId.equals(rowId))).getSingle();
|
)..where((t) => t.messageId.equals(messageId))).getSingle();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error('Could not insert message: $e');
|
Log.error('Could not insert message: $e');
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,13 @@ class ReceiptsDao extends DatabaseAccessor<TwonlyDB> with _$ReceiptsDaoMixin {
|
||||||
))
|
))
|
||||||
.go();
|
.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> deleteReceiptsByMessageId(String messageId) async {
|
||||||
|
await (delete(receipts)..where(
|
||||||
|
(t) => t.messageId.equals(messageId),
|
||||||
|
))
|
||||||
|
.go();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deleteReceiptForUser(int contactId) async {
|
Future<void> deleteReceiptForUser(int contactId) async {
|
||||||
await (delete(receipts)..where(
|
await (delete(receipts)..where(
|
||||||
|
|
@ -91,10 +98,11 @@ class ReceiptsDao extends DatabaseAccessor<TwonlyDB> with _$ReceiptsDaoMixin {
|
||||||
receiptId: Value(uuid.v4()),
|
receiptId: Value(uuid.v4()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final id = await into(receipts).insert(insertEntry);
|
await into(receipts).insert(insertEntry);
|
||||||
|
final receiptId = insertEntry.receiptId.value;
|
||||||
return await (select(
|
return await (select(
|
||||||
receipts,
|
receipts,
|
||||||
)..where((t) => t.rowId.equals(id))).getSingle();
|
)..where((t) => t.receiptId.equals(receiptId))).getSingle();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore error, receipts is already in the database...
|
// ignore error, receipts is already in the database...
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -178,9 +178,15 @@ Future<void> handleMedia(
|
||||||
|
|
||||||
unawaited(startDownloadMedia(mediaFile!, false));
|
unawaited(startDownloadMedia(mediaFile!, false));
|
||||||
} else {
|
} else {
|
||||||
Log.error(
|
if (mediaFile == null && message == null) {
|
||||||
'Could not insert new message as both the message and mediaFile are empty.',
|
Log.error(
|
||||||
);
|
'Could not insert new message as both the message and mediaFile are empty.',
|
||||||
|
);
|
||||||
|
} else if (mediaFile == null) {
|
||||||
|
Log.error('Could not insert new message as the mediaFile is empty.');
|
||||||
|
} else {
|
||||||
|
Log.error('Could not insert new message as the message is empty.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,23 @@ Future<void> reuploadMediaFiles() async {
|
||||||
final content = EncryptedContent.fromBuffer(receipt.message);
|
final content = EncryptedContent.fromBuffer(receipt.message);
|
||||||
if (content.hasMedia()) {
|
if (content.hasMedia()) {
|
||||||
messageId = content.media.senderMessageId;
|
messageId = content.media.senderMessageId;
|
||||||
await twonlyDB.receiptsDao.updateReceipt(
|
final messageExists = await twonlyDB.messagesDao
|
||||||
receipt.receiptId,
|
.getMessageById(messageId)
|
||||||
ReceiptsCompanion(
|
.getSingleOrNull();
|
||||||
messageId: Value(messageId),
|
if (messageExists != null) {
|
||||||
),
|
await twonlyDB.receiptsDao.updateReceipt(
|
||||||
);
|
receipt.receiptId,
|
||||||
|
ReceiptsCompanion(
|
||||||
|
messageId: Value(messageId),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Log.info(
|
||||||
|
'Message $messageId not found in DB for receipt recovery. Deleting stale receipt.',
|
||||||
|
);
|
||||||
|
await twonlyDB.receiptsDao.deleteReceipt(receipt.receiptId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e);
|
Log.error(e);
|
||||||
|
|
@ -110,8 +121,8 @@ Future<void> reuploadMediaFiles() async {
|
||||||
await twonlyDB.messagesDao.deleteMessagesById(messageId);
|
await twonlyDB.messagesDao.deleteMessagesById(messageId);
|
||||||
}
|
}
|
||||||
await twonlyDB.receiptsDao.deleteReceipt(receipt.receiptId);
|
await twonlyDB.receiptsDao.deleteReceipt(receipt.receiptId);
|
||||||
Log.error(
|
Log.warn(
|
||||||
'Message not found for reupload of the receipt (${message == null} - ${message?.mediaId}).',
|
'Message not found for reupload of the receipt, likely deleted from sender (${message == null} - ${message?.mediaId}).',
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,8 +198,8 @@ class MainCameraController {
|
||||||
|
|
||||||
focusPointOffset = Offset(localPosition.dx, localPosition.dy);
|
focusPointOffset = Offset(localPosition.dx, localPosition.dy);
|
||||||
|
|
||||||
final dx = localPosition.dx / box.size.width;
|
final dx = (localPosition.dx / box.size.width).clamp(0.0, 1.0);
|
||||||
final dy = localPosition.dy / box.size.height;
|
final dy = (localPosition.dy / box.size.height).clamp(0.0, 1.0);
|
||||||
|
|
||||||
setState();
|
setState();
|
||||||
|
|
||||||
|
|
@ -208,7 +208,13 @@ class MainCameraController {
|
||||||
await cameraController?.setFocusPoint(Offset(dx, dy));
|
await cameraController?.setFocusPoint(Offset(dx, dy));
|
||||||
await cameraController?.setFocusMode(FocusMode.auto);
|
await cameraController?.setFocusMode(FocusMode.auto);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e);
|
if (e is CameraException &&
|
||||||
|
(e.code == 'setFocusPointFailed' ||
|
||||||
|
e.code == 'setFocusModeFailed')) {
|
||||||
|
Log.info('Focus point or mode not supported on this device');
|
||||||
|
} else {
|
||||||
|
Log.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the focus point at least 500ms
|
// display the focus point at least 500ms
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue