mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-04-22 10:02:53 +00:00
Groups can now collect flames as well
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
54bdbea858
commit
60ed2775bb
7 changed files with 21 additions and 21 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## 0.0.98
|
## 0.0.98
|
||||||
|
|
||||||
|
- New: Groups can now collect flames as well
|
||||||
- New: Adds a link if the image contains a QR code
|
- New: Adds a link if the image contains a QR code
|
||||||
- Improve: Video compression with progress updates
|
- Improve: Video compression with progress updates
|
||||||
- Improve: Show message "Flames restored"
|
- Improve: Show message "Flames restored"
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,10 @@ class GroupsDao extends DatabaseAccessor<TwonlyDB> with _$GroupsDaoMixin {
|
||||||
return (select(groups)..where((t) => t.isDirectChat.equals(true))).get();
|
return (select(groups)..where((t) => t.isDirectChat.equals(true))).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Group>> getAllGroups() {
|
||||||
|
return select(groups).get();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Group>> getAllNotJoinedGroups() {
|
Future<List<Group>> getAllNotJoinedGroups() {
|
||||||
return (select(groups)
|
return (select(groups)
|
||||||
..where(
|
..where(
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,12 @@ Future<void> handleContactUpdate(
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleFlameSync(
|
Future<void> handleFlameSync(
|
||||||
int contactId,
|
String groupId,
|
||||||
EncryptedContent_FlameSync flameSync,
|
EncryptedContent_FlameSync flameSync,
|
||||||
) async {
|
) async {
|
||||||
Log.info('Got a flameSync from $contactId');
|
Log.info('Got a flameSync for group $groupId');
|
||||||
|
|
||||||
final group = await twonlyDB.groupsDao.getDirectChat(contactId);
|
final group = await twonlyDB.groupsDao.getGroup(groupId);
|
||||||
if (group == null || group.lastFlameCounterChange == null) return;
|
if (group == null || group.lastFlameCounterChange == null) return;
|
||||||
|
|
||||||
var updates = GroupsCompanion(
|
var updates = GroupsCompanion(
|
||||||
|
|
|
||||||
|
|
@ -257,11 +257,6 @@ Future<(EncryptedContent?, PlaintextContent?)> handleEncryptedMessage(
|
||||||
return (null, null);
|
return (null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.hasFlameSync()) {
|
|
||||||
await handleFlameSync(fromUserId, content.flameSync);
|
|
||||||
return (null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.hasPushKeys()) {
|
if (content.hasPushKeys()) {
|
||||||
await handlePushKey(fromUserId, content.pushKeys);
|
await handlePushKey(fromUserId, content.pushKeys);
|
||||||
return (null, null);
|
return (null, null);
|
||||||
|
|
@ -346,6 +341,11 @@ Future<(EncryptedContent?, PlaintextContent?)> handleEncryptedMessage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.hasFlameSync()) {
|
||||||
|
await handleFlameSync(content.groupId, content.flameSync);
|
||||||
|
return (null, null);
|
||||||
|
}
|
||||||
|
|
||||||
if (content.hasGroupUpdate()) {
|
if (content.hasGroupUpdate()) {
|
||||||
await handleGroupUpdate(
|
await handleGroupUpdate(
|
||||||
fromUserId,
|
fromUserId,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/utils/storage.dart';
|
import 'package:twonly/src/utils/storage.dart';
|
||||||
|
|
||||||
Future<void> syncFlameCounters({String? forceForGroup}) async {
|
Future<void> syncFlameCounters({String? forceForGroup}) async {
|
||||||
final groups = await twonlyDB.groupsDao.getAllDirectChats();
|
final groups = await twonlyDB.groupsDao.getAllGroups();
|
||||||
if (groups.isEmpty) return;
|
if (groups.isEmpty) return;
|
||||||
final maxMessageCounter = groups.map((x) => x.totalMediaCounter).max;
|
final maxMessageCounter = groups.map((x) => x.totalMediaCounter).max;
|
||||||
final bestFriend =
|
final bestFriend =
|
||||||
|
|
@ -37,14 +37,8 @@ Future<void> syncFlameCounters({String? forceForGroup}) async {
|
||||||
// only sync when flame counter is higher three or when they are bestFriends
|
// only sync when flame counter is higher three or when they are bestFriends
|
||||||
if (flameCounter <= 2 && bestFriend.groupId != group.groupId) continue;
|
if (flameCounter <= 2 && bestFriend.groupId != group.groupId) continue;
|
||||||
|
|
||||||
final groupMembers =
|
await sendCipherTextToGroup(
|
||||||
await twonlyDB.groupsDao.getGroupNonLeftMembers(group.groupId);
|
group.groupId,
|
||||||
if (groupMembers.length != 1) {
|
|
||||||
continue; // flame sync is only done for groups of two
|
|
||||||
}
|
|
||||||
|
|
||||||
await sendCipherText(
|
|
||||||
groupMembers.first.contactId,
|
|
||||||
EncryptedContent(
|
EncryptedContent(
|
||||||
flameSync: EncryptedContent_FlameSync(
|
flameSync: EncryptedContent_FlameSync(
|
||||||
flameCounter: Int64(flameCounter),
|
flameCounter: Int64(flameCounter),
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,7 @@ class _FlameCounterWidgetState extends State<FlameCounterWidget> {
|
||||||
group = await twonlyDB.groupsDao.getDirectChat(widget.contactId!);
|
group = await twonlyDB.groupsDao.getDirectChat(widget.contactId!);
|
||||||
groupId = group?.groupId;
|
groupId = group?.groupId;
|
||||||
} else if (groupId != null) {
|
} else if (groupId != null) {
|
||||||
// do not display the flame counter for groups
|
|
||||||
group = await twonlyDB.groupsDao.getGroup(groupId);
|
group = await twonlyDB.groupsDao.getGroup(groupId);
|
||||||
if (!(group?.isDirectChat ?? false)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (groupId != null && group != null) {
|
if (groupId != null && group != null) {
|
||||||
isBestFriend =
|
isBestFriend =
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/views/components/alert_dialog.dart';
|
import 'package:twonly/src/views/components/alert_dialog.dart';
|
||||||
import 'package:twonly/src/views/components/avatar_icon.component.dart';
|
import 'package:twonly/src/views/components/avatar_icon.component.dart';
|
||||||
import 'package:twonly/src/views/components/better_list_title.dart';
|
import 'package:twonly/src/views/components/better_list_title.dart';
|
||||||
|
import 'package:twonly/src/views/components/flame.dart';
|
||||||
import 'package:twonly/src/views/components/select_chat_deletion_time.comp.dart';
|
import 'package:twonly/src/views/components/select_chat_deletion_time.comp.dart';
|
||||||
import 'package:twonly/src/views/components/verified_shield.dart';
|
import 'package:twonly/src/views/components/verified_shield.dart';
|
||||||
import 'package:twonly/src/views/contact/contact.view.dart';
|
import 'package:twonly/src/views/contact/contact.view.dart';
|
||||||
|
|
@ -181,6 +182,10 @@ class _GroupViewState extends State<GroupView> {
|
||||||
substringBy(_group!.groupName, 25),
|
substringBy(_group!.groupName, 25),
|
||||||
style: const TextStyle(fontSize: 20),
|
style: const TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
|
FlameCounterWidget(
|
||||||
|
groupId: _group?.groupId,
|
||||||
|
prefix: true,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue