paper-plane-developers / paper-plane

Chat over Telegram on a modern and elegant client
GNU General Public License v3.0
990 stars 42 forks source link

Rewrite: Define the basic app structure #20

Closed melix99 closed 3 years ago

melix99 commented 3 years ago

Note: This is one of the discussions for #19, so I suggest reading that issue first to better understand what's going on.

We need a basic app structure (or hierarchy) to better visualize and organize the project. I recently saw this blog post of a Fractal core contributor that talks about the structure of Fractal's rewrite in gtk4-rs and, since that project is pretty similar to Telegrand, I think that we can use a similar structure and design.

So, a basic hierarchy for Telegrand would look like this:

Then for the Session:

Then we would also define the relative GObjects, but that's pretty easy as they should be wrappers around TDLib's objects. The only problem is assuring that the objects are updated when we receive the relative update events. We receive updates from the receive() function that we will have in the Window object so, when we receive an update, the idea is to dispatch the updated object to the relative GObject though (probably) functions and maybe using hashmaps to find the correct GObject by an identifier. Obviously this doesn't sound too great so I'm really looking for a better solution, if you have one please don't be afraid to comment!

melix99 commented 3 years ago

Quick update on the Content widget (for how I'm implementing it).

First of all, it is no longer a GtkStack, but it's just a normal AdwBin with a child widget: the ContentChatHistory. The ContentChatHistory is basically the widget that contains both the message list and the "send message area". The idea is to have a selected-chat GObject parameter that's shared between the Sidebar and the ContentChatHistory to know which chat to show in the ContentChatHistory widget.

For now my target is to implement a basic ContentChatHistory that can show the last 20 messages. Then, the next challenge is to dynamically load older messages using the scroll value of the GtkScrolledWindow.

melix99 commented 3 years ago

Closing this as the new app structure is implemented in the rewrite branch.