Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.onesignal.user.internal

import com.onesignal.common.IDManager
import com.onesignal.common.OneSignalUtils
import com.onesignal.common.TimeUtils
import com.onesignal.common.events.EventProducer
import com.onesignal.common.modeling.ISingletonModelStoreChangeHandler
import com.onesignal.common.modeling.ModelChangedArgs
import com.onesignal.core.internal.application.IApplicationLifecycleHandler
import com.onesignal.core.internal.application.IApplicationService
import com.onesignal.core.internal.language.ILanguageContext
import com.onesignal.debug.LogLevel
import com.onesignal.debug.internal.logging.Logging
Expand All @@ -26,7 +29,8 @@ internal open class UserManager(
private val _identityModelStore: IdentityModelStore,
private val _propertiesModelStore: PropertiesModelStore,
private val _languageContext: ILanguageContext,
) : IUserManager, ISingletonModelStoreChangeHandler<IdentityModel> {
private val _applicationService: IApplicationService,
) : IUserManager, IApplicationLifecycleHandler, ISingletonModelStoreChangeHandler<IdentityModel> {
override val onesignalId: String
get() = if (IDManager.isLocalId(_identityModel.onesignalId)) "" else _identityModel.onesignalId

Expand Down Expand Up @@ -55,6 +59,7 @@ internal open class UserManager(
}

init {
_applicationService.addApplicationLifecycleHandler(this)
_identityModelStore.subscribe(this)
}

Expand Down Expand Up @@ -260,4 +265,11 @@ internal open class UserManager(
}
}
}

override fun onFocus(firedOnSubscribe: Boolean) {
// Detect any user properties updates that changed
_propertiesModel.timezone = TimeUtils.getTimeZoneId()
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to pass TimeUtils into this class? so that you can mock it?

Copy link
Contributor

Choose a reason for hiding this comment

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

also please make sure to write tests

}

override fun onUnfocused() { }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.onesignal.user.internal.operations.impl.executors

import com.onesignal.common.NetworkUtils
import com.onesignal.common.TimeUtils
import com.onesignal.common.exceptions.BackendException
import com.onesignal.common.modeling.ModelChangeTags
import com.onesignal.core.internal.config.ConfigModelStore
Expand Down Expand Up @@ -89,9 +90,8 @@ internal class RefreshUserOperationExecutor(
}
}

if (response.properties.timezoneId != null) {
propertiesModel.timezone = response.properties.timezoneId
}
// No longer hydrate timezone from remote, set locally
Copy link
Contributor

Choose a reason for hiding this comment

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

same with this.

propertiesModel.timezone = TimeUtils.getTimeZoneId()

val subscriptionModels = mutableListOf<SubscriptionModel>()
for (subscription in response.subscriptions) {
Expand Down
Loading