Commit d173885e authored by Romain Hunault's avatar Romain Hunault

Merge branch 'dev' into 'master'

[RELEASE] Sprint Freetown

See merge request !17
parents 0a3a5803 a34484ae
Pipeline #40855 passed with stage
in 7 minutes and 59 seconds
......@@ -25,6 +25,7 @@ import dagger.Module
import dagger.Provides
import dagger.multibindings.IntoMap
import io.reactivex.disposables.CompositeDisposable
import javax.inject.Named
@Module
class MainActivityModule {
......@@ -33,6 +34,11 @@ class MainActivityModule {
@ActivityScope
fun provideCompositeDiposableLifecycle(): CompositeDisposable = CompositeDisposable()
@Provides
@Named("threadId")
fun provideThreadId(activity: MainActivity): Long = activity.intent.extras?.getLong("threadId")
?: 0L
@Provides
@IntoMap
@ViewModelKey(MainViewModel::class)
......
......@@ -24,16 +24,7 @@ import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.extensions.mapNotNull
import com.moez.QKSMS.interactor.DeleteConversations
import com.moez.QKSMS.interactor.MarkAllSeen
import com.moez.QKSMS.interactor.MarkArchived
import com.moez.QKSMS.interactor.MarkPinned
import com.moez.QKSMS.interactor.MarkRead
import com.moez.QKSMS.interactor.MarkUnarchived
import com.moez.QKSMS.interactor.MarkUnpinned
import com.moez.QKSMS.interactor.MarkUnread
import com.moez.QKSMS.interactor.MigratePreferences
import com.moez.QKSMS.interactor.SyncMessages
import com.moez.QKSMS.interactor.*
import com.moez.QKSMS.listener.ContactAddedListener
import com.moez.QKSMS.manager.ChangelogManager
import com.moez.QKSMS.manager.PermissionManager
......@@ -51,25 +42,29 @@ import io.realm.Realm
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Named
class MainViewModel @Inject constructor(
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
private val contactAddedListener: ContactAddedListener,
private val changelogManager: ChangelogManager,
private val conversationRepo: ConversationRepository,
private val deleteConversations: DeleteConversations,
private val markArchived: MarkArchived,
private val markPinned: MarkPinned,
private val markRead: MarkRead,
private val markUnarchived: MarkUnarchived,
private val markUnpinned: MarkUnpinned,
private val markUnread: MarkUnread,
private val navigator: Navigator,
private val permissionManager: PermissionManager,
private val prefs: Preferences,
private val syncMessages: SyncMessages
@Named("threadId") private val threadId: Long,
markAllSeen: MarkAllSeen,
migratePreferences: MigratePreferences,
syncRepository: SyncRepository,
private val contactAddedListener: ContactAddedListener,
private val changelogManager: ChangelogManager,
private val conversationRepo: ConversationRepository,
private val deleteConversations: DeleteConversations,
private val markArchived: MarkArchived,
private val markBlocked: MarkBlocked,
private val markPinned: MarkPinned,
private val markRead: MarkRead,
private val markUnarchived: MarkUnarchived,
private val markUnpinned: MarkUnpinned,
private val markUnread: MarkUnread,
private val navigator: Navigator,
private val permissionManager: PermissionManager,
private val prefs: Preferences,
private val syncMessages: SyncMessages,
private val syncContacts: ContactSync
) : QkViewModel<MainView, MainState>(MainState(page = Inbox(data = conversationRepo.getConversations()))) {
init {
......@@ -388,6 +383,12 @@ class MainViewModel @Inject constructor(
}
.autoDisposable(view.scope())
.subscribe()
if (threadId == 0L) {
syncContacts.execute(Unit)
}
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment