mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Removed PathJS dependency; refactored routing
This commit is contained in:
@ -9,10 +9,10 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
|
||||
pager.resetCache();
|
||||
}
|
||||
|
||||
function getLinksToPostsAround(searchParams, page, postId) {
|
||||
function getLinksToPostsAround(query, postId) {
|
||||
return promise.make(function(resolve, reject) {
|
||||
pager.setSearchParams(searchParams);
|
||||
pager.setPage(page);
|
||||
pager.setSearchParams(query);
|
||||
pager.setPage(query.page);
|
||||
promise.wait(pager.retrieveCached())
|
||||
.then(function(response) {
|
||||
var postIds = _.pluck(response.entities, 'id');
|
||||
@ -23,8 +23,8 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
|
||||
}
|
||||
|
||||
promise.wait(
|
||||
getLinkToPostAround(postIds, position, page, -1),
|
||||
getLinkToPostAround(postIds, position, page, 1))
|
||||
getLinkToPostAround(postIds, position, query.page, -1),
|
||||
getLinkToPostAround(postIds, position, query.page, 1))
|
||||
.then(function(nextPostUrl, prevPostUrl) {
|
||||
resolve(nextPostUrl, prevPostUrl);
|
||||
});
|
||||
@ -35,7 +35,7 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
|
||||
function getLinkToPostAround(postIds, position, page, direction) {
|
||||
return promise.make(function(resolve, reject) {
|
||||
if (position + direction >= 0 && position + direction < postIds.length) {
|
||||
var url = util.compileComplexRouteArgs(
|
||||
var url = util.appendComplexRouteParam(
|
||||
'#/post/' + postIds[position + direction],
|
||||
_.extend({page: page}, pager.getSearchParams()));
|
||||
resolve(url);
|
||||
@ -47,7 +47,7 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
|
||||
_.last(response.entities) :
|
||||
_.first(response.entities);
|
||||
|
||||
var url = util.compileComplexRouteArgs(
|
||||
var url = util.appendComplexRouteParam(
|
||||
'#/post/' + post.id,
|
||||
_.extend({page: page + direction}, pager.getSearchParams()));
|
||||
resolve(url);
|
||||
|
Reference in New Issue
Block a user