@@ -35,6 +35,7 @@ class MembersPresenter @Inject constructor(
35
35
private var offset: Long = 0
36
36
private lateinit var roomType: RoomType
37
37
private lateinit var roomId: String
38
+ private var totalMembers: Long = 0
38
39
var isRoomOwner: Boolean = false
39
40
40
41
/* *
@@ -68,6 +69,7 @@ class MembersPresenter @Inject constructor(
68
69
it.muted = muted?.find { it == username }.isNotNullNorEmpty()
69
70
}
70
71
view.showMembers(memberUiModels, members.total)
72
+ totalMembers = members.total
71
73
offset + = 1 * 60L
72
74
}.ifNull {
73
75
Timber .e(" Couldn't find a room with id: $roomId at current server." )
@@ -88,64 +90,64 @@ class MembersPresenter @Inject constructor(
88
90
navigator.toMemberDetails(memberUiModel.userId)
89
91
}
90
92
91
- fun toggleOwner (userId : String , isOwner : Boolean = false) {
93
+ fun toggleOwner (userId : String , isOwner : Boolean = false, notifier : () -> Unit ) {
92
94
launchUI(strategy) {
93
95
try {
94
96
if (isOwner)
95
97
retryIO(description = " removeOwner($roomId , $roomType , $userId )" ) { client.removeOwner(roomId, roomType, userId) }
96
98
else
97
99
retryIO(description = " addOwner($roomId , $roomType , $userId )" ) { client.addOwner(roomId, roomType, userId) }
98
- offset = 0
99
- navigator.toMembersList(roomId)
100
+ notifier()
100
101
} catch (ex: RocketChatException ) {
101
102
view.showMessage(ex.message!! ) // TODO Remove.
102
103
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
103
104
}
104
105
}
105
106
}
106
107
107
- fun toggleLeader (userId : String , isLeader : Boolean = false) {
108
+ fun toggleLeader (userId : String , isLeader : Boolean = false, notifier : () -> Unit ) {
108
109
launchUI(strategy) {
109
110
try {
110
111
if (isLeader)
111
112
retryIO(description = " removeLeader($roomId , $roomType , $userId )" ) { client.removeLeader(roomId, roomType, userId) }
112
113
else
113
114
retryIO(description = " addLeader($roomId , $roomType , $userId )" ) { client.addLeader(roomId, roomType, userId) }
114
- navigator.toMembersList(roomId )
115
+ notifier( )
115
116
} catch (ex: RocketChatException ) {
116
117
view.showMessage(ex.message!! ) // TODO Remove.
117
118
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
118
119
}
119
120
}
120
121
}
121
122
122
- fun toggleModerator (userId : String , isModerator : Boolean = false) {
123
+ fun toggleModerator (userId : String , isModerator : Boolean = false, notifier : () -> Unit ) {
123
124
launchUI(strategy) {
124
125
try {
125
126
if (isModerator)
126
127
retryIO(description = " removeModerator($roomId , $roomType , $userId )" ) { client.removeModerator(roomId, roomType, userId) }
127
128
else
128
129
retryIO(description = " addModerator($roomId , $roomType , $userId )" ) { client.addModerator(roomId, roomType, userId) }
129
- navigator.toMembersList(roomId )
130
+ notifier( )
130
131
} catch (ex: RocketChatException ) {
131
132
view.showMessage(ex.message!! ) // TODO Remove.
132
133
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
133
134
}
134
135
}
135
136
}
136
137
137
- fun toggleIgnore (userId : String , isIgnored : Boolean = false) {
138
+ fun toggleIgnore (userId : String , isIgnored : Boolean = false, notifier : () -> Unit ) {
138
139
launchUI(strategy) {
139
140
try {
140
141
retryIO(description = " ignoreUser($roomId , $userId , ${! isIgnored} )" ) { client.ignoreUser(roomId, userId, ! isIgnored) }
142
+ notifier()
141
143
} catch (ex: RocketChatException ) {
142
144
view.showMessage(ex.message!! ) // TODO Remove.
143
145
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
144
146
}
145
147
}
146
148
}
147
149
148
- fun toggleMute (username : String? , isMuted : Boolean = false) {
150
+ fun toggleMute (username : String? , isMuted : Boolean = false, notifier : () -> Unit ) {
149
151
launchUI(strategy) {
150
152
try {
151
153
if (isMuted)
@@ -156,17 +158,20 @@ class MembersPresenter @Inject constructor(
156
158
retryIO(" runCommand(mute, $username , $roomId )" ) {
157
159
client.runCommand(Command (" mute" , username), roomId)
158
160
}
161
+ notifier()
159
162
} catch (ex: RocketChatException ) {
160
163
view.showMessage(ex.message!! ) // TODO Remove.
161
164
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
162
165
}
163
166
}
164
167
}
165
168
166
- fun removeUser (userId : String ) {
169
+ fun removeUser (userId : String , notifier : () -> Unit ) {
167
170
launchUI(strategy) {
168
171
try {
169
172
retryIO(description = " removeUser($roomId , $roomType , $userId )" ) { client.removeUser(roomId, roomType, userId) }
173
+ notifier()
174
+ view.setMemberCount(-- totalMembers)
170
175
} catch (ex: RocketChatException ) {
171
176
view.showMessage(ex.message!! ) // TODO Remove.
172
177
Timber .e(ex) // FIXME: Right now we are only catching the exception with Timber.
0 commit comments