Skip to content

Commit

Permalink
fix: use setting to hide/show excerpt
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Oct 21, 2024
1 parent f75329f commit dad63e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
25 changes: 18 additions & 7 deletions extensions/sticky/js/src/admin/extend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ export default [
'moderate',
95
)
.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'),
})),
.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
),
];
2 changes: 1 addition & 1 deletion extensions/sticky/js/src/forum/addStickyExcerpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions extensions/sticky/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ 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.

# These translations are used in the Permissions page of the admin interface.
permissions:
sticky_discussions_label: Sticky discussions

settings:
enable_display_excerpt: Show an excerpt of the first post when a sticky discussion is unread

# Translations in this namespace are used by the forum user interface.
forum:

Expand Down

0 comments on commit dad63e9

Please sign in to comment.