Skip to content

fix: multi screen views action handling #920

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

Merged
merged 4 commits into from
May 27, 2025
Merged

fix: multi screen views action handling #920

merged 4 commits into from
May 27, 2025

Conversation

Shahroz16
Copy link
Contributor

@Shahroz16 Shahroz16 commented May 20, 2025

Summary:

  • Added a new GistViewLifecycleDelegate protocol to improve the handling of view lifecycle events
  • Refactored message view dismissal logic to respect different manager contexts
  • Enhanced test coverage for Gist components with comprehensive test suites

Changes:

  • Created a new GistViewLifecycleDelegate protocol to properly handle view removal events
  • Moved dismissal logic from GistView to the appropriate message managers
  • Implemented context-specific handling:
    • InlineMessageManager: Automatically dismisses messages when views are removed
    • ModalMessageManager: Skips auto-dismissal since modals have their own dismissal flow. This was root cause of multi screen messages, when one would hinder the other dismissal flow.

Testing:

  • Added GistViewLifecycleDelegateTests to verify the new lifecycle delegation system works correctly
  • Created GistDelegateImplTests to improve test coverage of event handling
  • Updated ThreadUtilStub to support better testing of UI operations

Testing Instructions:

  1. Run the MessagingInApp test suite to verify all tests pass
  2. Test inline message embedding/dismissal to ensure they dismiss correctly when removed
  3. Test modal messages to verify they don't auto-dismiss when their view is removed

Here is a link to the multi screen message that we can use to reproduce on main branch, when tested on real device and in this branch you should not face it.

Video created from main before the fix

in-app.mov

Copy link

github-actions bot commented May 20, 2025

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps.
It's recommended to always download the latest builds to test this PR accurately.

Copy link

github-actions bot commented May 20, 2025

SDK binary size reports 📊

SDK binary size of this PR
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  16.5%   160Ki  16.5%   160Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/autogenerated/AutoMockable.generated.swift
   4.0%  38.9Ki   4.0%  38.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventBusHandler.swift
   3.7%  36.0Ki   3.7%  36.0Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/autogenerated/AutoMockable.generated.swift
   3.6%  35.4Ki   3.6%  35.4Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/autogenerated/AutoMockable.generated.swift
   2.7%  25.8Ki   2.7%  25.8Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageManager.swift
   2.4%  23.0Ki   2.4%  23.0Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/DataPipelineImplementation.swift
   2.3%  22.8Ki   2.3%  22.8Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/autogenerated/AutoMockable.generated.swift
   2.2%  21.6Ki   2.2%  21.6Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/QueueStorage.swift
   1.9%  18.9Ki   1.9%  18.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/autogenerated/AutoMockable.generated.swift
   1.9%  18.6Ki   1.9%  18.6Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/Event.swift
   1.8%  18.0Ki   1.8%  18.0Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/AnyEncodable.swift
   1.7%  16.9Ki   1.7%  16.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageMiddleware.swift
   1.7%  16.3Ki   1.7%  16.3Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/autogenerated/AutoDependencyInjection.generated.swift
   1.6%  15.6Ki   1.6%  15.6Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Type/PushNotification.swift
   1.5%  15.0Ki   1.5%  15.0Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventMemoryStorage.swift
   1.5%  14.3Ki   1.5%  14.3Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageState.swift
   1.4%  13.5Ki   1.4%  13.5Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventStorage.swift
   1.2%  11.8Ki   1.2%  11.8Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/DataPipeline.swift
   1.2%  11.3Ki   1.2%  11.3Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/MessageManager.swift
   1.1%  10.2Ki   1.1%  10.2Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/PushEventHandlerProxy.swift
   1.0%  9.63Ki   1.0%  9.63Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/GistInlineInAppMessageView.swift
   1.0%  9.61Ki   1.0%  9.61Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/JsonAdapter.swift
   1.0%  9.41Ki   1.0%  9.41Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWeb.swift
   1.0%  9.30Ki   1.0%  9.30Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageReducer.swift
   1.0%  9.29Ki   1.0%  9.29Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/CustomerIOInstance.swift
   0.9%  8.83Ki   0.9%  8.83Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/TrackDeliveryEventRequestBody.swift
   0.9%  8.74Ki   0.9%  8.74Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/AutoTrackingScreenViews.swift
   0.9%  8.64Ki   0.9%  8.64Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/UserNotificationsFramework/Wrappers.swift
   0.9%  8.57Ki   0.9%  8.57Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Integration/CioProviderAgnosticAppDelegate.swift
   0.9%  8.28Ki   0.9%  8.28Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Log.swift
   0.8%  8.23Ki   0.8%  8.23Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Queue.swift
   0.8%  8.22Ki   0.8%  8.22Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/DataPipelineMigrationAssistant.swift
   0.8%  8.18Ki   0.8%  8.18Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/UIKitInline.swift
   0.8%  7.44Ki   0.8%  7.44Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushHttpClient.swift
   0.8%  7.41Ki   0.8%  7.41Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskMetadata.swift
   0.8%  7.39Ki   0.8%  7.39Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/URLComponents.swift
   0.7%  6.97Ki   0.7%  6.97Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/ModalViewManager.swift
   0.7%  6.86Ki   0.7%  6.86Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Config/MessagingPushConfigBuilder.swift
   0.7%  6.84Ki   0.7%  6.84Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Store/PushHistory.swift
   0.7%  6.60Ki   0.7%  6.60Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/autogenerated/AutoMockable.generated.swift
   0.7%  6.39Ki   0.7%  6.39Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Gist.swift
   0.6%  6.21Ki   0.6%  6.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/KeyValueStorage.swift
   0.6%  5.79Ki   0.6%  5.79Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/autogenerated/AutoDependencyInjection.generated.swift
   0.6%  5.70Ki   0.6%  5.70Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/TrackEventMigrationType.swift
   0.6%  5.64Ki   0.6%  5.64Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTask.swift
   0.6%  5.63Ki   0.6%  5.63Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/SwiftUIInline.swift
   0.6%  5.50Ki   0.6%  5.50Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/autogenerated/AutoDependencyInjection.generated.swift
   0.5%  5.16Ki   0.5%  5.16Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Response/ErrorMessageResponse.swift
   0.5%  5.07Ki   0.5%  5.07Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Config/SDKConfigBuilder.swift
   0.5%  5.07Ki   0.5%  5.07Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageAction.swift
   0.5%  5.06Ki   0.5%  5.06Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/GistQueueNetwork.swift
   0.5%  5.03Ki   0.5%  5.03Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/Models/Message.swift
   0.5%  4.57Ki   0.5%  4.57Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/DataPipelinePublishedEvents.swift
   0.5%  4.45Ki   0.5%  4.45Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/DeviceContexualAttributes.swift
   0.5%  4.44Ki   0.5%  4.44Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/MetricRequest.swift
   0.5%  4.43Ki   0.5%  4.43Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventBus.swift
   0.4%  4.21Ki   0.4%  4.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/FileStorage.swift
   0.4%  4.21Ki   0.4%  4.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/iOSPushEventListener.swift
   0.4%  4.08Ki   0.4%  4.08Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/GistDelegate.swift
   0.4%  3.86Ki   0.4%  3.86Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/MessagingPush.swift
   0.4%  3.79Ki   0.4%  3.79Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWebConfiguration.swift
   0.4%  3.70Ki   0.4%  3.70Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestRunner.swift
   0.4%  3.61Ki   0.4%  3.61Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Module/ModuleTopLevelObject.swift
   0.4%  3.59Ki   0.4%  3.59Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Views/GistModalViewController.swift
   0.4%  3.46Ki   0.4%  3.46Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/ModalMessageManager.swift
   0.4%  3.45Ki   0.4%  3.45Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Config/MessagingInAppConfigBuilder.swift
   0.3%  3.37Ki   0.3%  3.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/StringExtensions.swift
   0.3%  3.32Ki   0.3%  3.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SystemLogger.swift
   0.3%  3.32Ki   0.3%  3.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Atomic.swift
   0.3%  3.25Ki   0.3%  3.25Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/MessagingPush+RichPush.swift
   0.3%  3.10Ki   0.3%  3.10Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/StringAnyEncodable.swift
   0.3%  3.06Ki   0.3%  3.06Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/DIManager.swift
   0.3%  3.02Ki   0.3%  3.02Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineEventHandler.swift
   0.3%  2.98Ki   0.3%  2.98Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/Context.swift
   0.3%  2.96Ki   0.3%  2.96Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/QueueManager.swift
   0.3%  2.91Ki   0.3%  2.91Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/BaseNetwork.swift
   0.3%  2.88Ki   0.3%  2.88Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/DeletePushNotificationQueueTaskData.swift
   0.3%  2.84Ki   0.3%  2.84Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeviceInfo.swift
   0.3%  2.84Ki   0.3%  2.84Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/IdentifyProfileQueueTaskData.swift
   0.3%  2.84Ki   0.3%  2.84Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/TrackEventQueueTaskData.swift
   0.3%  2.65Ki   0.3%  2.65Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestParams.swift
   0.3%  2.62Ki   0.3%  2.62Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/Integration/CioAppDelegateAPN.swift
   0.3%  2.59Ki   0.3%  2.59Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/ManualPushHandling+UserNotifications.swift
   0.3%  2.58Ki   0.3%  2.58Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/RegisterPushNotificationQueueTaskData.swift
   0.3%  2.55Ki   0.3%  2.55Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestError.swift
   0.3%  2.54Ki   0.3%  2.54Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Util/DeviceAttributesProvider.swift
   0.2%  2.37Ki   0.2%  2.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Subscription.swift
   0.2%  2.34Ki   0.2%  2.34Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushRequestHandler.swift
   0.2%  2.29Ki   0.2%  2.29Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPushAPN.swift
   0.2%  2.20Ki   0.2%  2.20Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/UserNotificationsFramework/UserNotificationsFrameworkAdapter.swift
   0.2%  2.09Ki   0.2%  2.09Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskRunResults.swift
   0.2%  2.07Ki   0.2%  2.07Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/MessagingInAppImplementation.swift
   0.2%  1.98Ki   0.2%  1.98Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/MessagingPushImplementation.swift
   0.2%  1.96Ki   0.2%  1.96Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/autogenerated/AutoDependencyInjection.generated.swift
   0.2%  1.95Ki   0.2%  1.95Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/LockManager.swift
   0.2%  1.89Ki   0.2%  1.89Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/ScreenFilterPlugin.swift
   0.2%  1.75Ki   0.2%  1.75Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushDeliveryTracker.swift
   0.2%  1.67Ki   0.2%  1.67Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPush+APN.swift
   0.2%  1.65Ki   0.2%  1.65Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/InlineMessageManager.swift
   0.2%  1.62Ki   0.2%  1.62Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DateExtensions.swift
   0.2%  1.59Ki   0.2%  1.59Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Synchronized.swift
   0.2%  1.52Ki   0.2%  1.52Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Models/UserQueueResponse.swift
   0.2%  1.49Ki   0.2%  1.49Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/PushMetric.swift
   0.2%  1.48Ki   0.2%  1.48Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SdkClient.swift
   0.2%  1.46Ki   0.2%  1.46Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Views/GistView.swift
   0.1%  1.46Ki   0.1%  1.46Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/MessagingInApp.swift
   0.1%  1.42Ki   0.1%  1.42Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/CIOApiEndpoint.swift
   0.1%  1.37Ki   0.1%  1.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Extensions/GistExtensions.swift
   0.1%  1.37Ki   0.1%  1.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/PushClickHandler.swift
   0.1%  1.36Ki   0.1%  1.36Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/UIColor+Hex.swift
   0.1%  1.34Ki   0.1%  1.34Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/SdkConfig.swift
   0.1%  1.34Ki   0.1%  1.34Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushRequest.swift
   0.1%  1.32Ki   0.1%  1.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/InAppMetric.swift
   0.1%  1.30Ki   0.1%  1.30Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Mocks.swift
   0.1%  1.24Ki   0.1%  1.24Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/UIKitWrapper.swift
   0.1%  1.24Ki   0.1%  1.24Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/ThreadUtil.swift
   0.1%  1.22Ki   0.1%  1.22Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeepLinkUtil.swift
   0.1%  1.22Ki   0.1%  1.22Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DictionaryExtension.swift
   0.1%  1.21Ki   0.1%  1.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/GlobalDataStore.swift
   0.1%  1.19Ki   0.1%  1.19Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Type/ScreenView.swift
   0.1%  1.18Ki   0.1%  1.18Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Config/DataPipelineConfigOptions.swift
   0.1%  1.16Ki   0.1%  1.16Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO.swift
   0.1%  1.12Ki   0.1%  1.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DeviceExtension.swift
   0.1%  1.12Ki   0.1%  1.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Type/Region.swift
   0.1%  1.07Ki   0.1%  1.07Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SdkInitializationLogger.swift
   0.1%  1.02Ki   0.1%  1.02Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/DIGraphShared.swift
   0.1%    1024   0.1%    1024    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/AnyEncodable.swift
   0.1%     980   0.1%     980    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Type/InAppMessage.swift
   0.1%     968   0.1%     968    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/KeyValueStorageKey.swift
   0.1%     896   0.1%     896    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Utilities/HTTPMethod.swift
   0.1%     880   0.1%     880    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskType.swift
   0.1%     880   0.1%     880    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/UserAgentUtil.swift
   0.1%     872   0.1%     872    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/EmptyRequestBody.swift
   0.1%     868   0.1%     868    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPushAPN+PushConfigs.swift
   0.1%     832   0.1%     832    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO+Events.swift
   0.1%     820   0.1%     820    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/ArrayExtensions.swift
   0.1%     792   0.1%     792    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/Utilities/GistNetworkRequest.swift
   0.1%     768   0.1%     768    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/Logger.swift
   0.1%     752   0.1%     752    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/Environment.swift
   0.1%     652   0.1%     652    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Type/CustomerIOParsedPushPayload.swift
   0.1%     600   0.1%     600    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/DownloadFileType.swift
   0.1%     600   0.1%     600    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Config/MessagingPushConfigOptions.swift
   0.1%     576   0.1%     576    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/UIKitExtensions.swift
   0.1%     572   0.1%     572    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/QueueEndpoint.swift
   0.1%     532   0.1%     532    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/LogManager.swift
   0.1%     508   0.1%     508    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/Utilities/GistNetworkRequestError.swift
   0.1%     504   0.1%     504    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/ProfileStore.swift
   0.0%     496   0.0%     496    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueStatus.swift
   0.0%     496   0.0%     496    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Util/DataPipelinesLogger.swift
   0.0%     484   0.0%     484    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO+Segment.swift
   0.0%     480   0.0%     480    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/RingBuffer.swift
   0.0%     480   0.0%     480    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/Encodable.swift
   0.0%     468   0.0%     468    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/LogEndpoint.swift
   0.0%     468   0.0%     468    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Store.swift
   0.0%     416   0.0%     416    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Utilities/ElapsedTimer.swift
   0.0%     396   0.0%     396    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/StoreSubscriber.swift
   0.0%     380   0.0%     380    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Config/MessagingInAppConfigOptions.swift
   0.0%     236   0.0%     236    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Util/NotificationCenterWrapper.swift
   0.0%     228   0.0%     228    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/NetworkSettings.swift
   0.0%     204   0.0%     204    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Lock.swift
   0.0%     200   0.0%     200    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Extensions/LoggerExtensions.swift
   0.0%     196   0.0%     196    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeviceMetricsGrabber.swift
   0.0%     192   0.0%     192    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/AutomaticPushClickHandling.swift
   0.0%     164   0.0%     164    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/QueueInventoryMemoryStore.swift
   0.0%     144   0.0%     144    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Aliases.swift
   0.0%     128   0.0%     128    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Timer.swift
   0.0%     120   0.0%     120    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DataExtensions.swift
   0.0%     116   0.0%     116    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/CustomerIODestination.swift
   0.0%      84   0.0%      84    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageStore.swift
   0.0%      68   0.0%      68    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SingleScheduleTimer.swift
   0.0%      64   0.0%      64    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DateUtil.swift
   0.0%      52   0.0%      52    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Version.swift
   0.0%      48   0.0%      48    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWebProvider.swift
   0.0%      36   0.0%      36    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Time.swift
   0.0%      20   0.0%      20    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Deprecated/CustomerIO+Tracking.swift
   0.0%       8   0.0%       8    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/ErrorExtension.swift
 100.0%   973Ki 100.0%   973Ki    TOTAL
Filtering enabled (source_filter); omitted file = 2.01Mi, vm = 2.10Mi of entries

SDK binary size diff report vs. main branch
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
Filtering enabled (source_filter); omitted file = 2.01Mi, vm = 2.10Mi of entries

Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 76.92308% with 6 lines in your changes missing coverage. Please review.

Project coverage is 62.95%. Comparing base (6f11c7e) to head (e828707).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...gingInApp/Gist/Managers/InlineMessageManager.swift 72.72% 3 Missing ⚠️
...agingInApp/Gist/Managers/ModalMessageManager.swift 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #920      +/-   ##
==========================================
+ Coverage   61.04%   62.95%   +1.90%     
==========================================
  Files         165      165              
  Lines        7281     7304      +23     
==========================================
+ Hits         4445     4598     +153     
+ Misses       2836     2706     -130     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Shahroz16 Shahroz16 marked this pull request as ready for review May 20, 2025 20:14
@Shahroz16 Shahroz16 requested a review from a team as a code owner May 20, 2025 20:14
@Shahroz16 Shahroz16 self-assigned this May 20, 2025
@mahmoud-elmorabea
Copy link
Contributor

@Shahroz16 Can we please add steps to reproduce the bug we are fixing so we can help test the fix 😇

@Shahroz16
Copy link
Contributor Author

@Shahroz16 Can we please add steps to reproduce the bug we are fixing so we can help test the fix 😇

@mahmoud-elmorabea added 🙌

Copy link
Contributor

@mahmoud-elmorabea mahmoud-elmorabea left a comment

Choose a reason for hiding this comment

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

The changes look good but unfortunately, I am still unable to reproduce the issue on main even on a real device and triggering the message mentioned in PR description multiple times.

Can you please add a video or steps to reproduce to make sure that this branch fixes the issue?

@Shahroz16
Copy link
Contributor Author

@mahmoud-elmorabea added the video in description.

Copy link
Contributor

@mrehan27 mrehan27 left a comment

Choose a reason for hiding this comment

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

Tested on real device, seems like working well 👍🏻

@Ahmed-Ali
Copy link
Contributor

@claude review

@Ahmed-Ali Ahmed-Ali requested a review from Copilot May 26, 2025 23:28
Copy link

@Copilot 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 centralizes view removal handling via a new lifecycle delegate, moves dismissal logic into context-specific managers, and adds tests to ensure correct behavior.

  • Introduce GistViewLifecycleDelegate to notify managers when a GistView is removed.
  • Refactor GistView.removeFromSuperview() to remove direct dismissal and delegate action to InlineMessageManager or ModalMessageManager.
  • Enhance test coverage with lifecycle and delegate tests and improve ThreadUtilStub to track and reset thread calls.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/Shared/Stub/ThreadUtilStub.swift Added flags (runMainCalled, runBackgroundCalled) and a reset() method to support testing thread execution.
Tests/MessagingInApp/Gist/Views/GistViewLifecycleDelegateTests.swift New tests verifying that GistView notifies its lifecycle delegate when removed.
Tests/MessagingInApp/Gist/GistDelegateImplTests.swift Updated tests to inject ThreadUtilStub and confirm UI-thread dispatch in delegate.
Sources/MessagingInApp/Gist/Views/GistView.swift Added GistViewLifecycleDelegate protocol and delegate call in removeFromSuperview().
Sources/MessagingInApp/Gist/Managers/InlineMessageManager.swift Set lifecycleDelegate on the GistView and dismiss inline messages on removal.
Sources/MessagingInApp/Gist/Managers/ModalMessageManager.swift Implement GistViewLifecycleDelegate to skip auto-dismiss for modal messages.
Comments suppressed due to low confidence (1)

Tests/Shared/Stub/ThreadUtilStub.swift:17

  • Add a unit test to verify that ThreadUtilStub.runBackground(_:) correctly sets the runBackgroundCalled flag when the block is executed.
public func runBackground(_ block: @escaping () -> Void) {

Comment on lines 29 to +34
super.removeFromSuperview()
if let _ = message {
DIGraphShared.shared.gistProvider.dismissMessage()
}

// Notify lifecycle delegate that this view is being removed
// The delegate (InlineMessageManager or ModalMessageManager) can decide
// what action to take based on the context
lifecycleDelegate?.gistViewWillRemoveFromSuperview(self)
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider notifying the lifecycle delegate before calling super.removeFromSuperview() so the delegate can act while the view hierarchy is still intact.

Copilot uses AI. Check for mistakes.

@Ahmed-Ali Ahmed-Ali requested a review from Copilot May 27, 2025 14:32
Copy link

@Copilot 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 addresses multi screen views action handling issues by refactoring view dismissal logic and introducing a new lifecycle delegate protocol. The changes include:

  • Adding the GistViewLifecycleDelegate protocol and integrating it into GistView for managing view removal events.
  • Refactoring message dismissal logic to differentiate between modal and inline message managers.
  • Enhancing test coverage for Gist components covering lifecycle events and delegate interactions.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/Shared/Stub/ThreadUtilStub.swift Added public flags and a reset function for better thread execution testing.
Tests/MessagingInApp/Gist/Views/GistViewLifecycleDelegateTests.swift Introduced tests to validate the new lifecycle delegate behavior.
Tests/MessagingInApp/Gist/GistDelegateImplTests.swift Extended test coverage incorporating the updated event handling flow.
Sources/MessagingInApp/Gist/Views/GistView.swift Updated removeFromSuperview to notify the lifecycle delegate instead of calling dismissMessage directly.
Sources/MessagingInApp/Gist/Managers/ModalMessageManager.swift Configured lifecycle delegate handling for modal messages with no auto-dismissal.
Sources/MessagingInApp/Gist/Managers/InlineMessageManager.swift Ensured inline messages trigger dismissal via the lifecycle delegate when removed.
Comments suppressed due to low confidence (1)

Sources/MessagingInApp/Gist/Views/GistView.swift:28

  • Consider calling lifecycleDelegate?.gistViewWillRemoveFromSuperview(self) before calling super.removeFromSuperview() to better reflect the 'will remove' semantics of the protocol.
override public func removeFromSuperview() {

@Shahroz16 Shahroz16 merged commit 0426e06 into main May 27, 2025
17 checks passed
@Shahroz16 Shahroz16 deleted the mbl-1137 branch May 27, 2025 17:50
github-actions bot pushed a commit that referenced this pull request May 27, 2025
## [3.10.2](3.10.1...3.10.2) (2025-05-27)

### Bug Fixes

* multi screen views action handling ([#920](#920)) ([0426e06](0426e06))
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.

4 participants