FIX: improves bookmark shortcut reliability (PR #9547)

This commit reworks slightly the toggleBookmark and toggleBookmarkTopic functions.

The following cases have been identified:

  • Pressing [f] (toggleBookmarkTopic)

    • a topic list item is selected, we attempt to toggle the related topic
    • a post is selected, we do nothing, we could select the related post, but that should be done with [b]
    • nothing is selected, if there’s a currentTopic we bookmark it
  • Pressing [b] (toggleBookmark)

    • a post is selected, we bookmark it
    • a topic list item is selected, we attempt to toggle the related topic
    • nothing is selected, if there’s a currentTopic we bookmark it

Note this, commit also reduces jquery usage, and attempts to fix a bug when bookmarking a topic list item on the front page and the firstPost couldn’t be found, current repro before fix:

  • navigate to /
  • press [j] to select a topic list item
  • press [f]
  • Uncaught TypeError: Cannot read property 'post_number' of undefined error appears in console, the topic is not bookmarked

GitHub

Looks good to me!

1 Like

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/improved-bookmarks-with-reminders/144542/120

Fantastic, thank you for fixing this :tada:

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/improved-bookmarks-with-reminders/144542/121

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/reporting-few-issues-with-bookmarks/149283/4