Small UI fixes, error handling for joining chats
This commit is contained in:
parent
b4ae9cf0f3
commit
5d3805759a
18 changed files with 125 additions and 13 deletions
|
@ -312,8 +312,13 @@ function enhanceMessageText(formattedText) {
|
|||
function handleLink(link) {
|
||||
var tMePrefix = tdLibWrapper.getOptionString("t_me_url");
|
||||
if (link.indexOf("user://") === 0) {
|
||||
var userInformation = tdLibWrapper.getUserInformationByName(link.substring(8));
|
||||
var userName = link.substring(8);
|
||||
var userInformation = tdLibWrapper.getUserInformationByName(userName);
|
||||
if (typeof userInformation.id === "undefined") {
|
||||
appNotification.show(qsTr("Unable to find user %1").arg(userName));
|
||||
} else {
|
||||
tdLibWrapper.createPrivateChat(userInformation.id);
|
||||
}
|
||||
} else if (link.indexOf("userId://") === 0) {
|
||||
tdLibWrapper.createPrivateChat(link.substring(9));
|
||||
} else if (link.indexOf("tg://") === 0) {
|
||||
|
|
|
@ -320,7 +320,7 @@ Page {
|
|||
Connections {
|
||||
target: chatListModel
|
||||
onChatJoined: {
|
||||
chatPageNotification.show(qsTr("You joined the chat %1").arg(chatTitle));
|
||||
appNotification.show(qsTr("You joined the chat %1").arg(chatTitle));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ Page {
|
|||
}
|
||||
|
||||
AppNotification {
|
||||
id: chatPageNotification
|
||||
id: appNotification
|
||||
}
|
||||
|
||||
BackgroundItem {
|
||||
|
@ -469,13 +469,6 @@ Page {
|
|||
width: parent.width
|
||||
maximumLineCount: 1
|
||||
horizontalAlignment: Text.AlignRight
|
||||
onTruncatedChanged: {
|
||||
// There is obviously a bug in QML in truncating text with images.
|
||||
// We simply remove Emojis then...
|
||||
if (truncated) {
|
||||
text = text.replace(/\<img [^>]+\/\>/g, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: chatStatusText
|
||||
|
|
|
@ -159,6 +159,11 @@ Page {
|
|||
pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { "chatInformation" : tdLibWrapper.getChat(chat.id) });
|
||||
}
|
||||
}
|
||||
onErrorReceived: {
|
||||
if (message === "USER_ALREADY_PARTICIPANT") {
|
||||
appNotification.show(qsTr("You are already a member of this chat."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -184,7 +189,7 @@ Page {
|
|||
}
|
||||
|
||||
AppNotification {
|
||||
id: overviewPageNotification
|
||||
id: appNotification
|
||||
}
|
||||
|
||||
Column {
|
||||
|
|
|
@ -405,8 +405,11 @@ void ChatListModel::addVisibleChat(ChatData *chat)
|
|||
chatIndexMap.insert(chatList.at(i)->chatId, i);
|
||||
}
|
||||
endInsertRows();
|
||||
if (this->tdLibWrapper->getJoinChatRequested()) {
|
||||
this->tdLibWrapper->registerJoinChat();
|
||||
emit chatJoined(chat->chatId, chat->chatData.value("title").toString());
|
||||
}
|
||||
}
|
||||
|
||||
void ChatListModel::updateChatVisibility(const TDLibWrapper::Group *group)
|
||||
{
|
||||
|
|
|
@ -117,6 +117,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren
|
|||
handlers.insert("updateChatPermissions", &TDLibReceiver::processUpdateChatPermissions);
|
||||
handlers.insert("updateChatTitle", &TDLibReceiver::processUpdateChatTitle);
|
||||
handlers.insert("users", &TDLibReceiver::processUsers);
|
||||
handlers.insert("error", &TDLibReceiver::processError);
|
||||
}
|
||||
|
||||
void TDLibReceiver::setActive(bool active)
|
||||
|
@ -501,3 +502,9 @@ void TDLibReceiver::processUsers(const QVariantMap &receivedInformation)
|
|||
LOG("Received Users");
|
||||
emit usersReceived(receivedInformation.value(EXTRA).toString(), receivedInformation.value("user_ids").toList(), receivedInformation.value("total_count").toInt());
|
||||
}
|
||||
|
||||
void TDLibReceiver::processError(const QVariantMap &receivedInformation)
|
||||
{
|
||||
LOG("Received an error");
|
||||
emit errorReceived(receivedInformation.value("code").toInt(), receivedInformation.value("message").toString());
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ signals:
|
|||
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &chatPermissions);
|
||||
void chatTitleUpdated(const QString &chatId, const QString &title);
|
||||
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
|
||||
void errorReceived(const int code, const QString &message);
|
||||
private:
|
||||
typedef void (TDLibReceiver::*Handler)(const QVariantMap &);
|
||||
|
||||
|
@ -136,6 +137,7 @@ private:
|
|||
void processUpdateChatPermissions(const QVariantMap &receivedInformation);
|
||||
void processUpdateChatTitle(const QVariantMap &receivedInformation);
|
||||
void processUsers(const QVariantMap &receivedInformation);
|
||||
void processError(const QVariantMap &receivedInformation);
|
||||
};
|
||||
|
||||
#endif // TDLIBRECEIVER_H
|
||||
|
|
|
@ -112,6 +112,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, QObject *parent) : QObject(
|
|||
connect(this->tdLibReceiver, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)), this, SIGNAL(chatPermissionsUpdated(QString, QVariantMap)));
|
||||
connect(this->tdLibReceiver, SIGNAL(chatTitleUpdated(QString, QString)), this, SIGNAL(chatTitleUpdated(QString, QString)));
|
||||
connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int)));
|
||||
connect(this->tdLibReceiver, SIGNAL(errorReceived(int, QString)), this, SIGNAL(errorReceived(int, QString)));
|
||||
|
||||
connect(&emojiSearchWorker, SIGNAL(searchCompleted(QString, QVariantList)), this, SLOT(handleEmojiSearchCompleted(QString, QVariantList)));
|
||||
|
||||
|
@ -250,6 +251,7 @@ void TDLibWrapper::joinChat(const QString &chatId)
|
|||
QVariantMap requestObject;
|
||||
requestObject.insert(_TYPE, "joinChat");
|
||||
requestObject.insert("chat_id", chatId);
|
||||
this->joinChatRequested = true;
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
|
@ -741,6 +743,7 @@ void TDLibWrapper::joinChatByInviteLink(const QString &inviteLink)
|
|||
QVariantMap requestObject;
|
||||
requestObject.insert(_TYPE, "joinChatByInviteLink");
|
||||
requestObject.insert("invite_link", inviteLink);
|
||||
this->joinChatRequested = true;
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
|
@ -872,6 +875,16 @@ void TDLibWrapper::controlScreenSaver(bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
bool TDLibWrapper::getJoinChatRequested()
|
||||
{
|
||||
return this->joinChatRequested;
|
||||
}
|
||||
|
||||
void TDLibWrapper::registerJoinChat()
|
||||
{
|
||||
this->joinChatRequested = false;
|
||||
}
|
||||
|
||||
DBusAdaptor *TDLibWrapper::getDBusAdaptor()
|
||||
{
|
||||
return this->dbusInterface->getDBusAdaptor();
|
||||
|
|
|
@ -103,6 +103,8 @@ public:
|
|||
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
|
||||
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
|
||||
Q_INVOKABLE void controlScreenSaver(bool enabled);
|
||||
Q_INVOKABLE bool getJoinChatRequested();
|
||||
Q_INVOKABLE void registerJoinChat();
|
||||
|
||||
DBusAdaptor *getDBusAdaptor();
|
||||
|
||||
|
@ -215,6 +217,7 @@ signals:
|
|||
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &permissions);
|
||||
void chatTitleUpdated(const QString &chatId, const QString &title);
|
||||
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
|
||||
void errorReceived(const int code, const QString &message);
|
||||
|
||||
public slots:
|
||||
void handleVersionDetected(const QString &version);
|
||||
|
@ -261,6 +264,7 @@ private:
|
|||
EmojiSearchWorker emojiSearchWorker;
|
||||
|
||||
QString activeChatSearchName;
|
||||
bool joinChatRequested;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>Sie haben noch keine Chats.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation>Sie sind bereits Mitglied dieses Chats.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1448,5 +1452,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation>hat ein selbstzerstörendes Bild gesendet, das abgelaufen ist</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation>Konnte Benutzer %1 nicht finden</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>No hay todavía ninguna charla.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1442,5 +1446,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation>envió un vídeo autodestructivo que está caducado</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -840,6 +840,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>Sinulla ei ole vielä keskusteluja.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1449,5 +1453,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1442,5 +1446,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>Loading chat list...</source>
|
||||
<translation>Carica lista chat...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1448,5 +1452,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation>ha inviato un video effimero già scaduto</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation type="unfinished">Nie masz jeszcze żadnych czatów.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1454,5 +1458,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>Тут пока ничего нет</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1454,5 +1458,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>Du har inga chattar än.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1448,5 +1452,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation>你尚无任何对话。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1442,5 +1446,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -839,6 +839,10 @@
|
|||
<source>You don't have any chats yet.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You are already a member of this chat.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PollCreationPage</name>
|
||||
|
@ -1442,5 +1446,9 @@
|
|||
<source>sent a self-destructing video that is expired</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unable to find user %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
Loading…
Reference in a new issue