Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.9)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.0.1)
Expand All @@ -22,34 +24,42 @@ GEM
drb (2.2.3)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.18.0)
json (2.19.1)
json-schema (6.2.0)
addressable (~> 2.8)
bigdecimal (>= 3.1, < 5)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.7.0)
minitest (6.0.1)
mcp (0.8.0)
json-schema (>= 4.1)
minitest (6.0.2)
drb (~> 2.0)
prism (~> 1.5)
parallel (1.27.0)
parser (3.3.10.1)
parser (3.3.10.2)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (1.9.0)
public_suffix (7.0.5)
racc (1.8.1)
rack (3.2.5)
rainbow (3.1.1)
regexp_parser (2.11.3)
rubocop (1.84.0)
rubocop (1.85.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
mcp (~> 0.6)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.0)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-capybara (2.22.1)
Expand Down Expand Up @@ -102,4 +112,4 @@ DEPENDENCIES
syntax_tree

BUNDLED WITH
4.0.4
4.0.8
107 changes: 50 additions & 57 deletions javascripts/discourse/services/topic-thumbnails.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { tracked } from "@glimmer/tracking";
import { computed } from "@ember/object";
import { dependentKeyCompat } from "@ember/object/compat";
import Service, { service } from "@ember/service";
import discourseComputed from "discourse/lib/decorators";
import Site from "discourse/models/site";

const minimalGridCategories = settings.minimal_grid_categories
Expand Down Expand Up @@ -41,14 +41,14 @@ export default class TopicThumbnailService extends Service {
return this.discovery.onDiscoveryRoute;
}

@discourseComputed("router.currentRouteName")
isTopicRoute(currentRouteName) {
return currentRouteName.match(/^topic\./);
@computed("router.currentRouteName")
get isTopicRoute() {
return this.router?.currentRouteName?.match(/^topic\./);
}

@discourseComputed("router.currentRouteName")
isDocsRoute(currentRouteName) {
return currentRouteName.match(/^docs\./);
@computed("router.currentRouteName")
get isDocsRoute() {
return this.router?.currentRouteName?.match(/^docs\./);
}

@dependentKeyCompat
Expand All @@ -61,98 +61,91 @@ export default class TopicThumbnailService extends Service {
return this.discovery.tag?.name;
}

@discourseComputed(
@computed(
"viewingCategoryId",
"viewingTagName",
"router.currentRoute.metadata.customThumbnailMode",
"isTopicListRoute",
"isTopicRoute",
"isDocsRoute"
)
displayMode(
viewingCategoryId,
viewingTagName,
customThumbnailMode,
isTopicListRoute,
isTopicRoute,
isDocsRoute
) {
if (customThumbnailMode) {
return customThumbnailMode;
get displayMode() {
if (this.router?.currentRoute?.metadata?.customThumbnailMode) {
return this.router?.currentRoute?.metadata?.customThumbnailMode;
}
if (minimalGridCategories.includes(viewingCategoryId)) {
if (minimalGridCategories.includes(this.viewingCategoryId)) {
return "minimal-grid";
} else if (blogStyleCategories.includes(viewingCategoryId)) {
} else if (blogStyleCategories.includes(this.viewingCategoryId)) {
return "blog-style";
} else if (masonryCategories.includes(viewingCategoryId)) {
} else if (masonryCategories.includes(this.viewingCategoryId)) {
return "masonry";
} else if (gridCategories.includes(viewingCategoryId)) {
} else if (gridCategories.includes(this.viewingCategoryId)) {
return "grid";
} else if (listCategories.includes(viewingCategoryId)) {
} else if (listCategories.includes(this.viewingCategoryId)) {
return "list";
} else if (masonryTags.includes(viewingTagName)) {
} else if (masonryTags.includes(this.viewingTagName)) {
return "masonry";
} else if (minimalGridTags.includes(viewingTagName)) {
} else if (minimalGridTags.includes(this.viewingTagName)) {
return "minimal-grid";
} else if (blogStyleTags.includes(viewingTagName)) {
} else if (blogStyleTags.includes(this.viewingTagName)) {
return "blog-style";
} else if (gridTags.includes(viewingTagName)) {
} else if (gridTags.includes(this.viewingTagName)) {
return "grid";
} else if (listTags.includes(viewingTagName)) {
} else if (listTags.includes(this.viewingTagName)) {
return "list";
} else if (isTopicRoute && settings.suggested_topics_mode) {
} else if (this.isTopicRoute && settings.suggested_topics_mode) {
return settings.suggested_topics_mode;
} else if (isTopicListRoute || settings.enable_outside_topic_lists) {
} else if (this.isTopicListRoute || settings.enable_outside_topic_lists) {
return settings.default_thumbnail_mode;
} else if (isDocsRoute) {
} else if (this.isDocsRoute) {
return settings.docs_thumbnail_mode;
} else {
return "none";
}
}

@discourseComputed("displayMode")
enabledForRoute(displayMode) {
return displayMode !== "none";
@computed("displayMode")
get enabledForRoute() {
return this.displayMode !== "none";
}

@discourseComputed()
enabledForDevice() {
@computed()
get enabledForDevice() {
return Site.current().mobileView ? settings.mobile_thumbnails : true;
}

@discourseComputed("enabledForRoute", "enabledForDevice")
shouldDisplay(enabledForRoute, enabledForDevice) {
return enabledForRoute && enabledForDevice;
@computed("enabledForRoute", "enabledForDevice")
get shouldDisplay() {
return this.enabledForRoute && this.enabledForDevice;
}

@discourseComputed("shouldDisplay", "displayMode")
displayMinimalGrid(shouldDisplay, displayMode) {
return shouldDisplay && displayMode === "minimal-grid";
@computed("shouldDisplay", "displayMode")
get displayMinimalGrid() {
return this.shouldDisplay && this.displayMode === "minimal-grid";
}

@discourseComputed("shouldDisplay", "displayMode")
displayList(shouldDisplay, displayMode) {
return shouldDisplay && displayMode === "list";
@computed("shouldDisplay", "displayMode")
get displayList() {
return this.shouldDisplay && this.displayMode === "list";
}

@discourseComputed("shouldDisplay", "displayMode")
displayGrid(shouldDisplay, displayMode) {
return shouldDisplay && displayMode === "grid";
@computed("shouldDisplay", "displayMode")
get displayGrid() {
return this.shouldDisplay && this.displayMode === "grid";
}

@discourseComputed("shouldDisplay", "displayMode")
displayMasonry(shouldDisplay, displayMode) {
return shouldDisplay && displayMode === "masonry";
@computed("shouldDisplay", "displayMode")
get displayMasonry() {
return this.shouldDisplay && this.displayMode === "masonry";
}

@discourseComputed("shouldDisplay", "displayMode")
displayBlogStyle(shouldDisplay, displayMode) {
return shouldDisplay && displayMode === "blog-style";
@computed("shouldDisplay", "displayMode")
get displayBlogStyle() {
return this.shouldDisplay && this.displayMode === "blog-style";
}

@discourseComputed("displayMinimalGrid", "displayBlogStyle")
showLikes(isMinimalGrid) {
return isMinimalGrid;
@computed("displayMinimalGrid", "displayBlogStyle")
get showLikes() {
return this.displayMinimalGrid;
}
}
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"private": true,
"devDependencies": {
"@discourse/lint-configs": "2.37.2",
"@glint/ember-tsc": "1.0.9",
"@discourse/lint-configs": "2.43.0",
"@glint/ember-tsc": "1.1.1",
"concurrently": "^9.2.1",
"discourse": "npm:@discourse/types@2026.1.0-2709d36",
"discourse": "npm:@discourse/types@2026.3.0-887c5be4",
"ember-template-lint": "7.9.3",
"eslint": "9.39.2",
"prettier": "3.8.0",
"stylelint": "17.0.0"
"lint-to-the-future": "^2.6.4",
"lint-to-the-future-eslint": "^3.3.0",
"prettier": "3.8.1",
"stylelint": "17.4.0"
},
"scripts": {
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
Expand All @@ -21,7 +23,8 @@
"lint:hbs:fix": "ember-template-lint javascripts/**/*.gjs --fix --no-error-on-unmatched-pattern",
"lint:prettier": "pnpm prettier {javascripts,desktop,mobile,common,scss}/**/*.scss {javascripts,test}/**/*.{js,gjs} --check --no-error-on-unmatched-pattern",
"lint:prettier:fix": "pnpm prettier {javascripts,desktop,mobile,common,scss}/**/*.scss {javascripts,test}/**/*.{js,gjs} -w --no-error-on-unmatched-pattern",
"lint:types": "ember-tsc -b"
"lint:types": "ember-tsc -b",
"lttf:ignore": "lint-to-the-future ignore"
},
"engines": {
"node": ">= 22",
Expand Down
Loading