RGJ
(Richard - Communiteq)
9월 22, 2025, 11:01오후
1
게시물의 작은 액션 설명을 CustomComponent로 선택적으로 대체하려고 합니다.
하지만 게시물이 value transformer에 올바르게 전달되지 않습니다.
Core 코드
@cached
get CustomComponent() {
return applyValueTransformer("post-small-action-custom-component", null, {
actionCode: this.code,
post: this.post,
});
}
제 디버깅 코드
api.registerValueTransformer(
"post-small-action-custom-component",
(arg) => {
console.log(arg);
}
);
출력:
context: Object { actionCode: "bid", post: undefined }
테스트 에서는 매개변수를 확인하지 않기 때문에 이 문제가 발견되지 않았습니다.
post 매개변수는 this.post가 아니라 this.args.post여야 할 것 같습니다.
컴포넌트를 무조건 추가하고 컴포넌트 자체에서 무엇을 해야 하는지 확인하도록 하는 우회 방법을 시도해 보았지만, 불행히도 인수도 올바르게 전달되지 않는 것 같아 우회 방법과 일반적인 구현 모두 여기서 실패합니다:
<this.CustomComponent
@code={{this.code}}
@post={{this.post}}
@createdAt={{this.createdAt}}
@path={{this.path}}
@username={{this.username}}
/>
PostSmallAction에는 code, createdAt, path를 위한 getter가 있지만(다시 한번) this.post는 존재하지 않고, username()에도 버그가 있는 것 같습니다(this.args.post에 action_code_who가 없나요?), 그래서 해당 속성들이 비어 있습니다.
기존의 "실제
RGJ
(Richard - Communiteq)
9월 23, 2025, 12:14오후
2
saquetim
(Sérgio Saquetim)
9월 23, 2025, 8:21오후
3
이 문제를 발견해 주셔서 감사합니다.
맞습니다. post 매개변수는 this.post 대신 this.args.post여야 합니다.
여기서 username은 다소 혼란을 줄 수 있습니다. action_code_who는 정확하지만 assign 플러그인 같은 일부 플러그인에서 사용되므로 post 객체에 항상 존재하는 것은 아닙니다. small action을 생성한 사용자를 가져오려면 @post.username을 사용할 수 있습니다.
PR에 변경 사항을 push할 수 있을지 확신이立た서, 이 문제들을 해결하기 위해 아래 PR을 열었습니다:
transformer와 커스텀 컴포넌트에 모두 전달되는 post 인수를 수정
해당 인수에 대한 혼란을 최소화하기 위해 username 인수를 who로 이름 변경
인수가 올바르게 전달되는지 확인하기 위한 테스트 추가
main ← dev/small-action-custom-component-arguments
merged 09:04PM - 23 Sep 25 UTC
Renamed `username` to `who` and updated the component to use `@args.post` consis… tently, improving the semantic clarity of the code. Adjusted related logic to reflect the new naming convention and fixed references accordingly.
Enhanced test coverage for custom components with new assertions verifying parameter bindings (e.g., `who`, `created_at`, `path`).
saquetim
(Sérgio Saquetim)
9월 23, 2025, 8:24오후
4
그렇다고 생각해요.
제가 아는 한, all-the-* 저장소에서 추적하는 커스텀화 프로젝트 어디에서도 구 API가 사용되지 않았습니다. 셀프 호스터가 이를 사용 중인 경우를 대비해 대안을 제공하기 위해 이 기능을 추가한 것뿐입니다.
RGJ
(Richard - Communiteq)
9월 23, 2025, 9:59오후
5
훌륭합니다!
선제적으로 조치해 주셔서 감사합니다
discourse-encrypt가 이전에 이를 사용했고, 우리가 유지 관리하는 3개의 (!) 비공개 플러그인도 사용하고 있습니다.
설명해 주셔서 감사합니다. 어떻게 작동하는지 이해하지 못했는데, 이제 이해하게 되었습니다.
마지막으로 한 가지 더 부탁드릴 것이 있습니다: 수정 사항을 안정 버전(stable)에도 백포트할 수 있을까요?
saquetim
(Sérgio Saquetim)
9월 24, 2025, 8:56오후
6