Просмотр исходного кода

Migrate AddParticipantsToConversation from requery to room

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 лет назад
Родитель
Сommit
70d777ec3b

+ 11 - 5
app/src/main/java/com/nextcloud/talk/jobs/AddParticipantsToConversation.java

@@ -24,12 +24,13 @@ import android.content.Context;
 
 import com.nextcloud.talk.api.NcApi;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.data.user.model.User;
 import com.nextcloud.talk.events.EventStatus;
 import com.nextcloud.talk.models.RetrofitBucket;
-import com.nextcloud.talk.models.database.UserEntity;
+import com.nextcloud.talk.users.UserManager;
 import com.nextcloud.talk.utils.ApiUtils;
+import com.nextcloud.talk.utils.UserIdUtils;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
-import com.nextcloud.talk.utils.database.user.UserUtils;
 
 import org.greenrobot.eventbus.EventBus;
 
@@ -48,7 +49,7 @@ public class AddParticipantsToConversation extends Worker {
     NcApi ncApi;
 
     @Inject
-    UserUtils userUtils;
+    UserManager userManager;
 
     @Inject
     EventBus eventBus;
@@ -66,7 +67,10 @@ public class AddParticipantsToConversation extends Worker {
         String[] selectedGroupIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS());
         String[] selectedCircleIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_CIRCLES());
         String[] selectedEmails = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_EMAILS());
-        UserEntity user = userUtils.getUserWithInternalId(data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1));
+        User user =
+            userManager.getUserWithInternalId(
+                data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1))
+                .blockingGet();
 
         int apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {ApiUtils.APIv4, 1});
 
@@ -134,7 +138,9 @@ public class AddParticipantsToConversation extends Worker {
             }
         }
 
-        eventBus.post(new EventStatus(user.getId(), EventStatus.EventType.PARTICIPANTS_UPDATE, true));
+        eventBus.post(new EventStatus(UserIdUtils.INSTANCE.getIdForUser(user),
+                                      EventStatus.EventType.PARTICIPANTS_UPDATE,
+                                      true));
         return Result.success();
     }
 }