CodedOre / NewCaw

Development on Cawbird 2.0
GNU General Public License v3.0
97 stars 5 forks source link

Concept for a new Collection system #76

Closed CodedOre closed 1 year ago

CodedOre commented 1 year ago

In #74, @IBBoard wanted to extend Collection by sub-classing it so HomeTimeline and UserTimeline can have a method to pull for older posts, without having to adding the method to Thread, as it would be pointless there. When I looked into implementing notifications today, I found that it could technically be managed by Collection as well, instead of getting it's own managment. So, in the last few hours, I have developed this concept on how we could change Collection to be more flexible.

Here is the basic overview: Collection itself is only a ListModel, which enforces sorting. Sorting is done by calling the abstract sorter property, which allows classes which are based on Collection to choose a implementation of CollectionSorter which suits them. Methods to pull items are added by extending Interfaces, so that Thread can have one basic pulling method, while the timelines can implement pulling older ones as well.

So, the basic idea is to have a basic Collection, which is extendable, so it can be used with various cases.

However, there are still some issues and ToDo's:

Most importantly though: Since this was just an idea I quickly coded together in the last few hours, I would like to have a bit of feedback, especially from @IBBoard, if this is a good idea and how this could be improved.

CodedOre commented 1 year ago

@IBBoard, if you have the time, I would appreciate some feedback on this concept. Before I attempt to continue this branch (or as I know myself rewrite it) I would like to have some feedback on the idea of the extendable collection. At the end, the discussion about ExpandableCollection initiated the work on this idea.

IBBoard commented 1 year ago

Literally looking at it now 😁 I've been busy with other things, and then trying to fix up my window sizing branch before I looked at this πŸ™‚

CodedOre commented 1 year ago

The only thing that I don't quite get is why not make PullableCollection extend Collection and make PaginatedCollection extend PullableCollection? Is it a Vala-ism to have more multiple inheritance rather than a longer inheritance chain?

I have orientated that after how Gtk does it inheritance, as I wanted to avoid a long chain of inheritances.

Also, I don't think its possible to inherit an interface of an abstract class.

CodedOre commented 1 year ago

So, I have reworked the branch a bit.

I have now decided to implement the compare method as an abstract one in the Collection class. As a result, there is a new ReversePostList class which implements the sorting for the timelines. This isn't quite es modular as I originally wanted, but I haven't been able to make the delegate method to be working properly.

Also, the segfault while sorting is still present...\ And even if you cut out the sorting, CollectionView fails to show anything, as it fails to identify the items as GObjects...\ My guess is that it has to do with generics, have to look into that more.

Other than that, what I would want to add as well is:

CodedOre commented 1 year ago

Also, the segfault while sorting is still present...

Apparently this is caused by the timelines adding headers. Well, the idea is anyway to change this, so I removed that for now.

And even if you cut out the sorting, CollectionView fails to show anything, as it fails to identify the items as GObjects... My guess is that it has to do with generics, have to look into that more.

And my guess was wrong. I just missed a few brackets when calling a method... So, it does work (for now).

CodedOre commented 1 year ago

Alright, it's later than I planned, but now the backend should be complete. Might be some room for improvements though.

The frontend, especially CollectionView, was only modified so it works, so it probably could be improved for the new structure of Collection.

CodedOre commented 1 year ago

Since the threads are now sorted as well, I think we can merge this now.