Skip to content

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

Merged
merged 7 commits into from
Dec 14, 2022
Merged

thread list loading #7766

merged 7 commits into from
Dec 14, 2022

Conversation

fedrunov
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

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

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@fedrunov fedrunov requested review from bmarty and ganfra December 12, 2022 09:26
@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

Generated by 🚫 dangerJS against ba71291

@ElementBot
Copy link

Fails
🚫

node failed.

Log

Error:  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

Generated by 🚫 dangerJS against e9869ca

@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

Generated by 🚫 dangerJS against e9869ca

Copy link
Member

@bmarty bmarty left a 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>>
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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 {
Copy link
Member

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

@ganfra ganfra added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Dec 13, 2022
@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against 7e8859e

import org.matrix.android.sdk.api.session.room.ResultBoundaries
import org.matrix.android.sdk.api.session.room.threads.model.ThreadSummary

data class ThreadLivePageResult (

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Unused import

}
})

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 "}"

@fedrunov fedrunov requested a review from ganfra December 14, 2022 10:58
@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

Generated by 🚫 dangerJS against c067213

@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

Generated by 🚫 dangerJS against fa68956

@ElementBot
Copy link

Warnings
⚠️

Please add a changelog. See instructions here

Generated by 🚫 dangerJS against f02dd08

Copy link
Member

@ganfra ganfra left a 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

@ElementBot
Copy link

Warnings
⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against 0c3e238

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.4% 0.4% Coverage
0.0% 0.0% Duplication

@fedrunov fedrunov merged commit cf3abd6 into develop Dec 14, 2022
@fedrunov fedrunov deleted the feature/nfe/thread_list_loading branch December 14, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load the thread list using server-side sorting and pagination
4 participants