Эх сурвалжийг харах

fix to be able to modify status message after predefined status was selected

so api to set a predefined status is not used at all..

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 жил өмнө
parent
commit
bce0d276f3

+ 21 - 50
app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt

@@ -385,59 +385,31 @@ class SetStatusDialogFragment :
     }
 
     private fun setStatusMessage() {
-        if (selectedPredefinedMessageId != null) {
-
-            ncApi.setPredefinedStatusMessage(
-                credentials,
-                ApiUtils.getUrlForSetPredefinedStatus(currentUser?.baseUrl),
-                selectedPredefinedMessageId,
-                clearAt)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                ?.subscribe(object : Observer<GenericOverall> {
-
-                    override fun onSubscribe(d: Disposable) {
-                    }
-
-                    override fun onNext(t: GenericOverall) {
-                        Log.d(TAG, "PredefinedStatusMessage successfully set")
-                        dismiss()
-                    }
-
-                    override fun onError(e: Throwable) {
-                        Log.d(TAG, "failed to set PredefinedStatusMessage", e)
-                    }
-
-                    override fun onComplete() {}
-
-                })
-        } else {
-            ncApi.setCustomStatusMessage(
-                credentials,
-                ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
-                binding.emoji.text.toString(),
-                binding.customStatusInput.text.toString(),
-                clearAt)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                ?.subscribe(object : Observer<GenericOverall> {
-
-                    override fun onSubscribe(d: Disposable) {
-                    }
+        ncApi.setCustomStatusMessage(
+            credentials,
+            ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
+            binding.emoji.text.toString(),
+            binding.customStatusInput.text.toString(),
+            clearAt)
+            .subscribeOn(Schedulers.io())
+            .observeOn(AndroidSchedulers.mainThread())
+            ?.subscribe(object : Observer<GenericOverall> {
+
+                override fun onSubscribe(d: Disposable) {
+                }
 
-                    override fun onNext(t: GenericOverall) {
-                        Log.d(TAG, "CustomStatusMessage successfully set")
-                        dismiss()
-                    }
+                override fun onNext(t: GenericOverall) {
+                    Log.d(TAG, "CustomStatusMessage successfully set")
+                    dismiss()
+                }
 
-                    override fun onError(e: Throwable) {
-                        Log.d(TAG, "failed to set CustomStatusMessage", e)
-                    }
+                override fun onError(e: Throwable) {
+                    Log.d(TAG, "failed to set CustomStatusMessage", e)
+                }
 
-                    override fun onComplete() {}
+                override fun onComplete() {}
 
-                })
-        }
+            })
     }
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
@@ -445,7 +417,6 @@ class SetStatusDialogFragment :
     }
 
     override fun onClick(predefinedStatus: PredefinedStatus) {
-        selectedPredefinedMessageId = predefinedStatus.id
         clearAt = clearAtToUnixTime(predefinedStatus.clearAt)
         binding.emoji.setText(predefinedStatus.icon)
         binding.customStatusInput.text?.clear()

+ 0 - 5
app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java

@@ -437,11 +437,6 @@ public class ApiUtils {
         return getUrlForStatus(baseUrl) + "/message";
     }
 
-
-    public static String getUrlForSetPredefinedStatus(String baseUrl) {
-        return baseUrl + ocsApiVersion + "/apps/user_status/api/v1/user_status/message/predefined";
-    }
-
     public static String getUrlForSetCustomStatus(String baseUrl) {
         return baseUrl + ocsApiVersion + "/apps/user_status/api/v1/user_status/message/custom";
     }