Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CM-1186] Add preFilledMessage support to conversationObject | iOS SDK #454

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

AbhijeetRanjan308
Copy link
Contributor

@AbhijeetRanjan308 AbhijeetRanjan308 commented Dec 3, 2024

Summary

  • Introduced a prefilledMessage parameter in the KMConversation object.
  • Created a method to create and launch conversations. This method accepts a KMConversation object and a UIViewController as parameters.
  • The prefilledMessage functionality is supported exclusively with the launchConversation method.

Refactored Code

// Build a conversation object with a prefilled message
let kmConversation = KMConversationBuilder()
    .setPreFilledMessage("This is the Prefill message.")
    .build()

// Launch the conversation using the created conversation object
Kommunicate.launchConversation(conversation: kmConversation, viewController: self) { result in
    switch result {
    case .success(let conversationId):
        print("Successfully created conversation with ID: \(conversationId)")
    case .failure(let error):
        print("Failed to create a conversation: \(error)")
    }
}

Summary by CodeRabbit

  • New Features

    • Introduced a pre-filled message option in the chat bar for enhanced user experience.
    • Added a method to launch group chats directly from a specified view controller.
  • Bug Fixes

    • Improved error handling and validation processes in the conversation launch functionality.

Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

The changes in this pull request introduce new functionality to the KMConversation and Kommunicate classes. A new property, prefilledMessage, is added to the KMConversation class to allow pre-filling messages in the chat bar. Additionally, a method setPreFilledMessage(_:) is introduced in the KMConversationBuilder class for setting this property. The Kommunicate class receives a new method, launchConversation, enabling the initiation of group chats from a specified UIViewController, incorporating various checks and validations.

Changes

File Path Change Summary
Sources/Kommunicate/Classes/KMConversation.swift - Added property: public var prefilledMessage: String? in KMConversation.
- Added method: @objc public func setPreFilledMessage(_ message: String) -> KMConversationBuilder in KMConversationBuilder.
Sources/Kommunicate/Classes/Kommunicate.swift - Added method: open class func launchConversation(conversation: KMConversation, viewController: UIViewController, completion: @escaping (Result<String, KMConversationError>) -> Void) in Kommunicate.
- Minor adjustments in createConversation method to support launchConversation.

Possibly related PRs

  • [CM-2230] Automation 6 Sanity Task | iOS SDK  #450: The changes in this PR involve the createConversation method, which is related to the new prefilledMessage functionality in the main PR, as both deal with conversation management within the KMConversation class.
  • [CM--2239] Automate iOS SDK Testing | iOS SDK #453: This PR introduces a test case for opening a specific conversation, which is relevant to the new launchConversation method in the main PR, as both involve the functionality of managing and interacting with conversations.

Suggested reviewers

  • adarshmishra

Poem

In a chat where messages flow,
A prefilled note now steals the show.
With a tap, the conversation starts,
In a world where every message imparts.
Hopping through code, we bring delight,
A new chat feature, shining bright! 🐇✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AbhijeetRanjan308
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented Dec 3, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
Sources/Kommunicate/Classes/KMConversation.swift (1)

124-131: Fix typos in documentation comment

The documentation has two typos:

  • "converwastion" should be "conversation"
  • "vissble" should be "visible"
-    /// To set pre fill message in Chat Bar while opening converwastion.
-    /// - Parameter message: Pass the text that should be vissble on chat bar while opening the conversation. Only works with `launchConversation`
+    /// To set pre fill message in Chat Bar while opening conversation.
+    /// - Parameter message: Pass the text that should be visible on chat bar while opening the conversation. Only works with `launchConversation`
Sources/Kommunicate/Classes/Kommunicate.swift (1)

495-586: LGTM: Well-structured implementation with comprehensive error handling

The implementation is thorough and follows best practices. Consider adding documentation for the possible error cases that can be returned in the completion handler to help API consumers better handle errors.

Add documentation for error cases, for example:

    /**
     Launch a new conversation with the details passed in group chat from a ViewController

     - Parameters:
     - conversation: An instance of `KMConversation` object.
     - viewController: ViewController from which the group chat will be launched.
     - completionHandler: If successful launch the conversation the success callback will have a conversationId else it will be KMConversationError on failure.
+
+    Possible errors returned in the completion handler:
+    - `.deviceRooted`: Device is suspected to be jailbroken
+    - `.internet`: No network connection available
+    - `.invalidTitle`: Conversation title is empty or invalid
+    - `.notLoggedIn`: User is not logged in
+    - `.api`: API related errors during conversation creation
     */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb3815 and bf55f30.

📒 Files selected for processing (2)
  • Sources/Kommunicate/Classes/KMConversation.swift (2 hunks)
  • Sources/Kommunicate/Classes/Kommunicate.swift (1 hunks)
🔇 Additional comments (1)
Sources/Kommunicate/Classes/KMConversation.swift (1)

26-26: LGTM: Property declaration looks good

The optional String property with a nil default value is appropriate for storing a prefilled message.

@AbhijeetRanjan308 AbhijeetRanjan308 merged commit 74af2fb into dev Dec 5, 2024
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants