FIX: topic level bookmark button (PR #13530)

We have changed behaviour of the topic level bookmark button recently. That PR made the button be opening the edit bookmark modal when there is only one bookmark on the topic instead of just removing that bookmark as it was before.

This PR fixes the next problems that weren’t taken into account in the previous PR:

  1. Everything should work fine even on very big topics when a bookmarked post is unloaded from the post stream. I’ve added code that loads the post we need and makes everything work as expected
  2. When at least one bookmark on the topic has a reminder, we should always be showing the icon with a clock on the topic level bookmark button
  3. We should show correct tooltips for the topic level bookmark button

GitHub

    if @topic_view.present?

Quite a big PR but it makes a lot of sense and is easy to follow.

Super super trivial but:

Arguably [0] is more consistent with the [1] below it. Or, if you want to be fancy:

first, second = bookmark_posts

Arguably [0] is more consistent with the [1] below it.

Agree with this :+1:, but this one: first, second = bookmark_posts is even better!

Should probably user select or pluck to limit the columns loaded from the database.

    @topic.bookmarks.where(user: @user).pluck(:post_id, :reminder_at).map do |post_id, reminder_at|
      {
        post_id: post_id,
        reminder_at: reminder_at
      }
    end