mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-31 19:34:52 +01:00
Permalink: move method implementation from service to factory
This commit is contained in:
parent
744523b200
commit
afb49430be
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.permalinks
|
|||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultPermalinkService @Inject constructor(
|
internal class DefaultPermalinkService @Inject constructor(
|
||||||
@ -42,9 +41,6 @@ internal class DefaultPermalinkService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getLinkedId(url: String): String? {
|
override fun getLinkedId(url: String): String? {
|
||||||
return url
|
return permalinkFactory.getLinkedId(url)
|
||||||
.takeIf { it.startsWith(MATRIX_TO_URL_BASE) }
|
|
||||||
?.substring(MATRIX_TO_URL_BASE.length)
|
|
||||||
?.substringBeforeLast("?")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,10 @@ internal class PermalinkFactory @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getLinkedId(url: String): String? {
|
fun getLinkedId(url: String): String? {
|
||||||
val isSupported = url.startsWith(MATRIX_TO_URL_BASE)
|
return url
|
||||||
|
.takeIf { it.startsWith(MATRIX_TO_URL_BASE) }
|
||||||
return if (isSupported) {
|
?.substring(MATRIX_TO_URL_BASE.length)
|
||||||
url.substring(MATRIX_TO_URL_BASE.length)
|
?.substringBeforeLast("?")
|
||||||
} else null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user