Skip to content

Commit a4ccefe

Browse files
committed
starting with #227
1 parent 90e6aa6 commit a4ccefe

File tree

131 files changed

+14338
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+14338
-1418
lines changed

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
[submodule "dependencies/flutter_secure_storage"]
2-
path = dependencies/flutter_secure_storage
3-
url = https://github.com/juliansteenbakker/flutter_secure_storage
41
[submodule "dependencies/flutter_zxing"]
52
path = dependencies/flutter_zxing
63
url = https://github.com/khoren93/flutter_zxing.git
7-
[submodule "dependencies/flutter-pie-menu"]
8-
path = dependencies/flutter-pie-menu
9-
url = https://github.com/otsmr/flutter-pie-menu.git

build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ targets:
1010
drift_dev:
1111
options:
1212
databases:
13-
twonly_database: lib/src/database/twonly_database.dart
13+
twonly_db: lib/src/database/twonly.db.dart
14+
twonly_database: lib/src/database/twonly_database_old.dart

dependencies/flutter-pie-menu

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/NotificationService/push_notification.pb.swift

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ enum PushKind: SwiftProtobuf.Enum, Swift.CaseIterable {
103103

104104
}
105105

106-
struct EncryptedPushNotification: @unchecked Sendable {
106+
struct EncryptedPushNotification: Sendable {
107107
// SwiftProtobuf.Message conformance is added in an extension below. See the
108108
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
109109
// methods supported on all messages.
@@ -195,7 +195,7 @@ struct PushUser: Sendable {
195195
fileprivate var _lastMessageID: Int64? = nil
196196
}
197197

198-
struct PushKey: @unchecked Sendable {
198+
struct PushKey: Sendable {
199199
// SwiftProtobuf.Message conformance is added in an extension below. See the
200200
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
201201
// methods supported on all messages.
@@ -214,32 +214,12 @@ struct PushKey: @unchecked Sendable {
214214
// MARK: - Code below here is support for the SwiftProtobuf runtime.
215215

216216
extension PushKind: SwiftProtobuf._ProtoNameProviding {
217-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
218-
0: .same(proto: "reaction"),
219-
1: .same(proto: "response"),
220-
2: .same(proto: "text"),
221-
3: .same(proto: "video"),
222-
4: .same(proto: "twonly"),
223-
5: .same(proto: "image"),
224-
6: .same(proto: "contactRequest"),
225-
7: .same(proto: "acceptRequest"),
226-
8: .same(proto: "storedMediaFile"),
227-
9: .same(proto: "testNotification"),
228-
10: .same(proto: "reopenedMedia"),
229-
11: .same(proto: "reactionToVideo"),
230-
12: .same(proto: "reactionToText"),
231-
13: .same(proto: "reactionToImage"),
232-
]
217+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0reaction\0\u{1}response\0\u{1}text\0\u{1}video\0\u{1}twonly\0\u{1}image\0\u{1}contactRequest\0\u{1}acceptRequest\0\u{1}storedMediaFile\0\u{1}testNotification\0\u{1}reopenedMedia\0\u{1}reactionToVideo\0\u{1}reactionToText\0\u{1}reactionToImage\0")
233218
}
234219

235220
extension EncryptedPushNotification: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
236221
static let protoMessageName: String = "EncryptedPushNotification"
237-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
238-
1: .same(proto: "keyId"),
239-
2: .same(proto: "nonce"),
240-
3: .same(proto: "ciphertext"),
241-
4: .same(proto: "mac"),
242-
]
222+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}keyId\0\u{1}nonce\0\u{1}ciphertext\0\u{1}mac\0")
243223

244224
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
245225
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -284,11 +264,7 @@ extension EncryptedPushNotification: SwiftProtobuf.Message, SwiftProtobuf._Messa
284264

285265
extension PushNotification: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
286266
static let protoMessageName: String = "PushNotification"
287-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
288-
1: .same(proto: "kind"),
289-
2: .same(proto: "messageId"),
290-
3: .same(proto: "reactionContent"),
291-
]
267+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}kind\0\u{1}messageId\0\u{1}reactionContent\0")
292268

293269
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
294270
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -332,9 +308,7 @@ extension PushNotification: SwiftProtobuf.Message, SwiftProtobuf._MessageImpleme
332308

333309
extension PushUsers: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
334310
static let protoMessageName: String = "PushUsers"
335-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
336-
1: .same(proto: "users"),
337-
]
311+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}users\0")
338312

339313
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
340314
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -364,13 +338,7 @@ extension PushUsers: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
364338

365339
extension PushUser: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
366340
static let protoMessageName: String = "PushUser"
367-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
368-
1: .same(proto: "userId"),
369-
2: .same(proto: "displayName"),
370-
3: .same(proto: "blocked"),
371-
4: .same(proto: "lastMessageId"),
372-
5: .same(proto: "pushKeys"),
373-
]
341+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}userId\0\u{1}displayName\0\u{1}blocked\0\u{1}lastMessageId\0\u{1}pushKeys\0")
374342

375343
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
376344
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -424,11 +392,7 @@ extension PushUser: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
424392

425393
extension PushKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
426394
static let protoMessageName: String = "PushKey"
427-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
428-
1: .same(proto: "id"),
429-
2: .same(proto: "key"),
430-
3: .same(proto: "createdAtUnixTimestamp"),
431-
]
395+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}id\0\u{1}key\0\u{1}createdAtUnixTimestamp\0")
432396

433397
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
434398
while let fieldNumber = try decoder.nextFieldNumber() {

lib/globals.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'package:camera/camera.dart';
2-
import 'package:twonly/src/database/twonly_database.dart';
2+
import 'package:twonly/src/database/twonly.db.dart';
33
import 'package:twonly/src/services/api.service.dart';
44

55
late ApiService apiService;
66

77
// uses for background notification
8-
late TwonlyDatabase twonlyDB;
8+
late TwonlyDB twonlyDB;
99

1010
List<CameraDescription> gCameras = <CameraDescription>[];
1111

lib/main.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
66
import 'package:provider/provider.dart';
77
import 'package:twonly/globals.dart';
8-
import 'package:twonly/src/database/twonly_database.dart';
8+
import 'package:twonly/src/database/twonly.db.dart';
99
import 'package:twonly/src/providers/connection.provider.dart';
1010
import 'package:twonly/src/providers/image_editor.provider.dart';
1111
import 'package:twonly/src/providers/settings.provider.dart';
@@ -43,18 +43,18 @@ void main() async {
4343
gCameras = await availableCameras();
4444

4545
apiService = ApiService();
46-
twonlyDB = TwonlyDatabase();
46+
twonlyDB = TwonlyDB();
4747

48-
await twonlyDB.messagesDao.resetPendingDownloadState();
49-
await twonlyDB.messagesDao.handleMediaFilesOlderThan30Days();
50-
await twonlyDB.messageRetransmissionDao.purgeOldRetransmissions();
51-
await twonlyDB.signalDao.purgeOutDatedPreKeys();
48+
// await twonlyDB.messagesDao.resetPendingDownloadState();
49+
// await twonlyDB.messagesDao.handleMediaFilesOlderThan30Days();
50+
// await twonlyDB.messageRetransmissionDao.purgeOldRetransmissions();
51+
// await twonlyDB.signalDao.purgeOutDatedPreKeys();
5252

5353
// Purge media files in the background
54-
unawaited(purgeReceivedMediaFiles());
55-
unawaited(purgeSendMediaFiles());
54+
// unawaited(purgeReceivedMediaFiles());
55+
// unawaited(purgeSendMediaFiles());
5656

57-
unawaited(performTwonlySafeBackup());
57+
// unawaited(performTwonlySafeBackup());
5858

5959
await initFileDownloader();
6060

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import 'package:drift/drift.dart';
2-
import 'package:twonly/src/database/tables/contacts_table.dart';
3-
import 'package:twonly/src/database/twonly_database.dart';
2+
import 'package:twonly/src/database/tables/contacts.table.dart';
3+
import 'package:twonly/src/database/twonly.db.dart';
44
import 'package:twonly/src/services/notifications/pushkeys.notifications.dart';
55

6-
part 'contacts_dao.g.dart';
6+
part 'contacts.dao.g.dart';
77

88
@DriftAccessor(tables: [Contacts])
9-
class ContactsDao extends DatabaseAccessor<TwonlyDatabase>
10-
with _$ContactsDaoMixin {
9+
class ContactsDao extends DatabaseAccessor<TwonlyDB> with _$ContactsDaoMixin {
1110
// this constructor is required so that the main database can create an instance
1211
// of this object.
1312
// ignore: matching_super_parameters
@@ -135,42 +134,39 @@ class ContactsDao extends DatabaseAccessor<TwonlyDatabase>
135134
.watchSingleOrNull();
136135
}
137136

138-
Stream<List<Contact>> watchContactsForShareView() {
139-
return (select(contacts)
140-
..where(
141-
(t) =>
142-
t.accepted.equals(true) &
143-
t.blocked.equals(false) &
144-
t.deleted.equals(false),
145-
)
146-
..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
147-
.watch();
148-
}
149-
150-
Stream<List<Contact>> watchContactsForStartNewChat() {
151-
return (select(contacts)
152-
..where((t) => t.accepted.equals(true) & t.blocked.equals(false))
153-
..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
154-
.watch();
155-
}
156-
157-
Stream<List<Contact>> watchContactsForChatList() {
158-
return (select(contacts)
159-
..where(
160-
(t) =>
161-
t.accepted.equals(true) &
162-
t.blocked.equals(false) &
163-
t.archived.equals(false),
164-
)
165-
..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
166-
.watch();
167-
}
137+
// Stream<List<Contact>> watchContactsForShareView() {
138+
// return (select(contacts)
139+
// ..where(
140+
// (t) =>
141+
// t.accepted.equals(true) &
142+
// t.blocked.equals(false) &
143+
// t.deleted.equals(false),
144+
// )
145+
// ..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
146+
// .watch();
147+
// }
148+
149+
// Stream<List<Contact>> watchContactsForStartNewChat() {
150+
// return (select(contacts)
151+
// ..where((t) => t.accepted.equals(true) & t.blocked.equals(false))
152+
// ..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
153+
// .watch();
154+
// }
155+
156+
// Stream<List<Contact>> watchContactsForChatList() {
157+
// return (select(contacts)
158+
// ..where(
159+
// (t) =>
160+
// t.accepted.equals(true) &
161+
// t.blocked.equals(false) &
162+
// t.archived.equals(false),
163+
// )
164+
// ..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
165+
// .watch();
166+
// }
168167

169168
Future<List<Contact>> getAllNotBlockedContacts() {
170-
return (select(contacts)
171-
..where((t) => t.blocked.equals(false))
172-
..orderBy([(t) => OrderingTerm.desc(t.lastMessageExchange)]))
173-
.get();
169+
return (select(contacts)..where((t) => t.blocked.equals(false))).get();
174170
}
175171

176172
Stream<int?> watchContactsBlocked() {
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:drift/drift.dart';
2+
import 'package:twonly/src/database/tables/groups.table.dart';
3+
import 'package:twonly/src/database/twonly.db.dart';
4+
5+
part 'groups.dao.g.dart';
6+
7+
@DriftAccessor(tables: [Groups, GroupMembers])
8+
class GroupsDao extends DatabaseAccessor<TwonlyDB> with _$GroupsDaoMixin {
9+
// this constructor is required so that the main database can create an instance
10+
// of this object.
11+
// ignore: matching_super_parameters
12+
GroupsDao(super.db);
13+
14+
Future<bool> isContactInGroup(int contactId, String groupId) async {
15+
final entry = await (select(groupMembers)
16+
..where(
17+
(t) => t.contactId.equals(contactId) & t.groupId.equals(groupId)))
18+
.getSingleOrNull();
19+
return entry != null;
20+
}
21+
}

0 commit comments

Comments
 (0)