Skip to content
Commit 7f9d370e authored by Jeremy Winter's avatar Jeremy Winter Committed by Carl Schwan
Browse files

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.
parent 8de6558f
Pipeline #164523 passed with stage
in 34 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment