|
|
|
@ -11,7 +11,6 @@ import com.keylesspalace.tusky.db.AppDatabase |
|
|
|
|
import com.keylesspalace.tusky.network.TimelineCases |
|
|
|
|
import com.keylesspalace.tusky.util.Listing |
|
|
|
|
import com.keylesspalace.tusky.util.NetworkState |
|
|
|
|
import io.reactivex.Single |
|
|
|
|
import io.reactivex.disposables.CompositeDisposable |
|
|
|
|
import io.reactivex.rxkotlin.addTo |
|
|
|
|
import io.reactivex.schedulers.Schedulers |
|
|
|
@ -55,9 +54,8 @@ class ConversationsViewModel @Inject constructor( |
|
|
|
|
val newConversation = conversation.copy( |
|
|
|
|
lastStatus = conversation.lastStatus.copy(favourited = favourite) |
|
|
|
|
) |
|
|
|
|
Single.fromCallable { |
|
|
|
|
database.conversationDao().insert(newConversation) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
database.conversationDao().insert(newConversation) |
|
|
|
|
} |
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) } |
|
|
|
@ -74,9 +72,8 @@ class ConversationsViewModel @Inject constructor( |
|
|
|
|
val newConversation = conversation.copy( |
|
|
|
|
lastStatus = conversation.lastStatus.copy(poll = poll) |
|
|
|
|
) |
|
|
|
|
Single.fromCallable { |
|
|
|
|
database.conversationDao().insert(newConversation) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
database.conversationDao().insert(newConversation) |
|
|
|
|
} |
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
.doOnError { t -> Log.w("ConversationViewModel", "Failed to favourite conversation", t) } |
|
|
|
@ -118,18 +115,14 @@ class ConversationsViewModel @Inject constructor( |
|
|
|
|
/* this is not ideal since deleting last toot from an conversation |
|
|
|
|
should not delete the conversation but show another toot of the conversation */ |
|
|
|
|
timelineCases.delete(conversation.lastStatus.id) |
|
|
|
|
Single.fromCallable { |
|
|
|
|
database.conversationDao().delete(conversation) |
|
|
|
|
} |
|
|
|
|
database.conversationDao().delete(conversation) |
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
.subscribe() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun saveConversationToDb(conversation: ConversationEntity) { |
|
|
|
|
Single.fromCallable { |
|
|
|
|
database.conversationDao().insert(conversation) |
|
|
|
|
} |
|
|
|
|
database.conversationDao().insert(conversation) |
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
.subscribe() |
|
|
|
|
} |
|
|
|
|