Skip to content

Commit 0b95202

Browse files
ndhuutaiTai Nguyen
andauthored
refactor(tutorial): use isProductAttachment type guard instead of inline predicate (#3213)
## Summary - In `5-custom-attachment-type/App.tsx`, `hasProductMessage` used an inline predicate `(attachment) => 'type' in attachment && attachment.type === 'product'` that duplicated the existing `isProductAttachment` type guard defined earlier in the same file. - Replaced the inline predicate with a direct reference to `isProductAttachment`. ## Test plan - [ ] No behaviour change — purely a refactor to reuse the existing type guard. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Documentation * **Examples**: Updated tutorial to demonstrate improved patterns for detecting and handling custom attachment types in message processing workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Tai Nguyen <tainguyen@Tais-MacBook-Pro-M4.local>
1 parent 2418025 commit 0b95202

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

  • examples/tutorial/src/5-custom-attachment-type

examples/tutorial/src/5-custom-attachment-type/App.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ const App = () => {
9393
await channel.watch();
9494

9595
const hasProductMessage = channel.state.messages.some((message) =>
96-
message.attachments?.some(
97-
(attachment) => 'type' in attachment && attachment.type === 'product',
98-
),
96+
message.attachments?.some(isProductAttachment),
9997
);
10098

10199
if (!hasProductMessage) {

0 commit comments

Comments
 (0)