Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
megothss committed Jan 10, 2025
1 parent 9bd56ae commit 9d22a3d
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default apiInitializer("1.39.0", (api) => {
!(
siteSettings.whos_online_display_public ||
api.getCurrentUser()?.trust_level >=
siteSettings.whos_online_display_min_trust_level
siteSettings.whos_online_display_min_trust_level
)
) {
return;
Expand All @@ -33,7 +33,7 @@ export default apiInitializer("1.39.0", (api) => {
@discourseComputed("user", "whosOnline.users.[]")
isOnline(user) {
return user && this.whosOnline.isUserOnline(user.id);
}
},
});

api.modifyClass("route:user", {
Expand Down Expand Up @@ -65,12 +65,14 @@ export default apiInitializer("1.39.0", (api) => {
deactivate() {
this._super();
document.body.classList.remove("user-page-online");
}
},
});


if (siteSettings.whos_online_avatar_indicator_topic_lists) {
const addLastPosterOnlineClassNameTransformer = ({ value: additionalClasses, context: { topic } }) => {
const addLastPosterOnlineClassNameTransformer = ({
value: additionalClasses,
context: { topic },
}) => {
const whosOnline = api.container.lookup("service:whos-online");

const lastPosterId = topic.lastPoster.id;
Expand All @@ -83,8 +85,14 @@ export default apiInitializer("1.39.0", (api) => {
return additionalClasses;
};

api.registerValueTransformer("latest-topic-list-item-class", addLastPosterOnlineClassNameTransformer);
api.registerValueTransformer("topic-list-item-class", addLastPosterOnlineClassNameTransformer);
api.registerValueTransformer(
"latest-topic-list-item-class",
addLastPosterOnlineClassNameTransformer
);
api.registerValueTransformer(
"topic-list-item-class",
addLastPosterOnlineClassNameTransformer
);
}

api.modifyClass("component:scrolling-post-stream", {
Expand All @@ -109,12 +117,12 @@ export default apiInitializer("1.39.0", (api) => {
postIds.forEach((postId) => {
this.dirtyKeys.keyDirty(`post-${postId}`);
this.dirtyKeys.keyDirty(`post-${postId}-avatar-${id}`, {
onRefresh: "updateOnline"
onRefresh: "updateOnline",
});
});
});
this.queueRerender();
}
},
});

api.reopenWidget("post-avatar", {
Expand All @@ -124,7 +132,7 @@ export default apiInitializer("1.39.0", (api) => {
},
defaultState(attrs) {
return {
online: this.isUserOnline(attrs.user_id)
online: this.isUserOnline(attrs.user_id),
};
},
updateOnline() {
Expand All @@ -135,6 +143,6 @@ export default apiInitializer("1.39.0", (api) => {
return "user-online";
}
return [];
}
},
});
});

0 comments on commit 9d22a3d

Please sign in to comment.