Skip to content

Release/1.5.0#366

Merged
KommunicateDeveloper merged 16 commits intomasterfrom
dev
Apr 15, 2025
Merged

Release/1.5.0#366
KommunicateDeveloper merged 16 commits intomasterfrom
dev

Conversation

@KommunicateDeveloper
Copy link
Contributor

@KommunicateDeveloper KommunicateDeveloper commented Apr 15, 2025

Summary

  • Added Business Hours feature.
  • Disabled conversation restart when the restart button is hidden.
  • Enabled form data persistence in local cache.
  • Fixed character limit bug in Dialogflow bot.
  • Resolved bug in Text Area component.

Summary by CodeRabbit

  • New Features
    • Introduced Business Hours display in chat conversations.
    • Added persistent caching for form data, allowing data to be retained locally.
  • Improvements
    • Enhanced placeholder support for multiline text fields in forms.
    • Updated dropdown selection in forms for improved reliability.
    • Switched to new configuration and user defaults handlers for better consistency.
  • Bug Fixes
    • Fixed character limit issue in Dialogflow bot integration.
    • Resolved a bug affecting text area components in forms.
  • Chores
    • Updated SDK and dependency versions to 1.5.0.
    • Improved documentation and changelog entries.

@coderabbitai
Copy link

coderabbitai bot commented Apr 15, 2025

Walkthrough

This update introduces version 1.5.0 of the KommunicateChatUI-iOS-SDK, adding a Business Hours feature with a new UI component, persistent local caching for form data, and improvements to form dropdown handling. The codebase undergoes a comprehensive refactor, replacing references to ALApplozicSettings and ALUserDefaultsHandler with KMCoreSettings and KMCoreUserDefaultsHandler for settings and user defaults management. Several methods and types are updated to use new data structures and types, particularly for user details and form data. Additional bug fixes address character limits in bot integrations and text area components.

Changes

File(s) Change Summary
CHANGELOG.md Added entry for version 1.5.0: introduces Business Hours, disables conversation restart when button is hidden, adds local cache persistence for form data, and fixes bugs.
KommunicateChatUI-iOS-SDK.podspec
Package.swift
Package.resolved
Updated SDK version to 1.5.0 and dependency KommunicateCore-iOS-SDK to 1.3.0.
Sources/Controllers/ALKConversationListTableViewController.swift
Sources/Controllers/ALKConversationListViewController.swift
Sources/Controllers/ALKConversationViewController.swift
Sources/Controllers/ALKCreateGroupViewController.swift
Sources/Controllers/ALKNewChatViewController.swift
Sources/Controllers/ALKParticipantSelectionViewContoller.swift
Sources/Utilities/KMZendeskChatHandler.swift
Sources/ViewModels/ALKConversationListViewModel.swift
Sources/ViewModels/ALKConversationViewModel.swift
Sources/ViewModels/ALKCreateGroupViewModel.swift
Sources/ViewModels/ALKNewChatViewModel.swift
Sources/Utilities/ALKAppSettingsUserDefaults.swift
Sources/Utilities/ALKMessageViewModel+Extension.swift
Sources/Utilities/ALKHTTPManager.swift
Sources/Utilities/ALKVideoUploadManager.swift
Sources/Utilities/ALMessage+Extension.swift
Sources/Views/ALKAttatchmentView.swift
Sources/Views/ALKPhotoCell.swift
Sources/Views/ALKVideoCell.swift
Sources/Views/ALKInformationCell.swift
Sources/Views/ALKLocationCell.swift
Sources/Views/ALKMessageBaseCell.swift
Sources/Views/ALKReplyMessageView.swift
Sources/Views/KMLanguageView.swift
Sources/Views/SpeechToTextButton.swift
Replaced all references to ALApplozicSettings and ALUserDefaultsHandler with KMCoreSettings and KMCoreUserDefaultsHandler. Updated user detail types and related logic.
Sources/Controllers/ALKConversationViewController.swift Added businessHourView property (KMBusinessHoursView), dynamic height constraint, and methods for business hours info display. Added reply disabling logic based on conversation state. Integrated new form submission guards and updated layout.
Sources/Views/KMBusinessHoursView.swift Introduced new public UIView subclass for displaying business hours messages, with dynamic height calculation and configuration methods.
Sources/Views/ALKFormCell.swift Replaced tuple-based dropdown field with a dedicated DropDownField struct. Updated FormDataSubmit property and initializer. Improved type safety and clarity for dropdown handling.
Sources/Views/ALKFormTextItemCell.swift Added placeholder support to KMPaddedTextView with a label, updated text area cell to use new placeholder property, and improved dynamic text color handling.
Sources/Utilities/ALKFormDataCache.swift Made class and singleton public. Added persistent caching of form data to UserDefaults, retrieval with fallback, and a method to clear cache.
Sources/Views/ALKInformationCell.swift Refined comment height calculation for rating blocks, renamed variable for clarity, and improved padding logic.
Sources/Models/ALKChatBarConfiguration.swift Updated documentation to reference KMCoreUserDefaultsHandler for Google Map API key.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ALKConversationViewController
    participant KMBusinessHoursView

    User->>ALKConversationViewController: Opens conversation
    ALKConversationViewController->>KMBusinessHoursView: prepareBusinessHoursInfoView(message, isVisible)
    KMBusinessHoursView-->>ALKConversationViewController: Displays business hours message
    ALKConversationViewController->>User: Shows/hides reply options based on business hours and restart button state
Loading
sequenceDiagram
    participant User
    participant ALKFormCell
    participant ALKFormDataCache
    participant UserDefaults

    User->>ALKFormCell: Fills form fields
    ALKFormCell->>ALKFormDataCache: set(formData)
    ALKFormDataCache->>UserDefaults: Persist formData
    User->>ALKFormCell: Returns to form later
    ALKFormCell->>ALKFormDataCache: getFormData(formId)
    ALKFormDataCache->>UserDefaults: Retrieve formData if not in memory
    ALKFormDataCache-->>ALKFormCell: Returns formData
    ALKFormCell-->>User: Displays previously entered data
Loading

Possibly related PRs

  • #360: Modifies form cell and text area cell logic, directly relating to placeholder and form data persistence improvements.
  • #359: Implements local cache persistence for form data and restructures dropdown field data, matching the main PR’s enhancements.
  • #355: Adds Business Hours feature and disables reply submission when conversation is resolved, directly matching new logic here.

Suggested reviewers

  • adarshmishra
  • prateek-kommunicate

Poem

🐇
Version hop, a leap so bright—
Business hours now in sight!
Forms remember what you say,
Caches save it for the day.
Dropdowns smarter, bugs take flight,
Settings swapped for future light.
In the warren, code delights!

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate docstrings to generate docstrings for this 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.

Copy link

@prateek-kommunicate prateek-kommunicate left a comment

Choose a reason for hiding this comment

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

LGTM!

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

🧹 Nitpick comments (7)
Sources/Utilities/ALKFormDataCache.swift (2)

19-27: Proper implementation of persistent data storage.

The implementation correctly stores data both in memory and UserDefaults. Consider adding error handling for encoding failures and making this method thread-safe with a dispatch queue or synchronization mechanism for concurrent access.

 func set(_ formDataSubmit: FormDataSubmit, for key: String) {
     let cacheKey = key as NSString
     cache.setObject(formDataSubmit, forKey: cacheKey)
     
     // Persist to UserDefaults
+    do {
         if let encodedData = try? JSONEncoder().encode(formDataSubmit) {
             UserDefaults.standard.set(encodedData, forKey: userDefaultsKeyPrefix + key)
         }
+    } catch {
+        print("Error encoding form data: \(error.localizedDescription)")
+    }
 }

51-64: Complete cache clearing implementation.

The method effectively clears both in-memory and UserDefaults-based cache. The use of hasPrefix to target only relevant keys is a good practice. However, consider if synchronize() is necessary, as it's deprecated in newer iOS versions.

 public func clearCache() {
     cache.removeAllObjects() // Clear in-memory cache
         
     let userDefaults = UserDefaults.standard
     let allKeys = userDefaults.dictionaryRepresentation().keys
         
     // Remove only keys related to FormDataCache
     for key in allKeys where key.hasPrefix(userDefaultsKeyPrefix) {
         userDefaults.removeObject(forKey: key)
     }
-        
-    userDefaults.synchronize() // Ensure changes are applied
 }
Sources/Views/KMBusinessHoursView.swift (2)

32-47: Good constraint setup with clear organization.

The constraints are well-organized and properly establish the hierarchy and spacing between elements. Consider adding a bottom constraint for the message label to ensure proper vertical sizing.

 NSLayoutConstraint.activate([
     lineImageView.topAnchor.constraint(equalTo: view.topAnchor),
     lineImageView.heightAnchor.constraint(equalToConstant: 2),
     lineImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
     lineImageView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
     // Title Label
     businessHourMessageLabel.topAnchor.constraint(equalTo: lineImageView.topAnchor),
     businessHourMessageLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 15),
     businessHourMessageLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -15),
     businessHourMessageLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor),
+    businessHourMessageLabel.bottomAnchor.constraint(lessThanOrEqualTo: view.bottomAnchor, constant: -10)
 ])

49-54: Simple and effective message configuration.

The configuration method is straightforward and handles all necessary styling. Consider adding dynamic color support for better dark mode adaptation.

 public func configureMessage(message: String) {
     businessHourMessageLabel.text = message
     businessHourMessageLabel.font = Font.bold(size: 16.0).font()
-    businessHourMessageLabel.textColor = .white
-    lineImageView.backgroundColor = .white
+    businessHourMessageLabel.textColor = UIColor.dynamicColor(light: .white, dark: .white)
+    lineImageView.backgroundColor = UIColor.dynamicColor(light: .white, dark: .white)
 }
Sources/Views/ALKFormTextItemCell.swift (2)

249-256: Placeholder label setup looks good.

Consider updating the font when the text view’s font changes so that the placeholder always matches the current text style.

 func setCustomFont(_ newFont: UIFont) {
     self.font = newFont
+    placeholderLabel.font = newFont
     updatePlaceholderVisibility()
 }

276-299: Internal delegate usage and observer registration.

  1. Assigning delegate = self can conflict if consuming code also wants to implement a delegate for the text view. Consider exposing a forwarding delegate.
  2. Good job removing the observer in deinit, preventing memory leaks.
Sources/Controllers/ALKConversationViewController.swift (1)

3174-3174: Identical file-size check for videos.
Same note about confirming MB vs. 1024 approach to ensure consistent upload limits.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1b58ed and abbe39a.

⛔ Files ignored due to path filters (1)
  • Demo/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (35)
  • CHANGELOG.md (1 hunks)
  • KommunicateChatUI-iOS-SDK.podspec (2 hunks)
  • Package.resolved (1 hunks)
  • Package.swift (1 hunks)
  • Sources/Controllers/ALKConversationListTableViewController.swift (2 hunks)
  • Sources/Controllers/ALKConversationListViewController.swift (2 hunks)
  • Sources/Controllers/ALKConversationViewController+DocumentManager.swift (1 hunks)
  • Sources/Controllers/ALKConversationViewController.swift (21 hunks)
  • Sources/Controllers/ALKCreateGroupViewController.swift (1 hunks)
  • Sources/Controllers/ALKNewChatViewController.swift (3 hunks)
  • Sources/Controllers/ALKParticipantSelectionViewContoller.swift (3 hunks)
  • Sources/Models/ALKChatBarConfiguration.swift (1 hunks)
  • Sources/Utilities/ALKAppSettingsUserDefaults.swift (1 hunks)
  • Sources/Utilities/ALKFormDataCache.swift (1 hunks)
  • Sources/Utilities/ALKHTTPManager.swift (4 hunks)
  • Sources/Utilities/ALKMessageViewModel+Extension.swift (1 hunks)
  • Sources/Utilities/ALKVideoUploadManager.swift (4 hunks)
  • Sources/Utilities/ALMessage+Extension.swift (3 hunks)
  • Sources/Utilities/KMZendeskChatHandler.swift (9 hunks)
  • Sources/ViewModels/ALKConversationListViewModel.swift (2 hunks)
  • Sources/ViewModels/ALKConversationViewModel.swift (13 hunks)
  • Sources/ViewModels/ALKCreateGroupViewModel.swift (4 hunks)
  • Sources/ViewModels/ALKNewChatViewModel.swift (4 hunks)
  • Sources/Views/ALKAttatchmentView.swift (1 hunks)
  • Sources/Views/ALKFormCell.swift (4 hunks)
  • Sources/Views/ALKFormTextItemCell.swift (3 hunks)
  • Sources/Views/ALKInformationCell.swift (2 hunks)
  • Sources/Views/ALKLocationCell.swift (1 hunks)
  • Sources/Views/ALKMessageBaseCell.swift (1 hunks)
  • Sources/Views/ALKPhotoCell.swift (1 hunks)
  • Sources/Views/ALKReplyMessageView.swift (1 hunks)
  • Sources/Views/ALKVideoCell.swift (1 hunks)
  • Sources/Views/KMBusinessHoursView.swift (1 hunks)
  • Sources/Views/KMLanguageView.swift (2 hunks)
  • Sources/Views/SpeechToTextButton.swift (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
Sources/Views/KMBusinessHoursView.swift (1)
Learnt from: AbhijeetRanjan308
PR: Kommunicate-io/KommunicateChatUI-iOS-SDK#354
File: Sources/Controllers/ALKConversationViewController.swift:700-710
Timestamp: 2025-03-20T11:34:05.504Z
Learning: The `KMBusinessHoursView.estimateHeightForMessage()` method already returns zero for empty messages, making additional empty string checks redundant when setting the view's height constraint.
🧬 Code Graph Analysis (4)
Sources/Controllers/ALKConversationViewController+DocumentManager.swift (1)
Sources/Utilities/ALKFileUtils.swift (1)
  • sizeOfFile (120-125)
Sources/Views/KMBusinessHoursView.swift (1)
Sources/Controllers/ALKConversationViewController.swift (1)
  • setupConstraints (725-831)
Sources/Utilities/ALKFormDataCache.swift (1)
Sources/Utilities/ALKHTTPManager.swift (1)
  • hasPrefix (24-26)
Sources/Controllers/ALKConversationListViewController.swift (1)
Sources/Controllers/ALKConversationViewController.swift (1)
  • updateLastSeen (3058-3065)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Lint
🔇 Additional comments (103)
Sources/Models/ALKChatBarConfiguration.swift (1)

21-21: Documentation update aligns with codebase migration.

The comment now correctly references KMCoreUserDefaultsHandler, ensuring consistency with the updated settings/user defaults handler throughout the codebase.

Sources/Controllers/ALKConversationViewController+DocumentManager.swift (1)

14-14: Appropriate namespace migration for configuration settings.

The change from ALApplozicSettings to KMCoreSettings for retrieving the maximum image upload size aligns with the broader SDK refactoring effort. This maintains the same functionality while moving to the more appropriate namespace.

Package.swift (1)

19-19: Version update looks good!

The dependency version for KommunicateCore_iOS_SDK has been updated from 1.2.6 to 1.3.0, which correctly aligns with the corresponding updates in other package management files (Package.resolved and podspec).

KommunicateChatUI-iOS-SDK.podspec (2)

3-3: Appropriate version bump for new features

The SDK version increase to 1.5.0 properly reflects the significant new features being added (Business Hours, form data persistence, etc.).


32-32: Dependency version synchronized correctly

The KommunicateCore-iOS-SDK dependency version has been updated to 1.3.0, maintaining consistency with the Swift Package Manager configuration.

Package.resolved (1)

36-37: Package resolution correctly updated

The revision hash and version update for KommunicateCore_iOS_SDK are consistent with the package specification changes.

Sources/Views/ALKReplyMessageView.swift (1)

276-278: Refactoring to new API handlers looks good

The migration from ALUserDefaultsHandler to KMCoreUserDefaultsHandler for Google Maps API key retrieval is correctly implemented. This is part of a broader refactoring to standardize on the KMCore namespace for settings and user defaults.

Sources/Views/SpeechToTextButton.swift (1)

105-105: Consistent refactoring to new settings handlers

This change correctly replaces ALApplozicSettings with KMCoreSettings for retrieving speech-to-text language settings, consistent with the broader refactoring pattern across the codebase.

Sources/Views/ALKLocationCell.swift (1)

141-142: Updates API key retrieval source to KMCoreUserDefaultsHandler

This change aligns with the broader codebase refactoring from ALUserDefaultsHandler to KMCoreUserDefaultsHandler.

Sources/Views/ALKPhotoCell.swift (1)

332-332: Updates storage service checks to use KMCoreSettings

This change is part of the broader refactoring from ALApplozicSettings to KMCoreSettings.

Sources/Utilities/ALKAppSettingsUserDefaults.swift (1)

169-170: Updates default upload override methods to use KMCoreSettings

This change maintains the same functionality while updating to use the new KMCoreSettings class.

Sources/Controllers/ALKCreateGroupViewController.swift (1)

160-160: Updates base URL retrieval to use KMCoreUserDefaultsHandler

This change is consistent with the broader refactoring to use KMCore classes.

Sources/ViewModels/ALKCreateGroupViewModel.swift (5)

80-80: Consistent reference update to KM Core module

The code updates the reference from ALUserDefaultsHandler.getUserId() to KMCoreUserDefaultsHandler.getUserId(), which aligns with the broader SDK refactoring effort to use the newer Core module.


118-118: Appropriate handler migration

Updated user ID filtering to use the new handler, maintaining the same functionality while modernizing the codebase.


163-163: Consistent handler migration

Admin check updated to use KMCoreUserDefaultsHandler, continuing the pattern of migrating to the new Core module.


182-182: Successful migration to new defaults handler

Contact loading now uses the updated UserDefaults handler, consistent with the other changes in this file.


188-188: Completed handler migration

Final instance of the handler updated, ensuring all references now use the new KMCoreUserDefaultsHandler.

CHANGELOG.md (1)

5-10: Clear and informative release notes

The changelog for version 1.5.0 clearly documents the new features and bug fixes, providing good visibility into what's changing in this release.

Key additions include:

  • Business Hours feature
  • Form data persistence
  • Multiple bug fixes

These align with the code changes seen in the pull request.

Sources/Views/ALKAttatchmentView.swift (1)

81-82: Settings class migration completed

Successfully updated references from ALApplozicSettings to KMCoreSettings for storage service checks. This change is part of the broader effort to migrate to the new Core module.

Sources/Utilities/ALKMessageViewModel+Extension.swift (1)

44-46: Settings class migration for bot customization

Updated the bot configuration retrieval to use KMCoreSettings instead of ALApplozicSettings, maintaining consistent usage of the new Core module across the codebase.

Sources/Views/ALKMessageBaseCell.swift (1)

509-513: Consistent handler migration for Google Map API key access

The update to KMCoreUserDefaultsHandler for retrieving and setting the Google Map API key aligns with the broader refactoring effort across the codebase, ensuring a standardized approach to configuration management.

Sources/Views/ALKVideoCell.swift (1)

306-306: Storage service check migrated to KMCoreSettings

The migration from ALApplozicSettings to KMCoreSettings for checking storage service enablement maintains the same functionality while standardizing the configuration source.

Sources/Utilities/ALKHTTPManager.swift (5)

119-119: Storage service check migrated to KMCoreSettings

The migration from ALApplozicSettings to KMCoreSettings for checking storage service enablement is consistent with the broader refactoring approach.


159-161: S3 storage and upload URL checks migrated to KMCoreSettings

The configuration source has been updated while maintaining the same conditional logic for S3 storage and file naming.


164-168: Upload headers retrieval migrated to KMCoreSettings

Custom headers retrieval is now using the standardized KMCoreSettings class.


183-183: S3 parameter selection logic migrated to KMCoreSettings

File parameter constant selection based on storage type now uses KMCoreSettings.


196-201: Override upload URL check migrated to KMCoreSettings

The conditional block for handling custom upload URLs now uses KMCoreSettings while maintaining the same functionality.

Sources/Views/KMLanguageView.swift (2)

64-65: Language setting retrieval migrated to KMCoreSettings

The saved language code check now uses KMCoreSettings, consistent with the codebase-wide refactoring.


93-93: Language setting storage migrated to KMCoreSettings

Language code storage for speech-to-text now uses KMCoreSettings, maintaining functionality while standardizing the configuration approach.

Sources/Controllers/ALKConversationListTableViewController.swift (2)

486-487: Consistent refactoring of user ID retrieval

The change from ALUserDefaultsHandler.getUserId() to KMCoreUserDefaultsHandler.getUserId() aligns with the broader refactoring effort to standardize on KMCore variants for settings and user defaults throughout the SDK.


544-545: Consistent refactoring of user ID retrieval

This is another instance of the same refactoring pattern, replacing ALUserDefaultsHandler.getUserId() with KMCoreUserDefaultsHandler.getUserId() to maintain consistency across the codebase.

Sources/Utilities/ALKVideoUploadManager.swift (4)

83-87: Consistent replacement of settings handler

The change from ALApplozicSettings to KMCoreSettings for upload headers is part of the broader refactoring to standardize on KMCore variants for settings management.


120-121: Standardized settings check for S3 storage

Replacing ALApplozicSettings.isS3StorageServiceEnabled() with KMCoreSettings.isS3StorageServiceEnabled() maintains consistency with the refactoring approach across the codebase.


133-134: Consistent settings override URL check

Changing from ALApplozicSettings.getDefaultOverrideuploadUrl() to KMCoreSettings.getDefaultOverrideuploadUrl() follows the same refactoring pattern to use KMCore variants for settings.


162-167: Standardized S3 storage check for file metadata

The replacement of ALApplozicSettings.isS3StorageServiceEnabled() with KMCoreSettings.isS3StorageServiceEnabled() maintains consistency with the refactoring effort.

Sources/ViewModels/ALKConversationListViewModel.swift (2)

195-200: Updated parameter type for user details

The parameter type change from ALUserDetail to KMCoreUserDetail is part of the broader refactoring to standardize on KMCore data models. This ensures consistency with the updated SDK structure.


209-209: Standardized fetch flag check

Replacing ALUserDefaultsHandler.getFlagForAllConversationFetched() with KMCoreUserDefaultsHandler.getFlagForAllConversationFetched() aligns with the broader refactoring effort for user defaults handling.

Sources/Utilities/ALMessage+Extension.swift (3)

17-17: Updated file URL source for image base URL

The change from ALUserDefaultsHandler.getFILEURL() to KMCoreUserDefaultsHandler.getFILEURL() maintains consistency with the refactoring to use KMCore variants for user defaults.


71-74: Standardized bot name and ID retrieval

Replacing ALApplozicSettings with KMCoreSettings for custom bot ID and name follows the consistent refactoring pattern across the codebase.


273-275: Updated override URL check in messageType property

Changing from ALApplozicSettings.getDefaultOverrideuploadUrl() to KMCoreSettings.getDefaultOverrideuploadUrl() aligns with the broader refactoring effort for settings management.

Sources/ViewModels/ALKConversationViewModel.swift (14)

208-214: Good replacement of ALUserDefaultsHandler with KMCoreUserDefaultsHandler.

The code now uses KMCoreUserDefaultsHandler for checking if the server call is done for a chat ID. This is part of a systematic update across the codebase to use the KMCore classes instead of the AL classes.


287-289: LGTM! Consistent update to use KMCoreUserDefaultsHandler.

The filter condition for user ID now correctly uses the new KMCoreUserDefaultsHandler class. This maintains functionality while aligning with the refactoring approach.


588-590: Correctly updated comment and condition to use KMCoreSettings.

The comment and condition now properly refer to KMCoreSettings instead of ALApplozicSettings when checking for storage service configuration.


1190-1197: Good refactoring to use KMCoreSettings for upload handling.

The code now correctly uses KMCoreSettings for checking upload URL override and S3 storage service settings.


1221-1225: Successfully updated upload URL check to use KMCoreSettings.

This condition now correctly uses KMCoreSettings.getDefaultOverrideuploadUrl() to check for a custom upload URL override setting.


1242-1243: Proper update for typing status API call.

The code now uses KMCoreUserDefaultsHandler.getApplicationKey() for sending typing status, maintaining functionality while using the new class.


1255-1256: Good update for keyboard done typing method.

The typing status update when keyboard finishes typing is now correctly using KMCoreUserDefaultsHandler for the application key.


1262-1267: Updated device key comparison correctly.

The check for whether a message is from a different device now uses KMCoreUserDefaultsHandler for getting the device key string.


1279-1287: Successfully updated user defaults handler reference in refresh method.

The call to get latest messages now uses KMCoreUserDefaultsHandler.getDeviceKeyString() instead of the AL version.


1556-1558: Updated configuration check for agent app settings.

Now using KMCoreSettings to check if agent app configuration is enabled, maintaining functionality while using the new KMCore class.


1792-1797: Updated load earlier messages option check.

The code now uses KMCoreUserDefaultsHandler for checking the "show load earlier option" setting.


1808-1810: Consistent update for agent app configuration check.

Similar to the earlier instance, this code now uses KMCoreSettings to check if agent app configuration is enabled.


1870-1873: Updated user filtering to use KMCoreUserDefaultsHandler.

The filter condition now uses KMCoreUserDefaultsHandler.getUserId() to exclude the current user from the group members list.


2042-2052: Updated device key assignment in message creation.

The code now correctly uses KMCoreUserDefaultsHandler.getDeviceKeyString() when setting the device key on a new message.

Sources/Controllers/ALKParticipantSelectionViewContoller.swift (3)

145-147: Properly updated contacts group settings check.

Now using KMCoreSettings.isContactsGroupEnabled() and KMCoreSettings.getContactsGroupId() for contacts group handling.


163-165: Successfully updated user visibility and ID checks.

The predicate for fetching contacts now uses KMCoreUserDefaultsHandler for login user contact visibility and user ID.


201-202: Updated login user ID retrieval.

Now properly using KMCoreUserDefaultsHandler.getUserId() to get the current user's ID when filtering contacts.

Sources/Controllers/ALKNewChatViewController.swift (2)

54-55: Updated contact server call flag setting.

Now using KMCoreUserDefaultsHandler to set the contact server call status when the view loads.


179-193: Updated contact group check and server call flag.

The code now uses KMCoreSettings.isContactsGroupEnabled() for the contacts group check and KMCoreUserDefaultsHandler.setContactServerCallIsDone() to update the server call status.

Sources/Utilities/KMZendeskChatHandler.swift (10)

86-87: Successfully updated chat transcript setting check.

Now using KMCoreSettings to check if a chat transcript has been sent for the current group.


113-117: Updated Zendesk SDK account key retrieval.

Now using KMCoreSettings to get the Zendesk SDK account key, maintaining the same functionality.


153-154: Updated Zendesk last sync time retrieval.

The code now uses KMCoreSettings to get the last sync time for Zendesk interactions.


162-164: Updated user ID retrieval.

Now using KMCoreUserDefaultsHandler to get the current user's ID.


167-176: User handler reference updated.

The user handler reference is now correctly using KMCoreUserDefaultsHandler.


290-292: Updated user details type.

The code now uses KMCoreUserDetail instead of ALUserDetail when casting user array values, aligning with the KMCore class refactoring approach.


335-336: Updated transcript sent flag setting.

Now using KMCoreSettings to set the chat transcript sent flag.


348-355: Updated user detail type in bot name method parameter.

The getBotNameById function now correctly accepts an array of KMCoreUserDetail instead of ALUserDetail.

🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 350-350: where clauses are preferred over a single if inside a for

(for_where)


379-380: Updated Zendesk last sync time saving.

The code now uses KMCoreSettings to save the Zendesk last sync time.


484-485: Updated auth token retrieval.

Now using KMCoreUserDefaultsHandler to get the auth token for attachment message processing.

Sources/Controllers/ALKConversationListViewController.swift (2)

510-519: Correct type update to KMCoreUserDetail.

The change from ALUserDetail to KMCoreUserDetail aligns with the broader migration pattern across the codebase. The proper implementation maintains functionality while updating to the new type system.


521-528: Type change implemented consistently.

The update of the parameter type to KMCoreUserDetail is consistent with the change in the reloadData method above. This maintains compatibility with the corresponding method in ALKConversationViewController which also uses this type.

Sources/Utilities/ALKFormDataCache.swift (3)

10-13: Good addition of public access and key prefix.

Making the class and singleton public improves reusability across the application. The key prefix follows best practices for UserDefaults namespacing to avoid conflicts with other stored values.


29-45: Effective caching strategy with fallback mechanism.

The implementation correctly checks in-memory cache first before falling back to UserDefaults, which is an efficient approach. The code also wisely stores retrieved data back into the memory cache for faster future access.


47-49: Good simplification of default object retrieval.

The refactoring simplifies the method by leveraging the existing getFormData method with the nil coalescing operator, improving code reuse and maintainability.

Sources/ViewModels/ALKNewChatViewModel.swift (4)

21-21: Correct migration to KMCoreSettings.

The type change is aligned with the SDK-wide migration from ALApplozicSettings to KMCoreSettings.


40-42: Settings access updated consistently.

The migration to use KMCoreSettings methods for feature flags and configuration values is implemented correctly.


72-72: User ID retrieval updated appropriately.

The use of KMCoreUserDefaultsHandler for user ID retrieval is consistent with the codebase migration pattern.


93-95: Complete update of user defaults handler references.

All user defaults handler references in the predicate creation have been updated, maintaining consistent usage of the KMCore variants throughout the codebase.

Sources/Views/KMBusinessHoursView.swift (2)

11-31: Well-structured Business Hours view implementation.

The view setup follows good UIKit practices with proper initialization and disabled Interface Builder integration. The subviews are created with appropriate configurations, particularly the multi-line support for the label.


56-67: Good height calculation implementation.

The height estimation method correctly handles empty messages and calculates appropriate height based on text content and device width. The explicit handling of empty messages aligns with the learning from PR #354, avoiding redundant checks when setting the view's height constraint.

Sources/Views/ALKFormCell.swift (4)

235-240: Good handling of text area data.

The approach of conditionally setting the text from formDataSubmit.textViews or defaulting to "" is consistent and maintains data integrity.


513-520: Struct-based dropdown storage is well-structured.

Rewriting the dropdown logic with DropDownField tidies up data handling and readability. This is a clean improvement from the previous tuple approach.


627-640: New form data containers look good.

Defining DropDownField and centralizing all form field dictionaries under FormDataSubmit clarifies the form's data model. Making them Codable is also beneficial for persistence.


433-436:

Details

❓ Verification inconclusive

Check for out-of-range indexes in dropdown options.

When assigning selectedIndex = fields.id and using cell.options?[fields.id], ensure fields.id is valid for the size of cell.options to avoid issues if the index is out of range.

To confirm safety, you can scan for where cell.options is populated:


🏁 Script executed:

#!/bin/bash
# Verify the usage and length checks of cell.options
rg -A 5 "cell\.options ="

Length of output: 27


Validate dropdown options index range

The current code at Sources/Views/ALKFormCell.swift (lines 433–436) assigns selectedIndex = fields.id and immediately uses it to access cell.options?[fields.id].label without checking whether fields.id is within the bounds of the cell.options array. Although the grep command for cell.options = didn’t return any output, this absence of evidence suggests that there isn’t any obvious length check in place. It is therefore recommended to add a boundary check before accessing the dropdown options.

For example, you might consider an update like this:

if let options = cell.options, fields.id < options.count {
    cell.menu.selectedIndex = fields.id
    cell.menu.text = options[fields.id].label
} else {
    // Handle the out-of-range scenario, e.g., log an error or set a default value
}

Please perform manual verification or further code review to ensure that:

  • cell.options is populated correctly elsewhere in the codebase.
  • Adding this boundary check aligns with the overall data flow and error handling strategy.
Sources/Views/ALKInformationCell.swift (3)

153-158: Switch to KMCoreSettings is consistent.

Checking KMCoreSettings.isAgentAppConfigurationEnabled() keeps agent app configuration logic aligned with the rest of the refactor.


160-195: Reconsider string replacement for boundingRect.

Replacing spaces with 'd' might cause slightly inaccurate text measurements. Confirm if this is truly needed, or add a comment clarifying the rationale. Without a solid reason, removing this replacement may yield more accurate boundingRect calculations.


213-213: Agent configuration check updated correctly.

This aligns with the overall switch from ALApplozicSettings to KMCoreSettings.

Sources/Views/ALKFormTextItemCell.swift (3)

101-102: Placeholder assignment is clear and consistent.

Assigning the placeholder from item.placeholder maintains consistency with the approach used for other form fields.


242-247: Dynamic placeholder assignment is appropriate.

Updating the placeholder label’s text and visibility upon assignment is straightforward and maintains clarity for users when the field is empty.


258-262: Placeholder visibility update upon text change is optimal.

This ensures accurate placeholder display under various editing scenarios.

Sources/Controllers/ALKConversationViewController.swift (13)

197-200: New businessHourView property looks consistent.
A straightforward lazy-like property initialization with a closure. It effectively creates an instance of KMBusinessHoursView.


201-201: No review needed.
Blank line introduced; no functional changes.


545-545: Proper migration to KMCoreSettings.
Switching to KMCoreSettings is aligned with the broader migration effort. Looks good.


669-669: Check for potential nil user ID.
Ensure KMCoreUserDefaultsHandler.getUserId() cannot be nil. If it can, this conditional might cause unintended behavior.


677-677: Guard against potential missing user ID.
Same concern as above; confirm that KMCoreUserDefaultsHandler.getUserId() never returns nil.


698-699: Height constraint property is consistent.
Keeping the constraint private is a good practice to avoid exposure. No changes required.


700-710: Animated layout update for business hours info is well-structured.
This function nicely estimates the view height and animates height changes. Consider ensuring calls happen on the main thread if invoked from background contexts.


711-711: No review needed.
Blank line introduced; no functional changes.


1251-1256: Verify default return of true when channel is missing.
Consider whether allowing replies when channel is nil is intended. Otherwise, looks correct for resolved vs. restart button checks.


1823-1823: Guard statement strengthens reply restriction logic.
Early return if the conversation is disabled, which is consistent with isConversationResolvedAndReplyEnabled().


2021-2024: Ensure fallback handling for option.text.
Assigning option.text directly is fine, but confirm the .text is never nil or empty.


3123-3123: Upload size check added for images.
Helps prevent oversized uploads. Including an alert for user feedback is good.


3150-3150: Confirm MB vs. 1024 multiplier for GIF size check.
Using * 1024 might be correct, but verify that getMaxImageSizeForUploadInMB() aligns with base-2 or base-10 expectations.

@github-actions
Copy link

iOS Lint Test Result
Congratulations! Linter Check Passed Successfully 🎉

@KommunicateDeveloper KommunicateDeveloper merged commit 80b9fb1 into master Apr 15, 2025
2 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.

3 participants