Groups can now collect flames as well
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run

This commit is contained in:
otsmr 2026-03-14 01:40:07 +01:00
parent 54bdbea858
commit 60ed2775bb
7 changed files with 21 additions and 21 deletions

View file

@ -2,6 +2,7 @@
## 0.0.98
- New: Groups can now collect flames as well
- New: Adds a link if the image contains a QR code
- Improve: Video compression with progress updates
- Improve: Show message "Flames restored"

View file

@ -248,6 +248,10 @@ class GroupsDao extends DatabaseAccessor<TwonlyDB> with _$GroupsDaoMixin {
return (select(groups)..where((t) => t.isDirectChat.equals(true))).get();
}
Future<List<Group>> getAllGroups() {
return select(groups).get();
}
Future<List<Group>> getAllNotJoinedGroups() {
return (select(groups)
..where(

View file

@ -137,12 +137,12 @@ Future<void> handleContactUpdate(
}
Future<void> handleFlameSync(
int contactId,
String groupId,
EncryptedContent_FlameSync flameSync,
) 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;
var updates = GroupsCompanion(

View file

@ -257,11 +257,6 @@ Future<(EncryptedContent?, PlaintextContent?)> handleEncryptedMessage(
return (null, null);
}
if (content.hasFlameSync()) {
await handleFlameSync(fromUserId, content.flameSync);
return (null, null);
}
if (content.hasPushKeys()) {
await handlePushKey(fromUserId, content.pushKeys);
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()) {
await handleGroupUpdate(
fromUserId,

View file

@ -10,7 +10,7 @@ import 'package:twonly/src/utils/misc.dart';
import 'package:twonly/src/utils/storage.dart';
Future<void> syncFlameCounters({String? forceForGroup}) async {
final groups = await twonlyDB.groupsDao.getAllDirectChats();
final groups = await twonlyDB.groupsDao.getAllGroups();
if (groups.isEmpty) return;
final maxMessageCounter = groups.map((x) => x.totalMediaCounter).max;
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
if (flameCounter <= 2 && bestFriend.groupId != group.groupId) continue;
final groupMembers =
await twonlyDB.groupsDao.getGroupNonLeftMembers(group.groupId);
if (groupMembers.length != 1) {
continue; // flame sync is only done for groups of two
}
await sendCipherText(
groupMembers.first.contactId,
await sendCipherTextToGroup(
group.groupId,
EncryptedContent(
flameSync: EncryptedContent_FlameSync(
flameCounter: Int64(flameCounter),

View file

@ -44,11 +44,7 @@ class _FlameCounterWidgetState extends State<FlameCounterWidget> {
group = await twonlyDB.groupsDao.getDirectChat(widget.contactId!);
groupId = group?.groupId;
} else if (groupId != null) {
// do not display the flame counter for groups
group = await twonlyDB.groupsDao.getGroup(groupId);
if (!(group?.isDirectChat ?? false)) {
return;
}
}
if (groupId != null && group != null) {
isBestFriend =

View file

@ -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/avatar_icon.component.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/verified_shield.dart';
import 'package:twonly/src/views/contact/contact.view.dart';
@ -181,6 +182,10 @@ class _GroupViewState extends State<GroupView> {
substringBy(_group!.groupName, 25),
style: const TextStyle(fontSize: 20),
),
FlameCounterWidget(
groupId: _group?.groupId,
prefix: true,
),
],
),
const SizedBox(height: 50),