Skip to content

Conversation

@twisti-dev
Copy link
Contributor

Overview of Changes

This refactor simplifies and enhances the setup of JoinConfiguration instances across methods used for rendering components, especially in collection-based join operations. It introduces clearer logic for prefix handling and improves code readability by reducing nested builder calls.

Details

  • Version bump

    • Updated version in gradle.properties from 1.21.4-2.13.1-SNAPSHOT to 1.21.4-2.13.2-SNAPSHOT.
  • Refactor: Flattened JoinConfiguration building

    • Replaced multi-line .builder() calls with single-line versions for improved readability.
    • Separated separator logic into named variables (separator) before building the configuration.
  • Enhancement: Added conditional prefix logic

    • Introduced logic to prepend the separator only if the collection or map has elements.
    • Ensures consistent and expected formatting without leading separators when empty.
  • Improved formatting functions

    • Enhanced formatting for lists and maps in methods like joinList and joinMap.
    • Applied color defaults using .colorIfAbsent(...) for key/value component styling.

Motivation

The changes aim to enhance code maintainability, consistency, and performance when constructing joined component messages. By reducing visual clutter and duplicative .builder() usage, the refactor makes future changes and debugging easier.

Impact

  • Improves code readability and maintainability.
  • Ensures consistent output formatting for UI components.
  • Prepares the ground for future extensibility in message formatting.

Testing

  • Manual verification of component output in various scenarios (empty, single-item, and multi-item collections/maps).
  • Ensured backward-compatible formatting by reviewing visual results in relevant UI contexts.

Additional Notes

  • Consider extracting separator builders into shared utility functions if reuse increases in future changes.

@twisti-dev twisti-dev added the type: Fix PR that fixes an issue label Apr 18, 2025
@twisti-dev twisti-dev added this to the Version 2.14.0 milestone Apr 18, 2025
@twisti-dev twisti-dev requested a review from Copilot April 18, 2025 21:26
@twisti-dev twisti-dev self-assigned this Apr 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the setup of JoinConfiguration instances to simplify builder calls and improve the component joining logic.

  • Streamlines JoinConfiguration builder calls to a single line for improved readability.
  • Introduces conditional prefix logic to avoid unnecessary separators when joining collections and maps.
  • Enhances formatting consistency in both list and map join methods.
Files not reviewed (1)
  • gradle.properties: Language not supported

…surfapi/core/api/messages/CommonComponents.kt

Co-authored-by: Copilot <[email protected]>
@twisti-dev twisti-dev merged commit f702452 into version/1.21 Apr 18, 2025
1 check passed
@twisti-dev twisti-dev deleted the fix/component-builder branch April 18, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Fix PR that fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants