Resolve conflict with new Context attribute: deviceId

Rename our context.deviceId to context.npDeviceId
This commit is contained in:
S1m 2024-01-16 20:37:15 +01:00
parent 5a97c8b7e7
commit d6c270c81c
2 changed files with 9 additions and 9 deletions

View File

@ -32,7 +32,7 @@ object Account {
.edit().putInt(PREF_ACCOUNT_TYPE, value.toInt())
.apply()
var Context.deviceId: String?
var Context.npDeviceId: String?
get() = this.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.getString(PREF_DEVICE_ID, null)
set(value) {
@ -81,7 +81,7 @@ object Account {
fun logout(context: Context) {
getAccount(context)?.logout(context)
context.deviceId = null
context.npDeviceId = null
}
fun Context.setTypeSSO() {

View File

@ -11,8 +11,8 @@ import okhttp3.Request
import okhttp3.sse.EventSource
import okhttp3.sse.EventSources
import org.unifiedpush.distributor.nextpush.account.Account.accountType
import org.unifiedpush.distributor.nextpush.account.Account.deviceId
import org.unifiedpush.distributor.nextpush.account.Account.getAccount
import org.unifiedpush.distributor.nextpush.account.Account.npDeviceId
import org.unifiedpush.distributor.nextpush.account.AccountType
import org.unifiedpush.distributor.nextpush.api.provider.* // ktlint-disable no-wildcard-imports
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider.Companion.mApiEndpoint
@ -41,7 +41,7 @@ class Api(context: Context) {
}
fun apiSync() {
context.deviceId?.let {
context.npDeviceId?.let {
syncDevice(it)
}
?: run {
@ -56,7 +56,7 @@ class Api(context: Context) {
?.subscribe(object : DisposableObserver<ApiResponse>() {
override fun onNext(response: ApiResponse) {
response.deviceId.let {
context.deviceId = it
context.npDeviceId = it
}
}
@ -67,7 +67,7 @@ class Api(context: Context) {
override fun onComplete() {
// Sync once it is registered
context.deviceId?.let {
context.npDeviceId?.let {
syncDevice(it)
}
Log.d(TAG, "mApi register: onComplete")
@ -102,7 +102,7 @@ class Api(context: Context) {
}
fun apiDeleteDevice(block: () -> Unit = {}) {
val deviceId = context.deviceId ?: return
val deviceId = context.npDeviceId ?: return
try {
withApiProvider { apiProvider, then ->
apiProvider.deleteDevice(deviceId)
@ -128,7 +128,7 @@ class Api(context: Context) {
then()
}
})
context.deviceId = null
context.npDeviceId = null
}
} catch (e: NoProviderException) {
e.printStackTrace()
@ -140,7 +140,7 @@ class Api(context: Context) {
block: (String?) -> Unit
) {
// The unity of connector token must already be checked here
val parameters = context.deviceId?.let {
val parameters = context.npDeviceId?.let {
mutableMapOf(
"deviceId" to it,
"appName" to appName