Skip to content

Add m_original_post_id for use in timeline fetch

Joshua Goins requested to merge (removed):fix-timeline-scroll into master

For some reason, timeline scrolls happen to be buggy but only sometimes. However, I figured out that they have a consistent pattern - they always end on boosts. This makes sense, once you consider what TimelineModel is doing. See TimelineModel::fetchMore(const QModelIndex &parent):

void TimelineModel::fetchMore(const QModelIndex &parent)
{
    Q_UNUSED(parent);

    if (m_timeline.size() < 1)
        return;

    auto p = m_timeline.last();

    fillTimeline(p->m_post_id);
}

It's using the m_post_id to figure out the last post and feed that back to the Mastodon API. Now that should work, except that we technically overwrite m_post_id when creating Posts:

    if (!obj.contains("reblog") || reblog_obj.isEmpty()) {
        m_repeat = false;
        m_author_identity = m_parent->identityLookup(acct, account_doc);
    } else {
        m_repeat = true;

        auto repeat_account_doc = reblog_obj["account"].toObject();
        auto repeat_acct = repeat_account_doc["acct"].toString();

        m_author_identity = m_parent->identityLookup(repeat_acct, repeat_account_doc);
        m_repeat_identity = m_parent->identityLookup(acct, account_doc);

        obj = reblog_obj;
    }

Oops ;-) For those not familiar with how Mastodon functions, boosts are just regular posts with their own IDs, but they just contain the boosted post as a subobject in the JSON (with their own ID too.) However, while it makes sense to overwrite the whole post contents when displaying the boost in Tokodon, it's consequently overwriting the boosted post id with the original one. This means we're asking for Mastodon to show posts older than the original post, to which it just goes "???" and returns [] or no posts.

Now we could just copy everything but m_post_id, but I would figure that would mess up feeding back likes and replies to the original, so I just introduced a new variable called m_original_post_id. It's not exposed anywhere since it's just for internal use. Now you can scroll to your heart's content!

Edited by Joshua Goins

Merge request reports

Loading