Merge branch 'master' into feature/chatinfo-changes

This commit is contained in:
Sebastian Wolf 2020-11-17 21:15:33 +01:00 committed by GitHub
commit a5d0486128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 122 additions and 124 deletions

View file

@ -22,6 +22,7 @@
#include <QListIterator>
#include <QByteArray>
#include <QBitArray>
#include <QDebug>
#define LOG(x) qDebug() << "[ChatModel]" << x
@ -178,7 +179,6 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages, int totalCo
}
} else {
if (this->isMostRecentMessageLoaded() || this->inIncrementalUpdate) {
this->messagesMutex.lock();
this->messagesToBeAdded.clear();
QListIterator<QVariant> messagesIterator(messages);
while (messagesIterator.hasNext()) {
@ -194,7 +194,6 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages, int totalCo
if (!this->messagesToBeAdded.isEmpty()) {
this->insertMessages();
}
this->messagesMutex.unlock();
// First call only returns a few messages, we need to get a little more than that...
if (!this->messagesToBeAdded.isEmpty() && (this->messagesToBeAdded.size() + this->messages.size()) < 10 && !this->inReload) {
@ -228,13 +227,11 @@ void ChatModel::handleNewMessageReceived(const QString &id, const QVariantMap &m
if (id.toLongLong() == chatId && !this->messageIndexMap.contains(id)) {
if (this->isMostRecentMessageLoaded()) {
LOG("New message received for this chat");
this->messagesMutex.lock();
this->messagesToBeAdded.clear();
this->messagesToBeAdded.append(message);
this->insertMessages();
this->messagesMutex.unlock();
emit newMessageReceived(message);
} else {
LOG("New message in this chat, but not relevant as less recent messages need to be loaded first!");
@ -267,13 +264,11 @@ void ChatModel::handleMessageSendSucceeded(const QString &messageId, const QStri
LOG("Message send succeeded, new message ID" << messageId << "old message ID" << oldMessageId << ", chat ID" << message.value(CHAT_ID).toString());
LOG("index map:" << messageIndexMap.contains(oldMessageId) << ", index count:" << messageIndexMap.size() << ", message count:" << messages.size());
if (this->messageIndexMap.contains(oldMessageId)) {
this->messagesMutex.lock();
LOG("Message was successfully sent" << oldMessageId);
int messageIndex = this->messageIndexMap.value(oldMessageId).toInt();
this->messages.replace(messageIndex, message);
this->calculateMessageIndexMap();
LOG("Message was replaced at index" << messageIndex);
this->messagesMutex.unlock();
emit dataChanged(index(messageIndex), index(messageIndex));
emit lastReadSentMessageUpdated(calculateLastReadSentMessageId());
}
@ -301,7 +296,6 @@ void ChatModel::handleMessageContentUpdated(const QString &id, const QString &me
{
LOG("Message content updated" << id << messageId);
if (id.toLongLong() == chatId && messageIndexMap.contains(messageId)) {
this->messagesMutex.lock();
LOG("We know the message that was updated " << messageId);
int messageIndex = this->messageIndexMap.value(messageId).toInt();
QVariantMap messageToBeUpdated = this->messages.at(messageIndex).toMap();
@ -309,7 +303,6 @@ void ChatModel::handleMessageContentUpdated(const QString &id, const QString &me
this->messages.replace(messageIndex, messageToBeUpdated);
this->calculateMessageIndexMap();
LOG("Message was replaced at index" << messageIndex);
this->messagesMutex.unlock();
emit messageUpdated(messageIndex);
emit dataChanged(index(messageIndex), index(messageIndex));
}
@ -319,7 +312,6 @@ void ChatModel::handleMessagesDeleted(const QString &id, const QVariantList &mes
{
LOG("Messages were deleted in a chat" << id);
if (id.toLongLong() == chatId) {
this->messagesMutex.lock();
LOG("Messages in this chat were deleted...");
QListIterator<QVariant> messageIdIterator(messageIds);
while (messageIdIterator.hasNext()) {
@ -333,7 +325,6 @@ void ChatModel::handleMessagesDeleted(const QString &id, const QVariantList &mes
endRemoveRows();
}
}
this->messagesMutex.unlock();
emit messagesDeleted();
}
}

View file

@ -21,8 +21,6 @@
#define CHATMODEL_H
#include <QAbstractListModel>
#include <QDebug>
#include <QMutex>
#include "tdlibwrapper.h"
class ChatModel : public QAbstractListModel
@ -74,7 +72,6 @@ private:
QVariantList messages;
QVariantList messagesToBeAdded;
QVariantMap messageIndexMap;
QMutex messagesMutex;
QVariantMap chatInformation;
qlonglong chatId;
bool inReload;

View file

@ -9,7 +9,7 @@
</message>
<message>
<source>A Telegram client for Sailfish OS</source>
<translation>Klien Telegram dla Sailfish OS</translation>
<translation>Klient Telegram dla Sailfish OS</translation>
</message>
<message>
<source>Send E-Mail</source>
@ -81,7 +81,7 @@
</message>
<message>
<source>Open rlottie on GitHub</source>
<translation type="unfinished"></translation>
<translation>Otwórz rlottie na GitHub</translation>
</message>
</context>
<context>
@ -97,73 +97,73 @@
</context>
<context>
<name>ChatInformationPageContent</name>
<message>
<source>%1 members, %2 online</source>
<translation type="unfinished">$1 członków, %2 online </translation>
</message>
<message>
<source>%1 subscribers</source>
<translation type="unfinished">%1 subskrybentów</translation>
</message>
<message>
<source>%1 members</source>
<translation type="unfinished">%1 czlonków</translation>
</message>
<message>
<source>Leave Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Join Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Leaving chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Wyłącz wyciszenie czatu</translation>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Wycisz czat</translation>
<translation>Wycisz czat</translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished">Nieznany</translation>
<translation>Nieznany</translation>
</message>
<message>
<source>Chat Title</source>
<comment>group title header</comment>
<translation type="unfinished"></translation>
<source>The Invite Link has been copied to the clipboard.</source>
<translation>Link do zaproszenia został skopiowany do schowka.</translation>
</message>
<message>
<source>Enter 1-128 characters</source>
<translation type="unfinished"></translation>
<source>%1 members, %2 online</source>
<translation>$1 członków, %2 online </translation>
</message>
<message>
<source>There is no information text available, yet.</source>
<translation type="unfinished"></translation>
<source>%1 subscribers</source>
<translation>%1 subskrybentów</translation>
</message>
<message>
<source>%1 members</source>
<translation>%1 czlonków</translation>
</message>
<message>
<source>Leaving chat</source>
<translation>Opuszcza czat</translation>
</message>
<message>
<source>Info</source>
<comment>group or user infotext header</comment>
<translation type="unfinished"></translation>
<translation>Informacja</translation>
</message>
<message>
<source>Phone Number</source>
<comment>user phone number header</comment>
<translation type="unfinished"></translation>
<translation>Numer telefonu</translation>
</message>
<message>
<source>Invite Link</source>
<comment>header</comment>
<translation type="unfinished"></translation>
<translation>Link z zaproszeniem</translation>
</message>
<message>
<source>The Invite Link has been copied to the clipboard.</source>
<translation type="unfinished"></translation>
<source>There is no information text available, yet.</source>
<translation>Nie ma jeszcze dostępnego tekstu informacyjnego.</translation>
</message>
<message>
<source>Chat Title</source>
<comment>group title header</comment>
<translation>Tytuł czatu</translation>
</message>
<message>
<source>Enter 1-128 characters</source>
<translation>Wprowadź znaki 1-128</translation>
</message>
<message>
<source>Leave Chat</source>
<translation>Opuść czat</translation>
</message>
<message>
<source>Join Chat</source>
<translation>Dołącz do czatu</translation>
</message>
</context>
<context>
@ -171,31 +171,41 @@
<message>
<source>Loading common chats</source>
<comment>chats you have in common with a user</comment>
<translation type="unfinished"></translation>
<translation>Ładowanie wspólnych czatów...</translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished">Nieznany</translation>
<translation>Nieznany</translation>
</message>
<message>
<source>Groups</source>
<comment>Button: groups in common (short)</comment>
<translation>Grupy</translation>
</message>
<message>
<source>Members</source>
<comment>Button: Group Members</comment>
<translation>Członkowie</translation>
</message>
<message>
<source>Loading group members</source>
<translation type="unfinished"></translation>
<translation>Ładowanie członków grupy</translation>
</message>
<message>
<source>You</source>
<translation type="unfinished">Ty</translation>
<translation>Ty</translation>
</message>
<message>
<source>You don&apos;t have any groups in common with this user.</source>
<translation type="unfinished"></translation>
<translation>Nie masz żadnych wspólnych grup z tym użytkownikiem.</translation>
</message>
<message>
<source>This group is empty.</source>
<translation type="unfinished"></translation>
<translation>Ta grupa jest pusta</translation>
</message>
<message>
<source>Channel members are anonymous.</source>
<translation type="unfinished"></translation>
<translation>Członkowie kanału anonimowi</translation>
</message>
</context>
<context>
@ -213,38 +223,38 @@
<message>
<source>Settings</source>
<comment>Button: Chat Settings</comment>
<translation type="unfinished">Ustawienia</translation>
<translation>Ustawienia</translation>
</message>
</context>
<context>
<name>ChatListViewItem</name>
<message>
<source>Unknown</source>
<translation type="unfinished">Nieznany</translation>
<translation>Nieznany</translation>
</message>
<message>
<source>You</source>
<translation type="unfinished">Ty</translation>
<translation>Ty</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished">Wyłącz wyciszenie czatu</translation>
<translation>Wyłącz wyciszenie czatu</translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished">Wycisz czat</translation>
<translation>Wycisz czat</translation>
</message>
<message>
<source>User Info</source>
<translation type="unfinished"></translation>
<translation>Informacje o użytkowniku</translation>
</message>
<message>
<source>Group Info</source>
<translation type="unfinished"></translation>
<translation>Informacje o grupie</translation>
</message>
<message>
<source>Mark all messages as read</source>
<translation type="unfinished"></translation>
<translation>Zaznacz wszystkie wiadomości jako przeczytane</translation>
</message>
</context>
<context>
@ -295,60 +305,60 @@
</message>
<message>
<source>This chat is empty.</source>
<translation type="unfinished"></translation>
<translation>Ten czat jest pusty</translation>
</message>
<message>
<source>Leave Chat</source>
<translation type="unfinished"></translation>
<translation>Opuść czat</translation>
</message>
<message>
<source>Join Chat</source>
<translation type="unfinished"></translation>
<translation>Dołącz do czatu</translation>
</message>
<message>
<source>Leaving chat</source>
<translation type="unfinished"></translation>
<translation>Opuszczanie czatu</translation>
</message>
<message>
<source>You joined the chat %1</source>
<translation type="unfinished"></translation>
<translation>Dołączyłeś do czatu %1</translation>
</message>
<message>
<source>Select Messages</source>
<translation type="unfinished"></translation>
<translation>Wybierz wiadomości</translation>
</message>
<message numerus="yes">
<source>%n Messages deleted</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform></numerusform>
<translation>
<numerusform>%n wiadomość została usunięta</numerusform>
<numerusform>%n wiadomości zostały usunięte</numerusform>
<numerusform>%n wiadomości zostało usunięte</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n messages have been copied</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform></numerusform>
<translation>
<numerusform>%n wiadomość została skopiowana</numerusform>
<numerusform>%n wiadomości zostały skopiowane</numerusform>
<numerusform>%n wiadomość zostało skopiowane</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n messages selected</source>
<comment>number of messages selected</comment>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform></numerusform>
<translation>
<numerusform>%n wiadomość została wybrana</numerusform>
<numerusform>%n wiadomości zostały wybrane</numerusform>
<numerusform>%n wiadomości zostało wybrane</numerusform>
</translation>
</message>
<message numerus="yes">
<source>Forward %n messages</source>
<comment>dialog header</comment>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<numerusform></numerusform>
<translation>
<numerusform>Przekaż %n wiadomość</numerusform>
<numerusform>Przekaż %n wiadomości</numerusform>
<numerusform>Przekaż %n wiadomości</numerusform>
</translation>
</message>
</context>
@ -360,7 +370,7 @@
</message>
<message>
<source>You don&apos;t have any chats yet.</source>
<translation type="unfinished">Nie masz jeszcze żadnych czatów.</translation>
<translation>Nie masz jeszcze żadnych czatów.</translation>
</message>
</context>
<context>
@ -422,22 +432,22 @@
<message>
<source>Group Member Permissions</source>
<comment>what can normal group members do</comment>
<translation type="unfinished"></translation>
<translation>Uprawnienia członka grupy</translation>
</message>
<message>
<source>Send Messages</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Wyślij wiadomości</translation>
</message>
<message>
<source>Send Media Messages</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Wyślij wiadomość multimedialną</translation>
</message>
<message>
<source>Send Other Messages</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Wyślij inne wiadomości</translation>
</message>
<message>
<source>Add Web Page Previews</source>
@ -447,12 +457,12 @@
<message>
<source>Change Chat Info</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Zmień informacje o czacie</translation>
</message>
<message>
<source>Invite Users</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Zaproś użytkowników</translation>
</message>
<message>
<source>Pin Messages</source>
@ -462,12 +472,12 @@
<message>
<source>New Members</source>
<comment>what can new group members do</comment>
<translation type="unfinished"></translation>
<translation>Nowi członkowie</translation>
</message>
<message>
<source>New members can see older messages</source>
<comment>member permission</comment>
<translation type="unfinished"></translation>
<translation>Nowi członkowie mogą zobaczyć starsze wiadomości</translation>
</message>
</context>
<context>
@ -799,7 +809,7 @@
</message>
<message>
<source>Use the international format, e.g. %1</source>
<translation type="unfinished"></translation>
<translation>Użyj międzynarodowego formatu, %1</translation>
</message>
</context>
<context>
@ -821,34 +831,34 @@
</message>
<message>
<source>Copy Message to Clipboard</source>
<translation type="unfinished"></translation>
<translation>Skopiuj wiadomość do schowka</translation>
</message>
<message>
<source>Message deleted</source>
<translation type="unfinished"></translation>
<translation>Wiadomość usunięta</translation>
</message>
<message>
<source>Delete Message</source>
<translation type="unfinished">Usuń wiadomość</translation>
<translation>Usuń wiadomość</translation>
</message>
<message>
<source>You</source>
<translation type="unfinished">Ty</translation>
<translation>Ty</translation>
</message>
<message>
<source>Forwarded Message</source>
<translation type="unfinished"></translation>
<translation>Wiadomość przekazana</translation>
</message>
<message>
<source>Select Message</source>
<translation type="unfinished"></translation>
<translation>Wybierz wiadomość</translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>
<message>
<source>You</source>
<translation type="unfinished">Ty</translation>
<translation>Ty</translation>
</message>
</context>
<context>
@ -898,7 +908,7 @@
</message>
<message>
<source>You don&apos;t have any chats yet.</source>
<translation type="unfinished">Nie masz jeszcze żadnych czatów.</translation>
<translation>Nie masz jeszcze żadnych czatów.</translation>
</message>
</context>
<context>
@ -926,16 +936,16 @@
<message>
<source>Create a Poll</source>
<comment>Dialog Header</comment>
<translation type="unfinished"></translation>
<translation>Utórz ankietę</translation>
</message>
<message>
<source>in %1</source>
<comment>After dialog header Create a Poll in [group name]</comment>
<translation type="unfinished"></translation>
<translation>w %1</translation>
</message>
<message>
<source>Enter your question here</source>
<translation type="unfinished"></translation>
<translation>Wprowadź tutaj swoje pytanie</translation>
</message>
<message numerus="yes">
<source>Question (%n1 characters left)</source>
@ -948,11 +958,11 @@
<message>
<source>Answers</source>
<comment>Section header</comment>
<translation type="unfinished"></translation>
<translation>Odpowiedzi</translation>
</message>
<message>
<source>Enter an answer here</source>
<translation type="unfinished"></translation>
<translation>Wprowadź tutaj swoją odpowiedź</translation>
</message>
<message numerus="yes">
<source>Answer (%n1 characters left)</source>
@ -964,24 +974,24 @@
</message>
<message>
<source>Add an answer</source>
<translation type="unfinished"></translation>
<translation>Dodaj odpowiedź</translation>
</message>
<message>
<source>Poll Options</source>
<comment>Section header</comment>
<translation type="unfinished"></translation>
<translation>Opcje ankiety</translation>
</message>
<message>
<source>Anonymous answers</source>
<translation type="unfinished"></translation>
<translation>Anonimowa odpowiedź</translation>
</message>
<message>
<source>Multiple answers allowed</source>
<translation type="unfinished"></translation>
<translation>Wielokrotna odpowiedź dozwolona</translation>
</message>
<message>
<source>Quiz Mode</source>
<translation type="unfinished"></translation>
<translation>Tryb quizu</translation>
</message>
<message>
<source>Quizzes have one correct answer. Participants can&apos;t revoke their responses.</source>
@ -993,11 +1003,11 @@
<message>
<source>%L1%</source>
<comment>% of votes for option</comment>
<translation type="unfinished"></translation>
<translation>%L1%</translation>
</message>
<message>
<source>Final Result:</source>
<translation type="unfinished"></translation>
<translation>Ostateczny wynik:</translation>
</message>
<message>
<source>Multiple Answers are allowed.</source>
@ -1014,11 +1024,11 @@
</message>
<message>
<source>Close Poll</source>
<translation type="unfinished"></translation>
<translation>Zamknij ankietę</translation>
</message>
<message>
<source>Reset Answer</source>
<translation type="unfinished"></translation>
<translation>Resetuj odpowiedź</translation>
</message>
</context>
<context>
@ -1062,7 +1072,7 @@
<message>
<source>%L1%</source>
<comment>% of votes for option</comment>
<translation type="unfinished"></translation>
<translation>%L1%</translation>
</message>
<message>
<source>Chosen by:</source>