Open topic at last read



  • @Jaloopa said in How to set up a NodeBB dev environment:

    OK, so I thought I'd have a look at the infiniscrolling on unread issue that's been mentioned. I followed the Cloud9 instructions (after installing another browser because Edge didn't show the second part of the captcha and just took me back to the sign up page), and realised I have no idea where to look for actually rendering the page. src/categories/unread.js seems to just be a few functions, not getting a list of unread.

    Where do I start?

    If you mean, going to the last item in the page, here's what I've found so far:

    src/topics/data.js:Topics.getTopicsData: Need to load the bookmark information. Probably via something like async.forEach( Topics.getUserBookmark...) (in src/topics.js).

    {node-theme}/templates/partial/topics_list.tpl : need to add the /{topics.bookmark} bit to this line:

    <a href="{config.relative_path}/topic/{topics.slug}/{topics.bookmark}" itemprop="url">{topics.title}</a><br />
    

  • SockDev

    @boomzilla This may sound odd, but I think the popup saying 'go to last unread' actually goes to the last read post, which means the text is wrong, and it's causing confusion.

    I'll check it out tonight.



  • @RaceProUK Correct. It should be "last read" or "first unread". The "last unread" post is just the last post.

    The NodeBB community did a survey a while back, and the consensus was that it should take you to the last read post. The rationale was that the last read post would be familiar to the reader, so they would have some context before reading the next unread post. Personally, I would prefer to go straight to the first unread post, and if I need context I'll scroll up a bit.



  • Oh, and for just working with theme stuff quickly, you can edit the templates in, e.g., node_modules/nodebb-theme-persona/templates. But those are actually separate github projects.



  • @RaceProUK You're right. Got the terms mixed up. Fixed the title.

    But that is what the popup says. Huh.



  • So...this is what I've come up with:

    	Topics.getUserBookmarks = function( tids, uid, callback ) {
    		var bookmarks = new Object();
    		async.each( tids, function( tid, callback){
    				async.waterfall([
    					function(callback){
    						callback( null, Topics.getUserBookmark( tid, uid, callback) );						
    					},
    					function(bookmark, callback){
    						bookmarks['tid:' +tid] = bookmark;}
    								]);
    			}, callback);
    		callback( null, bookmarks);
    	}
    

    Which seems to do the right thing and avoid having to click the popup. Meh...the tid: + tid stuff was a function of logging to see WTF was going on with this node craziness.


  • kills Dumbledore

    @boomzilla said:

    If you mean, going to the last item in the page

    No, I was talking about the pagination option not applying to /unread. Not an issue that bothers me but it looked like a relatively simple place to start



  • @Jaloopa Fair enough. You can start your own topic for that, then. :-P


  • SockDev

    @RaceProUK said:

    I'll check it out tonight.

    I said I'd check it out, and I was right: navigator.scrollToPost(parseInt(bookmark - 1, 10), true); is the line that is triggered when you click the toaster, and it is indeed scrolling to the last read post :)

    Edit:



  • @boomzilla that approach puts the bookmark into every target url in the topic list, which obviously requires loading it.

    What if, instead, we church for a bookmark's existence of the user goes to a topic without a post number and redirects appropriately?



  • @boomzilla said:

    callback( null, Topics.getUserBookmark( tid, uid, callback) );

    This does not do what you want. Also, it'd be much better to copy the one-line function and then modify it to use the get-things-from-multiple-sorted-sets database function.



  • @boomzilla I'm not that experienced in web stuff so this might be a stupid idea, but can't you just hijack the toaster event, suppress it, and either steal and use the post number from the link or just redirect to it automatically?



  • Looking at the code, it looks like it can be done by adding these two lines here:

    var bookmark = ajaxify.data.bookmark;
    navigator.scrollToPost(parseInt(bookmark - 1, 10), true);


  • SockDev

    @coldandtired Almost:

    var bookmark = ajaxify.data.bookmark || localStorage.getItem('topic:' + tid + ':bookmark');
    if (bookmark) {
        navigator.scrollToPost(parseInt(bookmark - 1, 10), true);
    }
    

    There may not be a server-side bookmark; in that situation, NodeBB falls back to local storage. Also, if there's no bookmark at all, then there's no sense attempting a navigation.



  • @RaceProUK I had the longer line before but couldn't get it working in the dev console so just removed it :)



  • @RaceProUK said:

    @RaceProUK said:

    I'll check it out tonight.

    I said I'd check it out, and I was right: navigator.scrollToPost(parseInt(bookmark - 1, 10), true); is the line that is triggered when you click the toaster, and it is indeed scrolling to the last read post :)

    Edit:

    I would argue the toaster should be fixed instead so that it actually does move you to the first unread post. Why would I want to read something I already read?


  • SockDev

    @Deadfast Bear in mind that we are not the only users of this software; I'm not going to make assumptions that work for us but no-one else



  • @RaceProUK said:

    @Deadfast Bear in mind that we are not the only users of this software; I'm not going to make assumptions that work for us but no-one else

    I fully realize that. If you or anyone else can point out a valid use case please go ahead.


  • Discourse touched me in a no-no place

    @boomzilla said:

    we church

    Heh.




Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.