Skip to content

Commit e00e058

Browse files
committed
DEV: Update transformers in topic-list/item
These will enable discourse/discourse-topic-thumbnails#60
1 parent ad7a64b commit e00e058

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

app/assets/javascripts/discourse/app/components/topic-list/item.gjs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import didInsert from "@ember/render-modifiers/modifiers/did-insert";
66
import { next } from "@ember/runloop";
77
import { service } from "@ember/service";
88
import { modifier } from "ember-modifier";
9-
import { eq } from "truth-helpers";
9+
import { eq, not } from "truth-helpers";
1010
import PluginOutlet from "discourse/components/plugin-outlet";
1111
import PostCountOrBadges from "discourse/components/topic-list/post-count-or-badges";
1212
import TopicExcerpt from "discourse/components/topic-list/topic-excerpt";
@@ -185,6 +185,18 @@ export default class Item extends Component {
185185
}
186186
}
187187

188+
get useMobileLayout() {
189+
return applyValueTransformer(
190+
"topic-list-item-mobile-layout",
191+
this.site.mobileView,
192+
{ topic: this.args.topic }
193+
);
194+
}
195+
196+
get useDesktopLayout() {
197+
return !this.useMobileLayout;
198+
}
199+
188200
<template>
189201
<tr
190202
{{! template-lint-disable no-invalid-interactive }}
@@ -210,15 +222,15 @@ export default class Item extends Component {
210222
(if @topic.closed "closed")
211223
this.tagClassNames
212224
(applyValueTransformer
213-
"topic-list-item-class" (array) (hash topic=@topic)
225+
"topic-list-item-class" (array) (hash topic=@topic index=@index)
214226
)
215227
}}
216228
>
217229
<PluginOutlet
218230
@name="above-topic-list-item"
219231
@outletArgs={{hash topic=@topic}}
220232
/>
221-
{{#if this.site.desktopView}}
233+
{{#if this.useDesktopLayout}}
222234
{{#each @columns as |entry|}}
223235
<entry.value.item
224236
@topic={{@topic}}

app/assets/javascripts/discourse/app/lib/transformer/registry.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ export const VALUE_TRANSFORMERS = Object.freeze([
1919
"small-user-attrs",
2020
"topic-list-columns",
2121
"topic-list-header-sortable-column",
22+
"topic-list-class",
2223
"topic-list-item-class",
24+
"topic-list-item-mobile-layout",
2325
]);

0 commit comments

Comments
 (0)