Add chat list menu option to pin/unpin chat

This commit is contained in:
Sebastian Wolf 2021-01-07 22:47:42 +01:00
parent 7453c60052
commit e3370bf73e
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
14 changed files with 289 additions and 185 deletions

View file

@ -55,19 +55,18 @@ PhotoTextsListItem {
}
MenuItem {
visible: unread_count === 0 && !is_marked_as_unread
visible: unread_count === 0
onClicked: {
tdLibWrapper.toggleChatIsMarkedAsUnread(chat_id, true);
tdLibWrapper.toggleChatIsMarkedAsUnread(chat_id, !is_marked_as_unread);
}
text: qsTr("Mark chat as unread")
text: is_marked_as_unread ? qsTr("Mark chat as read") : qsTr("Mark chat as unread")
}
MenuItem {
visible: unread_count === 0 && is_marked_as_unread
onClicked: {
tdLibWrapper.toggleChatIsMarkedAsUnread(chat_id, false);
tdLibWrapper.toggleChatIsPinned(chat_id, !is_pinned);
}
text: qsTr("Mark chat as read")
text: is_pinned ? qsTr("Unpin chat") : qsTr("Pin chat")
}
MenuItem {
@ -82,7 +81,7 @@ PhotoTextsListItem {
newNotificationSettings.use_default_mute_for = false;
tdLibWrapper.setChatNotificationSettings(chat_id, newNotificationSettings);
}
text: display.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat")
text: display.notification_settings.mute_for > 0 ? qsTr("Unmute chat") : qsTr("Mute chat")
}
MenuItem {

View file

@ -47,8 +47,10 @@ namespace {
const QString USERNAME("username");
const QString THREAD_ID("thread_id");
const QString VALUE("value");
const QString CHAT_LIST_TYPE("chat_list_type");
const QString _TYPE("@type");
const QString _EXTRA("@extra");
const QString CHAT_LIST_MAIN("chatListMain");
}
TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent) : QObject(parent), joinChatRequested(false)
@ -1035,6 +1037,20 @@ void TDLibWrapper::toggleChatIsMarkedAsUnread(qlonglong chatId, bool isMarkedAsU
this->sendRequest(requestObject);
}
void TDLibWrapper::toggleChatIsPinned(qlonglong chatId, bool isPinned)
{
LOG("Toggle chat is pinned" << chatId << isPinned);
QVariantMap requestObject;
requestObject.insert(_TYPE, "toggleChatIsPinned");
QVariantMap chatListMap;
chatListMap.insert(_TYPE, CHAT_LIST_MAIN);
requestObject.insert("chat_list", chatListMap);
requestObject.insert(CHAT_ID, chatId);
requestObject.insert("is_pinned", isPinned);
requestObject.insert("is_marked_as_unread", isPinned);
this->sendRequest(requestObject);
}
void TDLibWrapper::setChatDraftMessage(qlonglong chatId, qlonglong threadId, qlonglong replyToMessageId, const QString &draft)
{
LOG("Set Draft Message" << chatId);
@ -1345,7 +1361,7 @@ void TDLibWrapper::handleChatReceived(const QVariantMap &chatInformation)
void TDLibWrapper::handleUnreadMessageCountUpdated(const QVariantMap &messageCountInformation)
{
if (messageCountInformation.value("chat_list_type").toString() == "chatListMain") {
if (messageCountInformation.value(CHAT_LIST_TYPE).toString() == CHAT_LIST_MAIN) {
this->unreadMessageInformation = messageCountInformation;
emit unreadMessageCountUpdated(messageCountInformation);
}
@ -1353,7 +1369,7 @@ void TDLibWrapper::handleUnreadMessageCountUpdated(const QVariantMap &messageCou
void TDLibWrapper::handleUnreadChatCountUpdated(const QVariantMap &chatCountInformation)
{
if (chatCountInformation.value("chat_list_type").toString() == "chatListMain") {
if (chatCountInformation.value(CHAT_LIST_TYPE).toString() == CHAT_LIST_MAIN) {
this->unreadChatInformation = chatCountInformation;
emit unreadChatCountUpdated(chatCountInformation);
}

View file

@ -185,6 +185,7 @@ public:
Q_INVOKABLE void searchPublicChats(const QString &query);
Q_INVOKABLE void readAllChatMentions(qlonglong chatId);
Q_INVOKABLE void toggleChatIsMarkedAsUnread(qlonglong chatId, bool isMarkedAsUnread);
Q_INVOKABLE void toggleChatIsPinned(qlonglong chatId, bool isPinned);
Q_INVOKABLE void setChatDraftMessage(qlonglong chatId, qlonglong threadId, qlonglong replyToMessageId, const QString &draft);
// Others (candidates for extraction ;))

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Verlasse Chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Stummschaltung des Chats aufheben</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Chat stummschalten</translation>
</message>
<message>
<source>Unknown</source>
<translation>Unbekannt</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation>Neuer geheimer Chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Stummschaltung des Chats aufheben</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Chat stummschalten</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>Sie</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Stummschaltung des Chats aufheben</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Chat stummschalten</translation>
</message>
<message>
<source>User Info</source>
<translation>Benutzerinfos</translation>
@ -276,6 +268,22 @@
<source>Draft</source>
<translation>Entwurf</translation>
</message>
<message>
<source>Unpin chat</source>
<translation>Chat losheften</translation>
</message>
<message>
<source>Pin chat</source>
<translation>Chat anheften</translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Stummschaltung des Chats aufheben</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Chat stummschalten</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Leaving chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Mute Chat</translation>
</message>
<message>
<source>Unknown</source>
<translation>Unknown</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation>New Secret Chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Mute Chat</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>You</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Mute Chat</translation>
</message>
<message>
<source>User Info</source>
<translation>User Info</translation>
@ -276,6 +268,22 @@
<source>Draft</source>
<translation>Draft</translation>
</message>
<message>
<source>Unpin chat</source>
<translation>Unpin chat</translation>
</message>
<message>
<source>Pin chat</source>
<translation>Pin chat</translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Unmute chat</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Mute chat</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -121,14 +121,6 @@
<source>Leaving chat</source>
<translation>Saliendo de la charla</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Notificar</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>No notificar</translation>
</message>
<message>
<source>Unknown</source>
<translation>Desconocido</translation>
@ -180,6 +172,14 @@
<source>New Secret Chat</source>
<translation>Charla secreta</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Notificar</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>No notificar</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -237,14 +237,6 @@
<source>You</source>
<translation>Usted</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Notificar</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>No notificar</translation>
</message>
<message>
<source>User Info</source>
<translation>Usuario</translation>
@ -273,6 +265,22 @@
<source>Mark chat as read</source>
<translation>Marcar como leído</translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Notificar</translation>
</message>
<message>
<source>Mute chat</source>
<translation>No notificar</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Poistutaan keskustelusta</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Poista keskustelun vaimennus</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Vaimenna keskustelu</translation>
</message>
<message>
<source>Unknown</source>
<translation>Tuntematon</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation>Uusi salattu keskustelu</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Poista keskustelun vaimennus</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Vaimenna keskustelu</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>Sinä</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Poista keskustelun vaimennus</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Vaimenna keskustelu</translation>
</message>
<message>
<source>User Info</source>
<translation>Käyttäjän tiedot</translation>
@ -276,6 +268,22 @@
<source>Mark chat as read</source>
<translation>Merkitse keskustelu luetuksi</translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Poista keskustelun vaimennus</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Vaimenna keskustelu</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -121,14 +121,6 @@
<source>Leaving chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Csevegés némítás feloldása</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Csevegés némítása</translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished">Ismeretlen</translation>
@ -180,6 +172,14 @@
<source>New Secret Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Csevegés némítás feloldása</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Csevegés némítása</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -237,14 +237,6 @@
<source>You</source>
<translation type="unfinished">Te</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Csevegés némítás feloldása</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Csevegés némítása</translation>
</message>
<message>
<source>User Info</source>
<translation type="unfinished"></translation>
@ -273,6 +265,22 @@
<source>Mark chat as read</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Csevegés némítás feloldása</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Csevegés némítása</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Lascia chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Riattiva suoni chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Silenzia chat</translation>
</message>
<message>
<source>Unknown</source>
<translation>Sconosciuto</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation>Nuova chat segreta</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Riattiva suoni chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Silenzia chat</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>Tu</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Riattiva suoni chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Silenzia chat</translation>
</message>
<message>
<source>User Info</source>
<translation>Info utente</translation>
@ -276,6 +268,22 @@
<source>Mark chat as read</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Riattiva suoni chat</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Silenzia chat</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -97,14 +97,6 @@
</context>
<context>
<name>ChatInformationPageContent</name>
<message>
<source>Unmute Chat</source>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Wycisz czat</translation>
</message>
<message>
<source>Unknown</source>
<translation>Nieznany</translation>
@ -186,6 +178,14 @@
<source>New Secret Chat</source>
<translation>Nowy tajny czat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Wycisz czat</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -243,14 +243,6 @@
<source>You</source>
<translation>Ty</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Wycisz czat</translation>
</message>
<message>
<source>User Info</source>
<translation>Informacje o użytkowniku</translation>
@ -279,6 +271,22 @@
<source>Mark chat as read</source>
<translation>Oznacz czat jako przeczytany</translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Wycisz czat</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -125,14 +125,6 @@
<source>Leaving chat</source>
<translation>Выход из чата</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Включить уведомления</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Выключить уведомления</translation>
</message>
<message>
<source>Unknown</source>
<translation>Неизвестный</translation>
@ -186,6 +178,14 @@
<source>New Secret Chat</source>
<translation>Новый секретный чат</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Включить уведомления</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Выключить уведомления</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -243,14 +243,6 @@
<source>You</source>
<translation>Вы</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Включить уведомления</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Выключить уведомления</translation>
</message>
<message>
<source>User Info</source>
<translation>Информация о пользователе</translation>
@ -279,6 +271,22 @@
<source>Mark chat as read</source>
<translation>Отметить чат как прочитанный</translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Включить уведомления</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Выключить уведомления</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Lämnar chatten</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Slå chatten</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Stäng av chatten</translation>
</message>
<message>
<source>Unknown</source>
<translation>Okänd</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation>Ny hemlig chatt</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Slå chatten</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Stäng av chatten</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>Du</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Slå chatten</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Stäng av chatten</translation>
</message>
<message>
<source>User Info</source>
<translation>Användarinfo</translation>
@ -276,6 +268,22 @@
<source>Mark chat as read</source>
<translation>Markera chatten som läst</translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation>Slå chatten</translation>
</message>
<message>
<source>Mute chat</source>
<translation>Stäng av chatten</translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -121,14 +121,6 @@
<source>Leaving chat</source>
<translation></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation></translation>
</message>
<message>
<source>Mute Chat</source>
<translation></translation>
</message>
<message>
<source>Unknown</source>
<translation></translation>
@ -180,6 +172,14 @@
<source>New Secret Chat</source>
<translation></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation></translation>
</message>
<message>
<source>Mute Chat</source>
<translation></translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -237,14 +237,6 @@
<source>You</source>
<translation></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation></translation>
</message>
<message>
<source>Mute Chat</source>
<translation></translation>
</message>
<message>
<source>User Info</source>
<translation></translation>
@ -273,6 +265,22 @@
<source>Mark chat as read</source>
<translation></translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation></translation>
</message>
<message>
<source>Mute chat</source>
<translation></translation>
</message>
</context>
<context>
<name>ChatPage</name>

View file

@ -123,14 +123,6 @@
<source>Leaving chat</source>
<translation>Leaving chat</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Mute Chat</translation>
</message>
<message>
<source>Unknown</source>
<translation>Unknown</translation>
@ -183,6 +175,14 @@
<source>New Secret Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Mute Chat</translation>
</message>
</context>
<context>
<name>ChatInformationTabItemMembersGroups</name>
@ -240,14 +240,6 @@
<source>You</source>
<translation>You</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation>Unmute Chat</translation>
</message>
<message>
<source>Mute Chat</source>
<translation>Mute Chat</translation>
</message>
<message>
<source>User Info</source>
<translation>User Info</translation>
@ -276,6 +268,22 @@
<source>Draft</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unpin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute chat</source>
<translation type="unfinished">Unmute chat</translation>
</message>
<message>
<source>Mute chat</source>
<translation type="unfinished">Mute chat</translation>
</message>
</context>
<context>
<name>ChatPage</name>