-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Archived Conversations ποΈ #4333
Changes from 3 commits
8eeca17
94f33c1
39305d7
46efdf4
d464d71
3d9f836
7285c0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import com.nextcloud.talk.models.domain.ConversationModel | |
import com.nextcloud.talk.models.json.capabilities.SpreedCapability | ||
import com.nextcloud.talk.models.json.generic.GenericOverall | ||
import com.nextcloud.talk.models.json.participants.TalkBan | ||
import com.nextcloud.talk.repositories.conversations.ConversationsRepository | ||
import com.nextcloud.talk.utils.ApiUtils | ||
import io.reactivex.Observer | ||
import io.reactivex.android.schedulers.AndroidSchedulers | ||
|
@@ -26,7 +27,8 @@ import io.reactivex.schedulers.Schedulers | |
import javax.inject.Inject | ||
|
||
class ConversationInfoViewModel @Inject constructor( | ||
private val chatNetworkDataSource: ChatNetworkDataSource | ||
private val chatNetworkDataSource: ChatNetworkDataSource, | ||
private val conversationsRepository: ConversationsRepository | ||
) : ViewModel() { | ||
|
||
object LifeCycleObserver : DefaultLifecycleObserver { | ||
|
@@ -200,6 +202,56 @@ class ConversationInfoViewModel @Inject constructor( | |
}) | ||
} | ||
|
||
fun archiveConversation(user: User, token: String) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing to implement for now (can be done in followup PR if you are interested), but just as a sidenote: It would be nice to have the archive/unarchive button also available in the conversations context menu. This would lead to the question how duplicated code can be avoided to call the repository. But as said, should be done later on and not in this PR. So for now i suggest to don't implement it in the context menu. |
||
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) | ||
val url = ApiUtils.getUrlForArchive(apiVersion, user.baseUrl, token) | ||
conversationsRepository.archiveConversation(user.getCredentials(), url) | ||
.subscribeOn(Schedulers.io()) | ||
?.observeOn(AndroidSchedulers.mainThread()) | ||
?.subscribe(object : Observer<GenericOverall> { | ||
override fun onSubscribe(p0: Disposable) { | ||
// unused | ||
} | ||
|
||
override fun onError(e: Throwable) { | ||
Log.d("Julius", "Error in archive $e") | ||
rapterjet2004 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
override fun onComplete() { | ||
// unused atm | ||
} | ||
|
||
override fun onNext(n: GenericOverall) { | ||
Log.d("Julius", "Archived successful") | ||
rapterjet2004 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}) | ||
} | ||
|
||
fun unarchiveConversation(user: User, token: String) { | ||
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) | ||
val url = ApiUtils.getUrlForArchive(apiVersion, user.baseUrl, token) | ||
conversationsRepository.unarchiveConversation(user.getCredentials(), url) | ||
.subscribeOn(Schedulers.io()) | ||
?.observeOn(AndroidSchedulers.mainThread()) | ||
?.subscribe(object : Observer<GenericOverall> { | ||
override fun onSubscribe(p0: Disposable) { | ||
// unused | ||
} | ||
|
||
override fun onError(e: Throwable) { | ||
Log.d("Julius", "Error in unarchive $e") | ||
rapterjet2004 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
override fun onComplete() { | ||
// unused atm | ||
} | ||
|
||
override fun onNext(n: GenericOverall) { | ||
Log.d("Julius", "unArchived successful") | ||
} | ||
}) | ||
} | ||
|
||
inner class GetRoomObserver : Observer<ConversationModel> { | ||
override fun onSubscribe(d: Disposable) { | ||
// unused atm | ||
|
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.
the databse version must be bumped and a database migration must be added to alter the affected table
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 was merged too fast. there should have been a 12.json file instead to modify 11.json
should be fixed with #4417