mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
feat(sticky): make excerpt optional in sticky (#4016)
This commit is contained in:
parent
b86a4a0fe0
commit
a0311dfb2b
|
@ -31,6 +31,10 @@ return [
|
|||
|
||||
new Extend\Locales(__DIR__.'/locale'),
|
||||
|
||||
(new Extend\Settings())
|
||||
->serializeToForum('excerptDisplayEnabled', 'flarum-sticky.enable_display_excerpt', 'boolval')
|
||||
->default('flarum-sticky.enable_display_excerpt', true),
|
||||
|
||||
(new Extend\Model(Discussion::class))
|
||||
->cast('is_sticky', 'bool'),
|
||||
|
||||
|
|
|
@ -15,11 +15,22 @@ export default [
|
|||
'moderate',
|
||||
95
|
||||
)
|
||||
.setting(() => ({
|
||||
.setting(
|
||||
() => ({
|
||||
setting: 'flarum-sticky.only_sticky_unread_discussions',
|
||||
name: 'onlyStickyUnreadDiscussions',
|
||||
type: 'boolean',
|
||||
label: app.translator.trans('flarum-sticky.admin.settings.only_sticky_unread_discussions_label'),
|
||||
help: app.translator.trans('flarum-sticky.admin.settings.only_sticky_unread_discussions_help'),
|
||||
})),
|
||||
}),
|
||||
90
|
||||
)
|
||||
.setting(
|
||||
() => ({
|
||||
type: 'switch',
|
||||
setting: 'flarum-sticky.enable_display_excerpt',
|
||||
label: app.translator.trans('flarum-sticky.admin.settings.enable_display_excerpt'),
|
||||
}),
|
||||
100
|
||||
),
|
||||
];
|
||||
|
|
|
@ -8,7 +8,7 @@ import { truncate } from 'flarum/common/utils/string';
|
|||
|
||||
export default function addStickyExcerpt() {
|
||||
extend(DiscussionListState.prototype, 'requestParams', function (params) {
|
||||
if (app.current.matches(IndexPage) || app.current.matches(DiscussionPage)) {
|
||||
if (app.forum.attribute('excerptDisplayEnabled') && (app.current.matches(IndexPage) || app.current.matches(DiscussionPage))) {
|
||||
params.include.push('firstPost');
|
||||
}
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ export default function addStickyExcerpt() {
|
|||
extend(DiscussionListItem.prototype, 'infoItems', function (items) {
|
||||
const discussion = this.attrs.discussion;
|
||||
|
||||
if (discussion.isSticky() && !this.attrs.params.q && !discussion.lastReadPostNumber()) {
|
||||
if (app.forum.attribute('excerptDisplayEnabled') && discussion.isSticky() && !this.attrs.params.q && !discussion.lastReadPostNumber()) {
|
||||
const firstPost = discussion.firstPost();
|
||||
|
||||
if (firstPost) {
|
||||
|
|
|
@ -7,6 +7,7 @@ flarum-sticky:
|
|||
# Translations in this namespace are used by the admin interface.
|
||||
admin:
|
||||
settings:
|
||||
enable_display_excerpt: Show an excerpt of the first post when a sticky discussion is unread
|
||||
only_sticky_unread_discussions_label: Only sticky unread discussions
|
||||
only_sticky_unread_discussions_help: On the All Discussions page, unread sticky discussions pin to the top, while read sticky discussions follow the regular order.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user