[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ruqola] src: Enable leave room with restapi
From:       Laurent Montel <null () kde ! org>
Date:       2018-04-30 14:49:53
Message-ID: E1fDA7l-0002E7-CL () code ! kde ! org
[Download RAW message or body]

Git commit c1f7cb39ccf1ff32f5d4563358f2d75e7385a7d2 by Laurent Montel.
Committed on 30/04/2018 at 14:49.
Pushed by mlaurent into branch 'master'.

Enable leave room with restapi

M  +1    -1    src/qml/Desktop.qml
M  +3    -2    src/qml/LeaveChannelDialog.qml
M  +1    -0    src/qml/RoomsComponent.qml
M  +10   -2    src/rocketchataccount.cpp
M  +1    -1    src/rocketchataccount.h

https://commits.kde.org/ruqola/c1f7cb39ccf1ff32f5d4563358f2d75e7385a7d2

diff --git a/src/qml/Desktop.qml b/src/qml/Desktop.qml
index b4ff9c5..e806332 100644
--- a/src/qml/Desktop.qml
+++ b/src/qml/Desktop.qml
@@ -183,7 +183,7 @@ Kirigami.ApplicationWindow {
     LeaveChannelDialog {
         id: leaveChannelDialog
         onLeaveChannel:  {
-            rocketChatAccount.leaveRoom(roomId)
+            rocketChatAccount.leaveRoom(roomId, channelType)
         }
     }
 
diff --git a/src/qml/LeaveChannelDialog.qml b/src/qml/LeaveChannelDialog.qml
index f602ec9..81eae0d 100644
--- a/src/qml/LeaveChannelDialog.qml
+++ b/src/qml/LeaveChannelDialog.qml
@@ -28,11 +28,12 @@ QQC2.Dialog {
 
     title: i18n("Leave Channel")
 
-    signal leaveChannel(string roomId)
+    signal leaveChannel(string roomId, string channelType)
 
     x: parent.width / 2 - width / 2
     y: parent.height / 2 - height / 2
 
+    property QtObject roomInfo
     property string rId: ""
     modal: true
 
@@ -47,6 +48,6 @@ QQC2.Dialog {
     }
 
     onAccepted: {
-        leaveChannelDialog.leaveChannel(rId)
+        leaveChannelDialog.leaveChannel(rId, roomInfo.channelType)
     }
 }
diff --git a/src/qml/RoomsComponent.qml b/src/qml/RoomsComponent.qml
index 982b03a..3cdf840 100644
--- a/src/qml/RoomsComponent.qml
+++ b/src/qml/RoomsComponent.qml
@@ -122,6 +122,7 @@ Component {
             onLeaveRoom: {
                 //TODO move to desktop.qml
                 leaveChannelDialog.rId = roomID
+                leaveChannelDialog.roomInfo = appid.selectedRoom
                 leaveChannelDialog.open()
             }
 
diff --git a/src/rocketchataccount.cpp b/src/rocketchataccount.cpp
index 2ea76d1..fd4626b 100644
--- a/src/rocketchataccount.cpp
+++ b/src/rocketchataccount.cpp
@@ -340,13 +340,13 @@ RestApiRequest *RocketChatAccount::restApi()
 
 void RocketChatAccount::leaveRoom(const QString &roomId, const QString &channelType)
 {
-#ifdef USE_REASTAPI_JOB_NOTSUPPORTED_YET
+#ifdef USE_REASTAPI_JOB
     if (channelType == QStringLiteral("c")) {
         restApi()->leaveChannel(roomId);
     } else if (channelType == QStringLiteral("p")) {
         restApi()->leaveGroups(roomId);
     } else {
-        qCWarning(RUQOLA_LOG) << " unsupport change announcement for type " << channelType;
+        qCWarning(RUQOLA_LOG) << " unsupport leave room for type " << channelType;
     }
 #else
     Q_UNUSED(channelType)
@@ -357,6 +357,14 @@ void RocketChatAccount::leaveRoom(const QString &roomId, const QString &channelT
 void RocketChatAccount::hideRoom(const QString &roomId, const QString &channelType)
 {
 #ifdef USE_REASTAPI_JOB_NOTSUPPORTED_YET
+    if (channelType == QStringLiteral("c")) {
+        restApi()->leaveChannel(roomId);
+    } else if (channelType == QStringLiteral("p")) {
+        restApi()->leaveGroups(roomId);
+    } else if (channelType == QStringLiteral("d")) {
+    } else {
+        qCWarning(RUQOLA_LOG) << " unsupport hide room for type " << channelType;
+    }
     restApi()->closeChannel(roomId, channelType);
 #else
     Q_UNUSED(channelType)
diff --git a/src/rocketchataccount.h b/src/rocketchataccount.h
index 08ec232..fe82985 100644
--- a/src/rocketchataccount.h
+++ b/src/rocketchataccount.h
@@ -107,7 +107,7 @@ public:
 
     Q_INVOKABLE void textEditing(const QString &roomId, const QString &str);
 
-    Q_INVOKABLE void leaveRoom(const QString &roomId, const QString &channelType = QString());
+    Q_INVOKABLE void leaveRoom(const QString &roomId, const QString &channelType);
     Q_INVOKABLE void hideRoom(const QString &roomId, const QString &channelType = QString());
     Q_INVOKABLE void tryLogin();
     Q_INVOKABLE void logOut();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic