Skip to content
Merged

Dev #412

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.2.14

- Fix: Issue with opening directly in chats
- Fix: Multipe smaller issues

## 0.2.13

- New: Tutorial on how to use zoom.
Expand Down
9 changes: 8 additions & 1 deletion lib/src/services/mediafiles/mediafile.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ class MediaFileService {

Future<void> createThumbnail() async {
if (!storedPath.existsSync()) {
Log.error('Could not create Thumbnail as stored media does not exists.');
if (mediaFile.stored &&
mediaFile.createdAt.isBefore(
clock.now().subtract(const Duration(days: 30)),
)) {
// media files does not exists any more so also delete the database entry
await twonlyDB.mediaFilesDao.deleteMediaFile(mediaFile.mediaId);
fullMediaRemoval();
}
return;
}
var success = false;
Expand Down
19 changes: 12 additions & 7 deletions lib/src/services/migrations.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,18 @@ Future<void> runMigrations() async {
final now = clock.now();
for (final messageId in messageIds.first.split(',')) {
await (twonlyDB.update(
twonlyDB.messages,
)..where((tbl) => tbl.messageId.equals(messageId))).write(
MessagesCompanion(
openedAt: Value(now),
openedByAll: Value(now),
),
);
twonlyDB.messages,
)..where(
(tbl) =>
tbl.messageId.equals(messageId) &
(tbl.openedByAll.isNull() | tbl.openedAt.isNull()),
))
.write(
MessagesCompanion(
openedAt: Value(now),
openedByAll: Value(now),
),
);
}
}
}
Expand Down
28 changes: 19 additions & 9 deletions lib/src/services/notifications/pushkeys.notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Future<void> setupNotificationWithUsers({

// HotFIX: Search for user with id 0 if not there remove all
// and create new push keys with all users.
final pushUser = pushUsers.firstWhereOrNull((x) => x.userId == 0);
final pushUser = pushUsers.firstWhereOrNull((x) => x.userId.toInt() == 0);
if (pushUser == null) {
Log.info('Clearing push keys');
await setPushKeys(SecureStorageKeys.receivingPushKeys, []);
Expand All @@ -51,7 +51,7 @@ Future<void> setupNotificationWithUsers({
final contacts = await twonlyDB.contactsDao.getAllContacts();
for (final contact in contacts) {
final pushUser = pushUsers.firstWhereOrNull(
(x) => x.userId == contact.userId,
(x) => x.userId.toInt() == contact.userId,
);

if (pushUser != null && pushUser.pushKeys.isNotEmpty) {
Expand Down Expand Up @@ -124,7 +124,9 @@ Future<void> sendNewPushKey(int userId, PushKey pushKey) async {
Future<void> updatePushUser(Contact contact) async {
final pushKeys = await getPushKeys(SecureStorageKeys.receivingPushKeys);

final pushUser = pushKeys.firstWhereOrNull((x) => x.userId == contact.userId);
final pushUser = pushKeys.firstWhereOrNull(
(x) => x.userId.toInt() == contact.userId,
);

if (pushUser == null) {
pushKeys.add(
Expand All @@ -148,7 +150,9 @@ Future<void> updatePushUser(Contact contact) async {
Future<void> handleNewPushKey(int fromUserId, int keyId, List<int> key) async {
final pushKeys = await getPushKeys(SecureStorageKeys.sendingPushKeys);

var pushUser = pushKeys.firstWhereOrNull((x) => x.userId == fromUserId);
var pushUser = pushKeys.firstWhereOrNull(
(x) => x.userId.toInt() == fromUserId,
);

if (pushUser == null) {
final contact = await twonlyDB.contactsDao
Expand All @@ -164,7 +168,7 @@ Future<void> handleNewPushKey(int fromUserId, int keyId, List<int> key) async {
lastMessageId: uuid.v7(),
),
);
pushUser = pushKeys.firstWhereOrNull((x) => x.userId == fromUserId);
pushUser = pushKeys.firstWhereOrNull((x) => x.userId.toInt() == fromUserId);
}

if (pushUser == null) {
Expand All @@ -187,7 +191,9 @@ Future<void> handleNewPushKey(int fromUserId, int keyId, List<int> key) async {
Future<void> updateLastMessageId(int fromUserId, String messageId) async {
final pushUsers = await getPushKeys(SecureStorageKeys.receivingPushKeys);

final pushUser = pushUsers.firstWhereOrNull((x) => x.userId == fromUserId);
final pushUser = pushUsers.firstWhereOrNull(
(x) => x.userId.toInt() == fromUserId,
);
if (pushUser == null) {
unawaited(setupNotificationWithUsers());
return;
Expand Down Expand Up @@ -285,7 +291,7 @@ Future<PushNotification?> getPushNotificationFromEncryptedContent(

if (content.hasMediaUpdate()) {
final msg = await twonlyDB.messagesDao
.getMessageById(content.reaction.targetMessageId)
.getMessageById(content.mediaUpdate.targetMessageId)
.getSingleOrNull();
// These notifications should only be send to the original sender.
if (msg == null || msg.senderId != toUserId) {
Expand All @@ -304,7 +310,9 @@ Future<PushNotification?> getPushNotificationFromEncryptedContent(
if (content.hasGroupCreate()) {
kind = PushKind.ADDED_TO_GROUP;
final group = await twonlyDB.groupsDao.getGroup(content.groupId);
additionalContent = group!.groupName;
if (group != null) {
additionalContent = group.groupName;
}
}

if (kind == null) return null;
Expand Down Expand Up @@ -339,7 +347,9 @@ Future<Uint8List?> encryptPushNotification(
var key = 'InsecureOnlyUsedForAddingContact'.codeUnits;
var keyId = 0;

final pushUser = pushKeys.firstWhereOrNull((x) => x.userId == toUserId);
final pushUser = pushKeys.firstWhereOrNull(
(x) => x.userId.toInt() == toUserId,
);

if (pushUser == null) {
// user does not have send any push keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MainCameraController {
CameraController? cameraController;
ScreenshotController screenshotController = ScreenshotController();
SelectedCameraDetails selectedCameraDetails = SelectedCameraDetails();
bool initCameraStarted = true;
bool initCameraStarted = false;
Map<int, ScannedVerifiedContact> contactsVerified = {};
Map<int, ScannedNewProfile> scannedNewProfiles = {};
final Set<String> _handledProfileLinks = {};
Expand Down
4 changes: 3 additions & 1 deletion lib/src/visual/views/home.view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class HomeViewState extends State<HomeView> {
streamHomeViewPageIndex.add(0);
});

unawaited(_mainCameraController.selectCamera(0, true));
if (initialPage == 1) {
unawaited(_mainCameraController.selectCamera(0, true));
}
unawaited(_initAsync());

// Subscribe to all events (initial link and further)
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec

publish_to: 'none'

version: 0.2.13+122
version: 0.2.14+123

environment:
sdk: ^3.11.0
Expand Down Expand Up @@ -185,6 +185,7 @@ dev_dependencies:
in_app_purchase_platform_interface: ^1.4.0
integration_test:
sdk: flutter
workmanager_platform_interface: any

flutter_launcher_icons:
android: true
Expand Down
Loading