@@ -47,42 +47,44 @@ class ReplicatorViewModel(private val replicatorService: ReplicatorService)
4747 logMessages.add(" INFORMATION:: Getting Replication Change Flow..." )
4848 replicatorFlow = replicatorService.getReplicatorChangeFlow()
4949 replicatorFlow?.let { flowChange ->
50- logMessages.add(" INFORMATION:: Collecting Replicator Changes" )
51- flowChange.collect { replicatorChange ->
52- logMessages.add(" INFORMATION:: Collecting Replication Change Flow..." )
50+ viewModelScope.launch(Dispatchers .Main ) {
51+ logMessages.add(" INFORMATION:: Collecting Replicator Changes" )
52+ flowChange.collect { replicatorChange ->
53+ logMessages.add(" INFORMATION:: Collecting Replication Change Flow..." )
5354
54- when (replicatorChange.status.activityLevel){
55- ReplicatorActivityLevel .OFFLINE -> {
56- replicationStatus.value = ReplicationStatus .OFFLINE
57- logMessages.add(" INFORMATION:: returned Status OFFLINE..." )
55+ when (replicatorChange.status.activityLevel) {
56+ ReplicatorActivityLevel .OFFLINE -> {
57+ replicationStatus.value = ReplicationStatus .OFFLINE
58+ logMessages.add(" INFORMATION:: returned Status OFFLINE..." )
59+ }
60+ ReplicatorActivityLevel .IDLE -> {
61+ replicationStatus.value = ReplicationStatus .IDlE
62+ logMessages.add(" INFORMATION:: returned Status IDLE..." )
63+ }
64+ ReplicatorActivityLevel .STOPPED -> {
65+ replicationStatus.value = ReplicationStatus .STOPPED
66+ logMessages.add(" INFORMATION:: returned Status STOPPED..." )
67+ }
68+ ReplicatorActivityLevel .BUSY -> {
69+ replicationStatus.value = ReplicationStatus .BUSY
70+ logMessages.add(" INFORMATION:: returned Status BUSY..." )
71+ }
72+ ReplicatorActivityLevel .CONNECTING -> {
73+ replicationStatus.value = ReplicationStatus .CONNECTING
74+ logMessages.add(" INFORMATION:: returned Status CONNECTING..." )
75+ }
5876 }
59- ReplicatorActivityLevel .IDLE -> {
60- replicationStatus.value = ReplicationStatus .IDlE
61- logMessages.add(" INFORMATION:: returned Status IDLE..." )
77+ replicatorChange.status.error?.let { error ->
78+ logMessages.add(" ERROR:: ${error.code} - ${error.message} " )
6279 }
63- ReplicatorActivityLevel .STOPPED -> {
64- replicationStatus.value = ReplicationStatus .STOPPED
65- logMessages.add(" INFORMATION:: returned Status STOPPED..." )
80+ logMessages.add(" INFORMATION:: Checking replication progress..." )
81+ if (replicatorChange.status.progress.completed == replicatorChange.status.progress.total || replicatorChange.status.progress.completed.toInt() == 0 ) {
82+ replicationProgress.value = " Completed"
83+ logMessages.add(" INFORMATION:: returned STATUS Completed..." )
84+ } else {
85+ replicationProgress.value =
86+ " ${replicatorChange.status.progress.total / replicatorChange.status.progress.completed} "
6687 }
67- ReplicatorActivityLevel .BUSY -> {
68- replicationStatus.value = ReplicationStatus .BUSY
69- logMessages.add(" INFORMATION:: returned Status BUSY..." )
70- }
71- ReplicatorActivityLevel .CONNECTING -> {
72- replicationStatus.value = ReplicationStatus .CONNECTING
73- logMessages.add(" INFORMATION:: returned Status CONNECTING..." )
74- }
75- }
76- replicatorChange.status.error?.let { error ->
77- logMessages.add(" ERROR:: ${error.code} - ${error.message} " )
78- }
79- logMessages.add(" INFORMATION:: Checking replication progress..." )
80- if (replicatorChange.status.progress.completed == replicatorChange.status.progress.total || replicatorChange.status.progress.completed.toInt() == 0 ){
81- replicationProgress.value = " Completed"
82- logMessages.add(" INFORMATION:: returned STATUS Completed..." )
83- } else {
84- replicationProgress.value =
85- " ${replicatorChange.status.progress.total / replicatorChange.status.progress.completed} "
8688 }
8789 }
8890 }
0 commit comments