Use /sources/stats in the home #133
No reviewers
Labels
No Label
Difficulty - Beginner friendly
Difficulty = Easy
Difficulty = Hard
Difficulty = Medium
Priority = CRITICAL
Priority = High
Priority = Low
Priority = Normal
Priority = Some day
Status - Fixed somewhere else
Status - No details provided
Status = Can't fix
Status = Duplicate
Status = Help wanted
Status = Invalid
Status = Need more details
Status = Taken
Status = Wontfix
Type - Selfoss works like this
Type = Bug
Type = Chore
Type = Enhancement
Type = Feature
Type = Question
Type = SELFOSS API ISSUE
Type = Tools
Type = UX/Design
Up For Grabs
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Louvorg/ReaderForSelfoss-multiplatform#133
Loading…
Reference in New Issue
Block a user
No description provided.
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(): Source
Ignore this.
@ -68,0 +85,4 @@
params = sourceDetail.params
)
constructor(sourceStat: SourceStats) : this(
This should be an extension function
fun SourceStats.toSource(): Source
Ignore this.
@ -64,4 +64,3 @@
}
@Serializable
data class Source(
Source
data class should be changed to an interfaceSourceDetail
andSourceStats
should 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 = false
private var sources = ArrayList<SelfossModel.Source>()
This shouldn't be changed/added.
@ -0,0 +1 @@
ALTER TABLE SOURCE ADD COLUMN `unread` INTEGER;
As
unread
is 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
unread
is only in the public mode, let's not change this.c127271ede
to0c942f7a80
This 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(): SOURCE
operator fun component1(): Int { return id }
What are these two methods ?
@ -70,0 +108,4 @@
this.unread = source.unread
}
override fun update(source: SourceDetail) {
SourceStats
class should not containSourceDetail
update.@ -77,0 +142,4 @@
override var icon: String?,
var params: SourceParams?
) : Source {
override fun update(source: SourceStats) {
SourceDetail
should not containSourceStats
update@ -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 = true
sources = updateSources(apiSources.data) as ArrayList<SelfossModel.Source>
We only update the DB from
getSourcesDetails
After 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.
23c44487ca
to2ae32794be