Pārlūkot izejas kodu

Pass 'null' for unset icon in custom status message

The OCS Status API  expect an valid emoji or 'null' for the status icon
in a custom message:

> field: statusIcon
> type: string/null
> Description: The icon picked by the user (must be an emoji, at most one)

See [1] for more details.

Resolves: #1839
See:
 [1] https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-status-api.html#set-a-custom-message-user-defined

Signed-off-by: Tim Krüger <t@timkrueger.me>
Tim Krüger 3 gadi atpakaļ
vecāks
revīzija
3411728597

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

@@ -393,15 +393,15 @@ class SetStatusDialogFragment :
     }
 
     private fun setStatusMessage() {
-        var inputText = binding.customStatusInput.text.toString()
-        if (inputText.isEmpty()) {
-            inputText = " "
-        }
+
+        val inputText = binding.customStatusInput.text.toString().ifEmpty { " " }
+        // The endpoint '/message/custom' expects a valid emoji as string or null
+        val statusIcon = binding.emoji.text.toString().ifEmpty { null }
 
         ncApi.setCustomStatusMessage(
             credentials,
             ApiUtils.getUrlForSetCustomStatus(currentUser?.baseUrl),
-            binding.emoji.text.toString(),
+            statusIcon,
             inputText,
             clearAt
         )