Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
Route bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrneDev committed May 24, 2018
1 parent 7e4f912 commit d25e9a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 48 deletions.
30 changes: 8 additions & 22 deletions js/forum/dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,33 +253,19 @@ System.register('Reflar/Gamification/components/AddHotnessSort', ['flarum/extend
return items;
};

IndexPage.prototype.navItems = function () {
var items = new ItemList();
var params = this.stickyParams();

items.add('allDiscussions', LinkButton.component({
href: app.route('index', params),
active: m.route() === '/' || /^.*?\/(\?sort=.*|hot)/.test(m.route()),
children: app.translator.trans('core.forum.index.all_discussions_link'),
icon: 'comments-o'
}), 100);

if (app.session.user === undefined || app.session.user.data.attributes.canViewRankingPage === false) {} else {
items.add('rankings', LinkButton.component({
href: app.route('rankings', {}),
children: app.translator.trans('reflar-gamification.forum.nav.name'),
icon: 'trophy'
}), 80);
}

return items;
};
extend(IndexPage.prototype, 'navItems', function (items) {
items.add('rankings', LinkButton.component({
href: app.route('rankings'),
children: app.translator.trans('reflar-gamification.forum.nav.name'),
icon: 'trophy'
}), 80);
});

IndexPage.prototype.changeSort = function (sort) {
var params = this.params();

if (sort === 'hot') {
m.route(app.route('index'));
m.route('/');
m.route(m.route() + 'hot');
} else {
if (sort === Object.keys(app.cache.discussionList.sortMap())[0]) {
Expand Down
34 changes: 8 additions & 26 deletions js/forum/src/components/AddHotnessSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,22 @@ export default function () {
return items
}

IndexPage.prototype.navItems = function () {
const items = new ItemList()
const params = this.stickyParams()

items.add('allDiscussions',
extend(IndexPage.prototype, 'navItems', function (items) {
items.add('rankings',
LinkButton.component({
href: app.route('index', params),
active: (m.route() === '/' || /^.*?\/(\?sort=.*|hot)/.test(m.route())),
children: app.translator.trans('core.forum.index.all_discussions_link'),
icon: 'comments-o'
}),
100
)

if (app.session.user === undefined || app.session.user.data.attributes.canViewRankingPage === false) {
} else {
items.add('rankings',
LinkButton.component({
href: app.route('rankings', {}),
href: app.route('rankings'),
children: app.translator.trans('reflar-gamification.forum.nav.name'),
icon: 'trophy'
}),
80
)
}

return items
}
}),
80
)
});

IndexPage.prototype.changeSort = function (sort) {
const params = this.params()

if (sort === 'hot') {
m.route(app.route('index'))
m.route('/')
m.route(m.route() + 'hot')
} else {
if (sort === Object.keys(app.cache.discussionList.sortMap())[0]) {
Expand Down

0 comments on commit d25e9a1

Please sign in to comment.