Skip to content

Commit c3fb731

Browse files
authored
DEV: Added compatibility with the Glimmer Post Stream (#54)
Use a value transformer to update the avatar size in posts.
1 parent db23e1c commit c3fb731

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.5.0.beta8-dev: db23e1c3722f806aae55b2fb1301ac0cc461873b
12
< 3.5.0.beta5-dev: be98c06e3b2cb7d6e69d1664d7491a4ab2dc9369
23
< 3.5.0.beta3-dev: da212eb425c56bc24b8d1ed34b704789ea796014
34
< 3.5.0.beta1-dev: cdd6c447cc959e5e7bb9c9798b33044664f51534

javascripts/discourse/initializers/avatar.gjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import HeaderPostersCell from "discourse/components/topic-list/header/posters-cell";
22
import avatar from "discourse/helpers/avatar";
3+
import { withSilencedDeprecations } from "discourse/lib/deprecated";
34
import { withPluginApi } from "discourse/lib/plugin-api";
45

56
const ItemCell = <template>
@@ -14,7 +15,8 @@ const ItemCell = <template>
1415
href={{poster.user.path}}
1516
data-user-card={{poster.user.username}}
1617
class={{poster.extraClasses}}
17-
>{{avatar
18+
>
19+
{{avatar
1820
poster
1921
avatarTemplatePath="user.avatar_template"
2022
usernamePath="user.username"
@@ -30,11 +32,18 @@ export default {
3032
name: "discourse-avatar-component",
3133

3234
initialize() {
33-
withPluginApi("1.34.0", (api) => {
34-
api.changeWidgetSetting(
35-
"post-avatar",
36-
"size",
37-
settings.topic_avatars_size
35+
withPluginApi((api) => {
36+
api.registerValueTransformer(
37+
"post-avatar-size",
38+
() => settings.topic_avatars_size
39+
);
40+
41+
withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
42+
api.changeWidgetSetting(
43+
"post-avatar",
44+
"size",
45+
settings.topic_avatars_size
46+
)
3847
);
3948

4049
api.registerValueTransformer(

0 commit comments

Comments
 (0)