Explicitly failing for non selfoss rss files.
This commit is contained in:
parent
3b0028164b
commit
f42ae97326
@ -11,6 +11,7 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
@ -48,7 +49,8 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
TrackHelper.track().download().identifier(DownloadTracker.Extra.ApkChecksum(applicationContext))
|
TrackHelper.track().download()
|
||||||
|
.identifier(DownloadTracker.Extra.ApkChecksum(applicationContext))
|
||||||
.with(tracker)
|
.with(tracker)
|
||||||
TrackHelper.track().screen("/login").with(tracker)
|
TrackHelper.track().screen("/login").with(tracker)
|
||||||
|
|
||||||
@ -64,7 +66,30 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
|||||||
handleBaseUrlFail()
|
handleBaseUrlFail()
|
||||||
|
|
||||||
if (appSettingsService.getBaseUrl().isNotEmpty()) {
|
if (appSettingsService.getBaseUrl().isNotEmpty()) {
|
||||||
|
showProgress(true)
|
||||||
|
// This should be reverted when "old" users connected with a non-selfoss rss
|
||||||
|
// are handled. Revert to "simple" way.
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
val (errorFetching, displaySelfossOnly) = repository.shouldBeSelfossInstance()
|
||||||
|
if (!errorFetching && !displaySelfossOnly) {
|
||||||
goToMain()
|
goToMain()
|
||||||
|
} else {
|
||||||
|
showProgress(false)
|
||||||
|
if (displaySelfossOnly) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
R.string.application_selfoss_only,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
repository.logout()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
repository.logout()
|
||||||
|
showProgress(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleActions()
|
handleActions()
|
||||||
@ -191,19 +216,29 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
|||||||
|
|
||||||
repository.refreshLoginInformation(url, login, password)
|
repository.refreshLoginInformation(url, login, password)
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
val result = repository.login()
|
val result = repository.login()
|
||||||
if (result) {
|
if (result) {
|
||||||
|
val (errorFetching, displaySelfossOnly) = repository.shouldBeSelfossInstance()
|
||||||
|
if (!errorFetching && !displaySelfossOnly) {
|
||||||
goToMain()
|
goToMain()
|
||||||
} else {
|
} else {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
if (displaySelfossOnly) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
R.string.application_selfoss_only,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
preferenceError()
|
preferenceError()
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
preferenceError()
|
||||||
}
|
}
|
||||||
showProgress(false)
|
showProgress(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showProgress(show: Boolean) {
|
private fun showProgress(show: Boolean) {
|
||||||
val shortAnimTime = resources.getInteger(android.R.integer.config_shortAnimTime)
|
val shortAnimTime = resources.getInteger(android.R.integer.config_shortAnimTime)
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -6,4 +6,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">发生崩溃。请将细节发送给开发人员。</string>
|
<string name="crash_toast_text">发生崩溃。请将细节发送给开发人员。</string>
|
||||||
<string name="pref_switch_disable_acra">"禁用自动错误报告 "</string>
|
<string name="pref_switch_disable_acra">"禁用自动错误报告 "</string>
|
||||||
<string name="menu_home_filter">筛选器</string>
|
<string name="menu_home_filter">筛选器</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -129,4 +129,5 @@
|
|||||||
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
<string name="crash_toast_text">A crash occured. Sending the details to the developper.</string>
|
||||||
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
<string name="pref_switch_disable_acra">"Disable automatic bug reporting. "</string>
|
||||||
<string name="menu_home_filter">Filters</string>
|
<string name="menu_home_filter">Filters</string>
|
||||||
|
<string name="application_selfoss_only">This app only works with a Selfoss instance, and no other RSS feed.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -8,13 +8,19 @@ import bou.amine.apps.readerforselfossv2.rest.SelfossApi
|
|||||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||||
import bou.amine.apps.readerforselfossv2.utils.*
|
import bou.amine.apps.readerforselfossv2.utils.*
|
||||||
import io.github.aakira.napier.Napier
|
import io.github.aakira.napier.Napier
|
||||||
|
import io.ktor.client.call.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class Repository(private val api: SelfossApi, private val appSettingsService: AppSettingsService, val isConnectionAvailable: MutableStateFlow<Boolean>, private val db: ReaderForSelfossDB) {
|
class Repository(
|
||||||
|
private val api: SelfossApi,
|
||||||
|
private val appSettingsService: AppSettingsService,
|
||||||
|
val isConnectionAvailable: MutableStateFlow<Boolean>,
|
||||||
|
private val db: ReaderForSelfossDB
|
||||||
|
) {
|
||||||
|
|
||||||
var items = ArrayList<SelfossModel.Item>()
|
var items = ArrayList<SelfossModel.Item>()
|
||||||
var connectionMonitored = false
|
var connectionMonitored = false
|
||||||
@ -146,7 +152,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getTags(): List<SelfossModel.Tag> {
|
suspend fun getTags(): List<SelfossModel.Tag> {
|
||||||
val isDatabaseEnabled = appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
val isDatabaseEnabled =
|
||||||
|
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
||||||
return if (isNetworkAvailable() && !fetchedTags) {
|
return if (isNetworkAvailable() && !fetchedTags) {
|
||||||
val apiTags = api.tags()
|
val apiTags = api.tags()
|
||||||
if (apiTags.success && apiTags.data != null && isDatabaseEnabled) {
|
if (apiTags.success && apiTags.data != null && isDatabaseEnabled) {
|
||||||
@ -178,7 +185,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getSources(): ArrayList<SelfossModel.Source> {
|
suspend fun getSources(): ArrayList<SelfossModel.Source> {
|
||||||
val isDatabaseEnabled = appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
val isDatabaseEnabled =
|
||||||
|
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
|
||||||
return if (isNetworkAvailable() && !fetchedSources) {
|
return if (isNetworkAvailable() && !fetchedSources) {
|
||||||
val apiSources = api.sources()
|
val apiSources = api.sources()
|
||||||
if (apiSources.success && apiSources.data != null && isDatabaseEnabled) {
|
if (apiSources.success && apiSources.data != null && isDatabaseEnabled) {
|
||||||
@ -380,18 +388,35 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun shouldBeSelfossInstance(): Pair<Boolean, Boolean> {
|
||||||
|
var fetchFailed = true
|
||||||
|
var showSelfossOnlyModal = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
try {
|
||||||
|
// Trying to fetch one item, and check someone is trying to use the app with
|
||||||
|
// a random rss feed, that would throw a NoTransformationFoundException
|
||||||
|
fetchFailed = !api.getItemsWithoutCatch().success
|
||||||
|
} catch (e: NoTransformationFoundException) {
|
||||||
|
showSelfossOnlyModal = true
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Napier.e(e.stackTraceToString(), tag = "RepositoryImpl.shouldBeSelfossInstance")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Pair(fetchFailed, showSelfossOnlyModal)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun logout() {
|
suspend fun logout() {
|
||||||
if (isNetworkAvailable()) {
|
if (isNetworkAvailable()) {
|
||||||
try {
|
try {
|
||||||
val response = api.logout()
|
val response = api.logout()
|
||||||
if (response.isSuccess) {
|
if (!response.isSuccess) {
|
||||||
Napier.e("Couldn't logout.", tag = "RepositoryImpl.logout")
|
Napier.e("Couldn't logout.", tag = "RepositoryImpl.logout")
|
||||||
}
|
}
|
||||||
} catch (cause: Throwable) {
|
} catch (cause: Throwable) {
|
||||||
Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.logout")
|
Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.logout")
|
||||||
} finally {
|
|
||||||
appSettingsService.clearAll()
|
|
||||||
}
|
}
|
||||||
|
appSettingsService.clearAll()
|
||||||
} else {
|
} else {
|
||||||
appSettingsService.clearAll()
|
appSettingsService.clearAll()
|
||||||
}
|
}
|
||||||
@ -456,11 +481,29 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
|
|
||||||
private fun getDBItems(): List<ITEM> = db.itemsQueries.items().executeAsList()
|
private fun getDBItems(): List<ITEM> = db.itemsQueries.items().executeAsList()
|
||||||
|
|
||||||
private fun insertDBAction(articleid: String, read: Boolean = false, unread: Boolean = false, starred: Boolean = false, unstarred: Boolean = false) =
|
private fun insertDBAction(
|
||||||
|
articleid: String,
|
||||||
|
read: Boolean = false,
|
||||||
|
unread: Boolean = false,
|
||||||
|
starred: Boolean = false,
|
||||||
|
unstarred: Boolean = false
|
||||||
|
) =
|
||||||
db.actionsQueries.insertAction(articleid, read, unread, starred, unstarred)
|
db.actionsQueries.insertAction(articleid, read, unread, starred, unstarred)
|
||||||
|
|
||||||
private fun updateDBItem(item: SelfossModel.Item) =
|
private fun updateDBItem(item: SelfossModel.Item) =
|
||||||
db.itemsQueries.updateItem(item.datetime, item.title.getHtmlDecoded(), item.content, item.unread, item.starred, item.thumbnail, item.icon, item.link, item.sourcetitle, item.tags.joinToString(","), item.id.toString())
|
db.itemsQueries.updateItem(
|
||||||
|
item.datetime,
|
||||||
|
item.title.getHtmlDecoded(),
|
||||||
|
item.content,
|
||||||
|
item.unread,
|
||||||
|
item.starred,
|
||||||
|
item.thumbnail,
|
||||||
|
item.icon,
|
||||||
|
item.link,
|
||||||
|
item.sourcetitle,
|
||||||
|
item.tags.joinToString(","),
|
||||||
|
item.id.toString()
|
||||||
|
)
|
||||||
|
|
||||||
suspend fun tryToCacheItemsAndGetNewOnes(): List<SelfossModel.Item> {
|
suspend fun tryToCacheItemsAndGetNewOnes(): List<SelfossModel.Item> {
|
||||||
try {
|
try {
|
||||||
|
@ -47,7 +47,7 @@ class SelfossApi(private val appSettingsService: AppSettingsService) {
|
|||||||
}
|
}
|
||||||
install(HttpCookies)
|
install(HttpCookies)
|
||||||
install(HttpRequestRetry) {
|
install(HttpRequestRetry) {
|
||||||
maxRetries = 2
|
maxRetries = 1
|
||||||
retryIf { _, response ->
|
retryIf { _, response ->
|
||||||
response.status == HttpStatusCode.Forbidden && shouldHavePostLogin() && hasLoginInfo()
|
response.status == HttpStatusCode.Forbidden && shouldHavePostLogin() && hasLoginInfo()
|
||||||
}
|
}
|
||||||
@ -134,6 +134,16 @@ class SelfossApi(private val appSettingsService: AppSettingsService) {
|
|||||||
parameter("offset", offset)
|
parameter("offset", offset)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
suspend fun getItemsWithoutCatch(): StatusAndData<List<SelfossModel.Item>> =
|
||||||
|
bodyOrFailure(client.get(url("/items")) {
|
||||||
|
if (!shouldHavePostLogin()) {
|
||||||
|
parameter("username", appSettingsService.getUserName())
|
||||||
|
parameter("password", appSettingsService.getPassword())
|
||||||
|
}
|
||||||
|
parameter("type", "all")
|
||||||
|
parameter("items", 1)
|
||||||
|
})
|
||||||
|
|
||||||
suspend fun stats(): StatusAndData<SelfossModel.Stats> =
|
suspend fun stats(): StatusAndData<SelfossModel.Stats> =
|
||||||
bodyOrFailure(client.tryToGet(url("/stats")) {
|
bodyOrFailure(client.tryToGet(url("/stats")) {
|
||||||
if (!shouldHavePostLogin()) {
|
if (!shouldHavePostLogin()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user