Skip to content

Unify AccountModel and TimelineModel fetchMore() logic

AccountModel extends TimelineModel, and the two share the same underlying data structure: a QList of Posts. However, since AccountModel needs to call a different API endpoint than TimelineModel, and also needs to fetch pinned posts, the two had very different logic involved with fetching posts. TimelineModel used a signal and slot to connect Account::fillTimeline() with its own fetchedTimeline() method used to handle newly fetched posts. AccountModel, on the other hand, passed in a callback to Account::fetchAccount() which functioned much the same.

However, this meant that the logic used in TimelineModel::fetchedTimeline() to auto-fetch new posts when the user reaches the bottom of the fetched timeline was not being reused by AccountModel. Thus, AccountModel would fetch 20 posts and then stop, unable to fetch more.

I removed the use of a callback function in Account::fetchAccount and replaced it with a call to the Account::fetchedTimeline() signal (which is connected to the TimelineModel::fetchedTimeline() slot) and altered the AccountModel constructor so that, when AccountModel needed to fetch posts, it would have all the necessary information to do so.

Merge request reports