client/paging: fix endless scroll return path
Since some refactors it has always been returning to page 1.
This commit is contained in:
		
							parent
							
								
									8901658c17
								
							
						
					
					
						commit
						5d8dd9cb05
					
				@ -12,7 +12,7 @@ router.exit(
 | 
			
		||||
    (ctx, next) => {
 | 
			
		||||
        ctx.state.scrollX = window.scrollX;
 | 
			
		||||
        ctx.state.scrollY = window.scrollY;
 | 
			
		||||
        ctx.save();
 | 
			
		||||
        router.replace(router.url, ctx.state);
 | 
			
		||||
        if (misc.confirmPageExit()) {
 | 
			
		||||
            next();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,8 @@
 | 
			
		||||
// - simplified method chains
 | 
			
		||||
// - added ability to call .save() in .exit() without side effects
 | 
			
		||||
// - page refresh recovers state from history
 | 
			
		||||
// - rename .save() to .replaceState()
 | 
			
		||||
// - offer .url
 | 
			
		||||
 | 
			
		||||
const pathToRegexp = require('path-to-regexp');
 | 
			
		||||
const clickEvent = document.ontouchstart ? 'touchstart' : 'click';
 | 
			
		||||
@ -47,7 +49,7 @@ class Context {
 | 
			
		||||
        history.pushState(this.state, this.title, this.canonicalPath);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    save() {
 | 
			
		||||
    replaceState() {
 | 
			
		||||
        history.replaceState(this.state, this.title, this.canonicalPath);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
@ -149,10 +151,10 @@ class Router {
 | 
			
		||||
        var ctx = new Context(path, state);
 | 
			
		||||
        if (dispatch) {
 | 
			
		||||
            this.dispatch(ctx, () => {
 | 
			
		||||
                ctx.save();
 | 
			
		||||
                ctx.replaceState();
 | 
			
		||||
            });
 | 
			
		||||
        } else {
 | 
			
		||||
            ctx.save();
 | 
			
		||||
            ctx.replaceState();
 | 
			
		||||
        }
 | 
			
		||||
        return ctx;
 | 
			
		||||
    }
 | 
			
		||||
@ -184,6 +186,10 @@ class Router {
 | 
			
		||||
        router.stop();
 | 
			
		||||
        location.href = ctx.canonicalPath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get url() {
 | 
			
		||||
        return location.pathname + location.search + location.hash;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const _onPopState = router => {
 | 
			
		||||
 | 
			
		||||
@ -65,7 +65,7 @@ class EndlessPageView {
 | 
			
		||||
        if (topPageNumber !== this.currentPage) {
 | 
			
		||||
            router.replace(
 | 
			
		||||
                ctx.getClientUrlForPage(topPageNumber),
 | 
			
		||||
                {},
 | 
			
		||||
                ctx.state,
 | 
			
		||||
                false);
 | 
			
		||||
            this.currentPage = topPageNumber;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -110,7 +110,7 @@ class PostsHeaderView {
 | 
			
		||||
        browsingSettings.listPosts[safety] =
 | 
			
		||||
            !browsingSettings.listPosts[safety];
 | 
			
		||||
        settings.save(browsingSettings, true);
 | 
			
		||||
        router.show(location.pathname + location.search + location.hash);
 | 
			
		||||
        router.show(router.url);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _evtSearchFormSubmit(e) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user