Skip to content

Commit

Permalink
Fix Recent Activity Section (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerbal authored Jun 2, 2024
1 parent 32cce42 commit a793884
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commet/lib/client/matrix/matrix_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class MatrixRoom extends Room {
}

_lastStateEventTimestamp = DateTime.fromMillisecondsSinceEpoch(0);
matrix.Event? latest = room.states[matrix.EventTypes.Message]?[""];
matrix.Event? latest = room.lastEvent;

if (latest != null) {
lastEvent = MatrixTimelineEvent(latest, _matrixRoom.client);
Expand Down
3 changes: 2 additions & 1 deletion commet/lib/ui/molecules/direct_message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:commet/client/client.dart';
import 'package:commet/client/client_manager.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:implicitly_animated_list/implicitly_animated_list.dart';
import 'package:tiamat/tiamat.dart';
Expand Down Expand Up @@ -67,7 +68,7 @@ class _DirectMessageListState extends State<DirectMessageList> {
}

void sortRooms() {
rooms.sort((a, b) {
mergeSort(rooms, compare: (a, b) {
return b.lastEventTimestamp.compareTo(a.lastEventTimestamp);
});
}
Expand Down
6 changes: 4 additions & 2 deletions commet/lib/ui/organisms/home_screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:commet/client/client_manager.dart';
import 'package:commet/ui/organisms/invitation_view/incoming_invitations_view.dart';
import 'package:commet/utils/event_bus.dart';
import 'package:commet/ui/organisms/home_screen/home_screen_view.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
Expand Down Expand Up @@ -44,9 +45,10 @@ class _HomeScreenState extends State<HomeScreen> {
}

void updateRecent() {
recentActivity = widget.clientManager.rooms;
recentActivity = List.from(widget.clientManager.rooms);
recentActivity.removeWhere((element) => element.lastEvent == null);

recentActivity.sort((a, b) {
mergeSort(recentActivity, compare: (a, b) {
return b.lastEventTimestamp.compareTo(a.lastEventTimestamp);
});

Expand Down
2 changes: 1 addition & 1 deletion commet/lib/ui/organisms/home_screen/home_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HomeScreenView extends StatelessWidget {
children: [
if (clientManager.alertManager.alerts.isNotEmpty) alerts(),
if (invitations?.isNotEmpty == true) invitationsList(),
recentRooms(),
if (recentActivity?.isNotEmpty == true) recentRooms(),
roomsList(context)
],
);
Expand Down

0 comments on commit a793884

Please sign in to comment.