-
Notifications
You must be signed in to change notification settings - Fork 800
thread list loading #7766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
thread list loading #7766
Conversation
LogError: Error: Could not find the Dangerfile at ./tools/danger/dangerfile-lint.js - does a file exist at danger/dangerfile-lint.js in ./tools?.
at /usr/src/danger/distribution/platforms/GitHub.js:166:27
at step (/usr/src/danger/distribution/platforms/GitHub.js:44:23)
at Object.next (/usr/src/danger/distribution/platforms/GitHub.js:25:53)
at fulfilled (/usr/src/danger/distribution/platforms/GitHub.js:16:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
danger-results://tmp/danger-results-b1e80078.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, some remarks.
* Returns a [LiveData] list of all the [ThreadSummary] that exists at the room level. | ||
*/ | ||
fun getAllThreadSummariesLive(): LiveData<List<ThreadSummary>> | ||
suspend fun getPagedThreadsList(coroutineScope: CoroutineScope, userParticipating: Boolean): LiveData<PagedList<ThreadSummary>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange to pass a CoroutineScope here. Maybe document the function to add details about the parameters usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is strange is to return a livedata from a suspendable method
@@ -40,5 +40,8 @@ internal open class ThreadSummaryEntity( | |||
@LinkingObjects("threadSummaries") | |||
val room: RealmResults<RoomEntity>? = null | |||
|
|||
@LinkingObjects("threadSummaries") | |||
val page: RealmResults<ThreadListPageEntity>? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this addition need to be part of the migration? I do not see it in MigrateSessionTo046
. Anyway if this is required, a test will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LinkingObjects are dynamically calculated and so you can't migrate them. I've tested migration by updating app build and it was working ok
threadSummaryMapper.map(it) | ||
} | ||
override suspend fun getPagedThreadsList(coroutineScope: CoroutineScope, userParticipating: Boolean): LiveData<PagedList<ThreadSummary>> { | ||
return DefaultGetPagedThreadListTask(monarchy, threadSummaryMapper, fetchThreadSummariesTask).execute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should inject the task GetPagedThreadListTask
in the constructor instead of creating a Default instance here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a thing i'd like to discuss. This task is basically a single-use cache, so we need to ensure that if the same task is called again, e.g. when filters are changed, it won't use anything from the previous run. If I'd inject the task it will require to do some cleanup on every execute and could cause problems if anything is not cleared, while running it from the scratch ensure that no previous data remain. Do you think it will be better to inject and do a cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Task shouldn't keep data, it's supposed to be a one/off operation
it.setBoundaryCallback(object : PagedList.BoundaryCallback<ThreadSummary>() { | ||
override fun onItemAtEndLoaded(itemAtEnd: ThreadSummary) { | ||
boundaries.postValue(boundaries.value?.copy(endLoaded = true)) | ||
coroutineScope?.launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have some inner coroutineScope from SDK for use cases like that
import org.matrix.android.sdk.api.session.room.ResultBoundaries | ||
import org.matrix.android.sdk.api.session.room.threads.model.ThreadSummary | ||
|
||
data class ThreadLivePageResult ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 🚫 Unexpected spacing before "("
@@ -17,7 +17,12 @@ | |||
package org.matrix.android.sdk.api.session.room.threads | |||
|
|||
import androidx.lifecycle.LiveData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 🚫 Unused import
@@ -17,7 +17,12 @@ | |||
package org.matrix.android.sdk.api.session.room.threads | |||
|
|||
import androidx.lifecycle.LiveData | |||
import androidx.paging.PagedList | |||
import kotlinx.coroutines.CoroutineScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 🚫 Unused import
@@ -17,7 +17,12 @@ | |||
package org.matrix.android.sdk.api.session.room.threads | |||
|
|||
import androidx.lifecycle.LiveData | |||
import androidx.paging.PagedList | |||
import kotlinx.coroutines.CoroutineScope | |||
import org.matrix.android.sdk.api.session.room.ResultBoundaries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 🚫 Unused import
} | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 🚫 Unexpected blank line(s) before "}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changelog and fix the warnings
SonarCloud Quality Gate failed. |
Type of change
Content
Since we have Threads API we should use it to fetch threads list instead of parsing messages locally
Motivation and context
closes #5819
Screenshots / GIFs
Tests
Tested devices
Checklist