Use /sources/stats in the home #133
Reference in New Issue
Block a user
Delete Branch "davidoskky/ReaderForSelfoss-multiplatform:sources"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Types of changes
This is implements feature #131 and it will allow implementing #132
With this, public mode functions perfectly and also has source filtering.
@@ -56,3 +56,3 @@CoroutineScope(Dispatchers.Main).launch {val response = repository.getSources()val response = repository.getSourcesDetails()Why would the SourcesActivity use the "public" route, instead of the actual one ?
I just changed the names of the methods it's the same endpoint.
I changed the names to make them more descriptive: getSourcesStats for /sources/stats and getSourcesDetails for /sources/details
@@ -62,3 +62,3 @@}if (itm.error.isNotBlank()) {if (itm.error.isNullOrBlank()) {This does not make sens. If the error is null or blank, the error text should not be displayed.
@@ -68,0 +74,4 @@var params: SourceParams?) {constructor(sourceDetail: SourceDetail) : this(This should be an extension function
fun SourceDetail.toSource(): SourceIgnore this.
@@ -68,0 +85,4 @@params = sourceDetail.params)constructor(sourceStat: SourceStats) : this(This should be an extension function
fun SourceStats.toSource(): SourceIgnore this.
@@ -64,4 +64,3 @@}@Serializabledata class Source(Sourcedata class should be changed to an interfaceSourceDetailandSourceStatsshould implement it.@@ -180,23 +181,49 @@ class Repository(}}suspend fun getSources(): ArrayList<SelfossModel.Source> {There should be two methods:
I'm not sure about this. Doing so is fine only as long as we don't care about the unread count. That is only available in the stats.
If we don't plan on displaying the unread count, this is fine; otherwise the amount of unread articles should be available in the home activity.
Unread count was complicated code-wise. We have no idea if the feature was used/useful, so for now, let's not add it back.
I did find the tags unread count useful. I will not add this here; we can always implement it later.
@@ -45,3 +45,3 @@val badgeStarred = _badgeStarred.asStateFlow()private var fetchedSources = falseprivate var sources = ArrayList<SelfossModel.Source>()This shouldn't be changed/added.
@@ -0,0 +1 @@ALTER TABLE SOURCE ADD COLUMN `unread` INTEGER;As
unreadis only in the public mode, let's not change this.@@ -5,3 +4,1 @@`spout` TEXT NOT NULL,`error` TEXT NOT NULL,`icon` TEXT NOT NULL,`unread` INTEGER,As
unreadis only in the public mode, let's not change this.c127271edeto0c942f7a80This should address all the comments. Finally the tests have been useful to spot some logical errors I had introduced.
@@ -66,0 +71,4 @@var error: String?var icon: String?fun checkSameSource(source: Source): Boolean {I don't understand why this is needed ?
@@ -66,0 +75,4 @@return this.id != source.id}fun update(source: Source) {This should be an "abstract" method.
@@ -66,0 +82,4 @@this.update(source)}}fun update(source: SourceStats)This should not be here.
@@ -66,0 +84,4 @@}fun update(source: SourceStats)fun update(source: SourceDetail)This should not be here.
@@ -66,0 +88,4 @@fun toEntity(): SOURCEoperator fun component1(): Int { return id }What are these two methods ?
@@ -70,0 +108,4 @@this.unread = source.unread}override fun update(source: SourceDetail) {SourceStatsclass should not containSourceDetailupdate.@@ -77,0 +142,4 @@override var icon: String?,var params: SourceParams?) : Source {override fun update(source: SourceStats) {SourceDetailshould not containSourceStatsupdate@@ -8,0 +4,4 @@`tags` TEXT,`spout` TEXT,`error` TEXT,`icon` TEXT,Why was everything changed to nullable ?
@@ -188,3 +186,1 @@if (apiSources.success && apiSources.data != null && isDatabaseEnabled) {resetDBSourcesWithData(apiSources.data)if (!appSettingsService.isUpdateSourcesEnabled()) {return if (isDatabaseEnabled) {All this is overly complicated.
@@ -191,1 +211,4 @@val apiSources = api.sourcesStats()if (apiSources.success && apiSources.data != null) {fetchedSources = truesources = updateSources(apiSources.data) as ArrayList<SelfossModel.Source>We only update the DB from
getSourcesDetailsAfter some cleaning, things should be ok.
It was definitely overcomplicated, I removed most of that update logic. I meant to merge the two information sources to get a complete view, but we're not really using the information anyway so it's not really needed.
23c44487cato2ae32794be