Skip to content

Commit

Permalink
Merge pull request #300 from bitfriend/issue284_timeline-upgrade
Browse files Browse the repository at this point in the history
Upgrade timeline
  • Loading branch information
bitfriend authored Nov 6, 2022
2 parents 30aa794 + ef4367d commit f7e8af8
Show file tree
Hide file tree
Showing 24 changed files with 444 additions and 386 deletions.
97 changes: 51 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion app/lib/controllers/chat_list_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ChatListController extends GetxController {

_invitesSubscription = client.invitationsRx().listen((event) {
invitations = event.toList();

update(['invited_list']);
});

Expand Down
21 changes: 12 additions & 9 deletions app/lib/controllers/chat_room_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ class ChatRoomController extends GetxController {
update(['active-members']);
_fetchUserProfiles();
if (_currentRoom == null) {
return; // user may close chat screen before long loading completed
// user may close chat screen before long loading completed
isLoading.value = false;
return;
}
_stream = await _currentRoom!.timeline();
_stream = _currentRoom!.timeline();
// i am fetching messages from remote
if (_currentRoom == null) {
return; // user may close chat screen before long loading completed
// user may close chat screen before long loading completed
isLoading.value = false;
return;
}
var msgs = await _stream!.paginateBackwards(10);
for (RoomMessage message in msgs) {
Expand All @@ -122,7 +126,9 @@ class ChatRoomController extends GetxController {
var receiptController = Get.find<ReceiptController>();
var receipts = (await convoRoom.userReceipts()).toList();
if (_currentRoom == null) {
return; // user may close chat screen before long loading completed
// user may close chat screen before long loading completed
isLoading.value = false;
return;
}
receiptController.loadRoom(convoRoom.getRoomId(), receipts);
isLoading.value = false;
Expand Down Expand Up @@ -408,11 +414,8 @@ class ChatRoomController extends GetxController {
void _loadMessage(RoomMessage message) {
String msgtype = message.msgtype();
String sender = message.sender();
var author = types.User(
id: sender,
firstName: simplifyUserId(sender),
);
int createdAt = message.originServerTs(); // in milliseconds
var author = types.User(id: sender, firstName: simplifyUserId(sender));
int? createdAt = message.originServerTs(); // in milliseconds
String eventId = message.eventId();

if (msgtype == 'm.audio') {
Expand Down
5 changes: 1 addition & 4 deletions app/lib/screens/HomeScreens/chat/ChatScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ class _ChatScreenState extends State<ChatScreen> {
required bool showName,
}) {
return Container(
width: sqrt(
p1.metadata!['messageLength'],
) *
38.5,
width: sqrt(p1.metadata!['messageLength']) * 38.5,
padding: const EdgeInsets.all(8),
constraints: const BoxConstraints(minWidth: 57),
child: Html(
Expand Down
Loading

0 comments on commit f7e8af8

Please sign in to comment.