Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat functionality #60

Merged
merged 34 commits into from
May 4, 2022
Merged

Chat functionality #60

merged 34 commits into from
May 4, 2022

Conversation

gnunicorn
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Apr 20, 2022

CLA assistant check
All committers have signed the CLA.

@gtalha07 gtalha07 linked an issue Apr 21, 2022 that may be closed by this pull request
@gtalha07
Copy link
Contributor

We would need extend TimelineStream class functionality so we can push messages in a conversation, ideally some function:

Future<RoomMessage> sendMessage (String messageText){
     ///code
} 

https://docs.effektio.org/api/main/dart-sdk/effektio/TimelineStream-class.html

@gtalha07
Copy link
Contributor

gtalha07 commented Apr 30, 2022

According to #3, the tasks have been implemented and can be reviewed in latest commit of PR. In general the basic chat is integrated. @gnunicorn you can have a look at CI check, then we can merge the PR in main. Some things which haven't been implemented :

  1. Not all chats are being shown, I believe its suppressed from the backend.
  2. Seen tick indicator not changing its color dynamically, we would need some async/await function like next() to update it.
  3. Room Info, as we need more functions to integrate it properly.

@gtalha07 gtalha07 marked this pull request as ready for review April 30, 2022 09:40
Copy link
Contributor Author

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks heaps, this takes us a lot further @gtalha07 ! I have a few remarks, some general, some we should fix before the merge others, we want to convert into tickets and fix later.

General remarks: please stick to one atomic change at a time, drive-by-fixes increase the PR size make it a lot harder to comprehend what is going and why. Instead for things like the style-changes or the logo-update just quickly jump into main branch off, do the fix, raise the PR and merge that branch into yours. Git-merging allows for a quick and easy way to keep that fine and your work fast - and this makes reviewing the distinct parts a lot easier. For this, let's keep it for now (aside from the stuff mentioned below) - but in the future let's stick to that style.

Please fix the following, then we can merge:

  • clean up the code to remove outcommented stuff - just doesn't belong into main ever (I've not remarked every instance, please go through and fix it yourself)
  • please revert the new-hamburger-logo-change: it's the wrong icon (and reopen the ticket belonging to it)
  • Clarify/remove the wrapping function calls
  • add a snackbar info to the user that the images/file they've added to the chat isn't actually send to the server right now

TThe following, we keep the code as is (maybe add FIXME's where I asked about that) but please convert the specific remarks into separate issues (all tagged bug and s-chat):

  • localisation
  • colors and theming
  • sending image messages
  • sending file messages
  • creating reusable avatar-component
  • showing the correct user-icon within the chat
  • fixing the backpaging in chat
  • user_id -> User.display_name()
  • replacing our own time calculation with time-module
  • recursion -> loop for listening to new messages
  • the send-receive-message-flow

app/lib/common/store/chatTheme.dart Outdated Show resolved Hide resolved
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.white,
),
);
}

String getNameFromId(String name) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: The actual native UserId-type already has facilities for this, we should move away from string to returning the native type(s) instead.

Further more, all users are bound to profiles that should actually have a display_name() instead - that might be the username but could also be a custom defined name. UserId isn't clear enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

return name.substring(start, end);
}

String formatedTime(int value) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just reuse existing time for this instead? Rather than building our own?

Also okay with just putting using time up as a ticket and link that here with a FIXME, replace with http...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked this package but I initially used duration and it was not correctly parsing the seconds into hours (the calculated was 5 hours less than actual). So I came up with own custom solution. I can open ticket for it if we want to use that instead of custom function.

@@ -0,0 +1,32 @@
// import 'package:flutter/material.dart';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files with just outcommented code also don't belong into the repo ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

Comment on lines +74 to +92
leading: FutureBuilder<Uint8List>(
future: room.avatar().then((fb) => fb.asTypedList()),
// a previously-obtained Future<String> or null
builder: (BuildContext context, AsyncSnapshot<List<int>> snapshot) {
if (snapshot.hasData) {
return CircleAvatar(
radius: 25,
backgroundImage:
MemoryImage(Uint8List.fromList(snapshot.requireData)),
);
} else {
return CircleAvatar(
radius: 25,
backgroundColor: Colors.grey[700],
child: SvgPicture.asset('assets/images/people.svg'),
);
}
},
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .avatar() is a very common pattern. Can we outsource that into a stand-along reusable component with configurabel radius, please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would be good, I can make custom widget for it. Good catch!

app/lib/screens/HomeScreens/ChatScreen.dart Show resolved Hide resolved
app/lib/screens/HomeScreens/ChatScreen.dart Outdated Show resolved Hide resolved
app/lib/screens/HomeScreens/ChatScreen.dart Outdated Show resolved Hide resolved
app/lib/screens/HomeScreens/ChatScreen.dart Outdated Show resolved Hide resolved
Comment on lines +402 to +407
padding: const EdgeInsets.only(right: 10),
child: CircleAvatar(
radius: 15,
child: Text(getNameFromId(userId)[0].toUpperCase()),
),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reuse the (then new) avatar-component here. The user-name-to-icon should only be a fallback.

@gtalha07 gtalha07 mentioned this pull request May 2, 2022
@gnunicorn gnunicorn merged commit ec0c65a into main May 4, 2022
@gnunicorn gnunicorn deleted the chat-functionality branch May 16, 2023 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement basic chat
3 participants