FEATURE: Go to last unread for topic-level bookmark links (PR #14396)

Instead of going to the OP of the topic for topic-level bookmarks (which are bookmarks where for_topic is true) when clicking on the bookmark in the quick access menu or on the user bookmark list, this commit takes the user to the last unread post in the topic instead. This should be generally more useful than landing on the unchanging OP.

To make this work nicely, I needed to add the last_read_post_number to the BookmarkQuery based on the TopicUser association. It should not add too much extra weight to the query, because it is limited to the user that we are fetching bookmarks for.

Also fixed an issue where the bookmark serializer highest_post_number was not taking into account whether the user was staff, which is when we should use highest_staff_post_number instead.

GitHub

Do we need this to be a computed property when it is computing against nothing?

    const linkedPostNumber = this.for_topic ? null : this.linked_post_number;
    let postNumber;
    
    if (bookmark.for_topic) {
      postNumber = bookmark.last_read_post_number + 1;
    } else {
      postNumber = bookmark.linked_post_number;
    }

Yes, I tried without it being a computed property and it was not accessible from the HBS view.

Just to confirm, topic_users has been preloaded right?

Yes

How I wish for the ruby if assignment syntax in JS

Why do we need nil here? TopicUser#user_id is a not nullable column so the nil filter will not have any effect.

Since this is a unit test for the serializer, I think we can just pass the bookmark directly to the serializer instead of having to query for it.