diff --git a/app/src/main/java/com/readrops/app/timelime/TimelineScreenModel.kt b/app/src/main/java/com/readrops/app/timelime/TimelineScreenModel.kt index 7290e271..5f1233ca 100644 --- a/app/src/main/java/com/readrops/app/timelime/TimelineScreenModel.kt +++ b/app/src/main/java/com/readrops/app/timelime/TimelineScreenModel.kt @@ -45,7 +45,7 @@ class TimelineScreenModel( private val database: Database, private val getFoldersWithFeeds: GetFoldersWithFeeds, private val preferences: Preferences, - context: Context, + private val context: Context, private val dispatcher: CoroutineDispatcher = Dispatchers.IO ) : TabScreenModel(database, context) { @@ -146,8 +146,8 @@ class TimelineScreenModel( private fun buildPager(empty: Boolean = false) { val query = ItemsQueryBuilder.buildItemsQuery( - filters.value, - currentAccount!!.config.useSeparateState + queryFilters = filters.value, + separateState = currentAccount!!.config.useSeparateState ) val pager = Pager( @@ -179,7 +179,7 @@ class TimelineScreenModel( } @Suppress("UNCHECKED_CAST") - fun refreshTimeline(context: Context) { + fun refreshTimeline() { buildPager(empty = true) screenModelScope.launch(dispatcher) { @@ -232,7 +232,7 @@ class TimelineScreenModel( _timelineState.update { it.copy( - syncError = error, + syncError = accountError?.genericMessage(error!!), isRefreshing = false, hideReadAllFAB = false ) @@ -449,7 +449,7 @@ data class TimelineState( val feedMax: Int = 0, val scrollToTop: Boolean = false, val localSyncErrors: ErrorResult? = null, - val syncError: Exception? = null, + val syncError: String? = null, val filters: QueryFilters = QueryFilters(), val filterFeedName: String = "", val filterFolderName: String = "", diff --git a/app/src/main/java/com/readrops/app/timelime/TimelineTab.kt b/app/src/main/java/com/readrops/app/timelime/TimelineTab.kt index fedaeb33..226e88fc 100644 --- a/app/src/main/java/com/readrops/app/timelime/TimelineTab.kt +++ b/app/src/main/java/com/readrops/app/timelime/TimelineTab.kt @@ -59,7 +59,6 @@ import cafe.adriel.voyager.navigator.tab.TabOptions import com.readrops.app.R import com.readrops.app.item.ItemScreen import com.readrops.app.timelime.drawer.TimelineDrawer -import com.readrops.app.util.ErrorMessage import com.readrops.app.util.components.CenteredProgressIndicator import com.readrops.app.util.components.Placeholder import com.readrops.app.util.components.RefreshScreen @@ -167,7 +166,7 @@ object TimelineTab : Tab { LaunchedEffect(state.syncError) { if (state.syncError != null) { - snackbarHostState.showSnackbar(ErrorMessage.get(state.syncError!!, context)) + snackbarHostState.showSnackbar(state.syncError!!) screenModel.resetSyncError() } } @@ -239,7 +238,7 @@ object TimelineTab : Tab { } IconButton( - onClick = { screenModel.refreshTimeline(context) } + onClick = { screenModel.refreshTimeline() } ) { Icon( painter = painterResource(id = R.drawable.ic_sync), @@ -297,7 +296,7 @@ object TimelineTab : Tab { else -> { PullToRefreshBox( isRefreshing = state.isRefreshing, - onRefresh = { screenModel.refreshTimeline(context) }, + onRefresh = { screenModel.refreshTimeline() }, ) { if (items.itemCount > 0) { MarkItemsRead( diff --git a/app/src/main/java/com/readrops/app/util/accounterror/AccountError.kt b/app/src/main/java/com/readrops/app/util/accounterror/AccountError.kt index 4e563e9c..8ac07b7c 100644 --- a/app/src/main/java/com/readrops/app/util/accounterror/AccountError.kt +++ b/app/src/main/java/com/readrops/app/util/accounterror/AccountError.kt @@ -25,7 +25,7 @@ abstract class AccountError(protected val context: Context) { open fun deleteFolderMessage(exception: Exception): String = genericMessage(exception) - protected fun genericMessage(exception: Exception) = when (exception) { + fun genericMessage(exception: Exception) = when (exception) { is HttpException -> httpMessage(exception) is UnknownHostException -> context.resources.getString(R.string.unreachable_url) is NoSuchFileException -> context.resources.getString(R.string.unable_open_file)