forum: fix PostStream not scrolling to post number on load & potential issues with app.route.discussion

This commit is contained in:
David Sevilla Martin 2020-03-07 18:00:28 -05:00
parent 31cfe0f9df
commit b9583943c5
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
7 changed files with 14 additions and 10 deletions

File diff suppressed because one or more lines are too long

2
js/dist/forum.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -78,7 +78,7 @@ export default class Discussion extends Model {
const items = new ItemList();
if (this.isHidden()) {
items.add('hidden', <Badge type="hidden" icon="fas fa-trash" label={app.translator.trans('core.lib.badge.hidden_tooltip')} />);
items.add('hidden', <Badge type="hidden" icon="fas fa-trash" label={app.translator.transText('core.lib.badge.hidden_tooltip')} />);
}
return items;

View File

@ -102,11 +102,15 @@ export default class Forum extends Application {
super.setupRoutes();
this.route.discussion = (discussion: Discussion, near?: number): string => {
const slug = discussion.slug();
return this.route(near && near !== 1 ? 'discussion.near' : 'discussion', {
const slug = discussion?.slug();
const hasNear = near && near !== 1;
const params = {
id: discussion.id() + (slug.trim() ? '-' + slug : ''),
near: near && near !== 1 ? near : undefined,
});
};
if (hasNear) params['near'] = near;
return this.route(near && near !== 1 ? 'discussion.near' : 'discussion', params);
};
/**

View File

@ -1,4 +1,4 @@
import {Vnode} from 'mithril';
import { Vnode } from 'mithril';
import Component from '../../common/Component';
import Button from '../../common/components/Button';

View File

@ -542,7 +542,7 @@ class PostStream<T extends PostStreamProps = PostStreamProps> extends Component<
if ($item.length) {
const itemTop = $item.offset().top - this.getMarginTop();
const itemBottom = $item.offset().top + $item.height();
const scrollTop = $(document).scrollTop();
const scrollTop = $container.scrollTop();
const scrollBottom = scrollTop + $(window).height();
// If the item is already in the viewport, we may not need to scroll.