Compare commits

...

7 commits

Author SHA1 Message Date
6616660849 Merge pull request 'upstream_fixes_28112023' (#15) from upstream_fixes_28112023 into master
Reviewed-on: #15
2023-11-29 02:10:12 +03:00
Sebastian Wolf
1cddb7a766 Open URLs without prefix 2023-11-28 20:34:53 +03:00
Sebastian Wolf
ec972d7edc More tweaks for reactions 2023-11-28 20:34:51 +03:00
Sebastian Wolf
1c9fcac9cd Animate new reaction button 2023-11-28 20:34:46 +03:00
Sebastian Wolf
497bd78e58 Tweak reactions again... 2023-11-28 20:34:45 +03:00
Peter G
d522536604 [Trivial]: Don't own bindir (#534)
* [Trivial]: Don't own bindir

This may seem like nitpicking, but the package should not own /usr/bin

* Update rpm/harbour-fernschreiber.spec

Co-authored-by: Sebastian Wolf <sebastian@ygriega.de>

---------

Co-authored-by: nephros <nemo@pgxperiiia10>
Co-authored-by: Sebastian Wolf <sebastian@ygriega.de>
2023-11-28 20:34:20 +03:00
Slava Monich
580fad2d22 Allow to remove a reaction (#536) 2023-11-28 20:33:58 +03:00
6 changed files with 125 additions and 23 deletions

View file

@ -115,6 +115,19 @@ ListItem {
return interactionText; return interactionText;
} }
function openReactions() {
if (messageListItem.chatReactions) {
Debug.log("Using chat reactions")
messageListItem.messageReactions = chatReactions
showItemCompletelyTimer.requestedIndex = index;
showItemCompletelyTimer.start();
} else {
Debug.log("Obtaining message reactions")
tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId);
}
selectReactionBubble.visible = false;
}
onClicked: { onClicked: {
if (messageListItem.precalculatedValues.pageIsSelecting) { if (messageListItem.precalculatedValues.pageIsSelecting) {
page.toggleMessageSelection(myMessage); page.toggleMessageSelection(myMessage);
@ -132,20 +145,17 @@ ListItem {
if (messageListItem.messageReactions) { if (messageListItem.messageReactions) {
messageListItem.messageReactions = null; messageListItem.messageReactions = null;
selectReactionBubble.visible = false;
} else {
if (messageListItem.chatReactions) {
selectReactionBubble.visible = !selectReactionBubble.visible;
}
} }
} }
} }
onDoubleClicked: { onDoubleClicked: {
if (messageListItem.chatReactions) { openReactions();
Debug.log("Using chat reactions")
messageListItem.messageReactions = chatReactions
showItemCompletelyTimer.requestedIndex = index;
showItemCompletelyTimer.start();
} else {
Debug.log("Obtaining message reactions")
tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId);
}
} }
onPressAndHold: { onPressAndHold: {
@ -652,12 +662,50 @@ ListItem {
textFormat: Text.StyledText textFormat: Text.StyledText
maximumLineCount: 1 maximumLineCount: 1
elide: Text.ElideRight elide: Text.ElideRight
MouseArea {
anchors.fill: parent
onClicked: {
if (messageListItem.messageReactions) {
messageListItem.messageReactions = null;
selectReactionBubble.visible = false;
} else {
openReactions();
}
}
}
} }
} }
} }
} }
Rectangle {
id: selectReactionBubble
visible: false
opacity: visible ? 0.5 : 0.0
Behavior on opacity { NumberAnimation {} }
anchors {
horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right
verticalCenter: messageBackground.verticalCenter
}
height: Theme.itemSizeExtraSmall
width: Theme.itemSizeExtraSmall
color: Theme.primaryColor
radius: parent.width / 2
}
IconButton {
id: selectReactionButton
visible: selectReactionBubble.visible
opacity: visible ? 1.0 : 0.0
Behavior on opacity { NumberAnimation {} }
icon.source: "image://theme/icon-s-favorite"
anchors.centerIn: selectReactionBubble
onClicked: {
openReactions();
}
}
} }
} }
@ -666,7 +714,7 @@ ListItem {
id: reactionsColumn id: reactionsColumn
width: parent.width - ( 2 * Theme.horizontalPageMargin ) width: parent.width - ( 2 * Theme.horizontalPageMargin )
anchors.top: messageTextRow.bottom anchors.top: messageTextRow.bottom
anchors.topMargin: Theme.paddingSmall anchors.topMargin: Theme.paddingMedium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
visible: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? true : false ) : false visible: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? true : false ) : false
opacity: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? 1 : 0 ) : 0 opacity: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? 1 : 0 ) : 0
@ -675,7 +723,7 @@ ListItem {
Flickable { Flickable {
width: parent.width width: parent.width
height: reactionsResultRow.height + Theme.paddingSmall height: reactionsResultRow.height + 2 * Theme.paddingMedium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
contentWidth: reactionsResultRow.width contentWidth: reactionsResultRow.width
clip: true clip: true
@ -691,13 +739,13 @@ ListItem {
Row { Row {
id: singleReactionRow id: singleReactionRow
spacing: Theme.paddingSmall spacing: Theme.paddingMedium
Image { Image {
id: emojiPicture id: emojiPicture
source: Emoji.getEmojiPath(modelData) source: Emoji.getEmojiPath(modelData)
width: status === Image.Ready ? Theme.fontSizeLarge : 0 width: status === Image.Ready ? Theme.fontSizeExtraLarge : 0
height: Theme.fontSizeLarge height: Theme.fontSizeExtraLarge
} }
} }
@ -705,12 +753,26 @@ ListItem {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
tdLibWrapper.setMessageReaction(messageListItem.chatId, messageListItem.messageId, modelData); for (var i = 0; i < reactions.length; i++) {
messageListItem.messageReactions = null; var reaction = reactions[i]
var reactionText = reaction.reaction ? reaction.reaction : (reaction.type && reaction.type.emoji) ? reaction.type.emoji : ""
if (reactionText === modelData) {
if (reaction.is_chosen) {
// Reaction is already selected
tdLibWrapper.removeMessageReaction(chatId, messageId, reactionText)
messageReactions = null
return
}
break
}
}
// Reaction is not yet selected
tdLibWrapper.addMessageReaction(chatId, messageId, modelData)
messageReactions = null
selectReactionBubble.visible = false
} }
} }
} }
} }
} }
} }

View file

@ -448,7 +448,12 @@ function handleLink(link) {
} else if (link.indexOf(tMePrefixHttp) === 0) { } else if (link.indexOf(tMePrefixHttp) === 0) {
handleTMeLink(link, tMePrefixHttp); handleTMeLink(link, tMePrefixHttp);
} else { } else {
Qt.openUrlExternally(link); Debug.log("Trying to open URL externally: " + link)
if (link.indexOf("://") === -1) {
Qt.openUrlExternally("https://" + link)
} else {
Qt.openUrlExternally(link);
}
} }
} }
} }

View file

@ -576,6 +576,9 @@ Page {
onSponsoredMessageReceived: { onSponsoredMessageReceived: {
chatPage.containsSponsoredMessages = true; chatPage.containsSponsoredMessages = true;
} }
onReactionsUpdated: {
availableReactions = tdLibWrapper.getChatReactions(chatInformation.id);
}
} }
Connections { Connections {
@ -610,6 +613,8 @@ Page {
chatViewCooldownTimer.restart(); chatViewCooldownTimer.restart();
chatViewStartupReadTimer.restart(); chatViewStartupReadTimer.restart();
/*
// Double-tap for reactions is currently disabled, let's see if we'll ever need it again
var remainingDoubleTapHints = appSettings.remainingDoubleTapHints; var remainingDoubleTapHints = appSettings.remainingDoubleTapHints;
Debug.log("Remaining double tap hints: " + remainingDoubleTapHints); Debug.log("Remaining double tap hints: " + remainingDoubleTapHints);
if (remainingDoubleTapHints > 0) { if (remainingDoubleTapHints > 0) {
@ -618,6 +623,8 @@ Page {
tapHintLabel.visible = true; tapHintLabel.visible = true;
appSettings.remainingDoubleTapHints = remainingDoubleTapHints - 1; appSettings.remainingDoubleTapHints = remainingDoubleTapHints - 1;
} }
*/
} }
onNewMessageReceived: { onNewMessageReceived: {
if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender_id.user_id === chatPage.myUserId) { if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender_id.user_id === chatPage.myUserId) {

View file

@ -12,7 +12,7 @@ Name: harbour-fernschreiber
Summary: Fernschreiber is a Telegram client for Aurora OS Summary: Fernschreiber is a Telegram client for Aurora OS
Version: 0.17 Version: 0.17
Release: 7 Release: 8
Group: Qt/Qt Group: Qt/Qt
License: LICENSE License: LICENSE
URL: http://werkwolf.eu/ URL: http://werkwolf.eu/
@ -70,7 +70,7 @@ desktop-file-install --delete-original \
%files %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
%{_bindir} %{_bindir}/%{name}
%{_datadir}/%{name} %{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop %{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png %{_datadir}/icons/hicolor/*/apps/%{name}.png

View file

@ -1462,9 +1462,8 @@ void TDLibWrapper::getPageSource(const QString &address)
connect(reply, SIGNAL(finished()), this, SLOT(handleGetPageSourceFinished())); connect(reply, SIGNAL(finished()), this, SLOT(handleGetPageSourceFinished()));
} }
void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction) void TDLibWrapper::addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction)
{ {
LOG("Set message reaction" << chatId << messageId << reaction);
QVariantMap requestObject; QVariantMap requestObject;
requestObject.insert(CHAT_ID, chatId); requestObject.insert(CHAT_ID, chatId);
requestObject.insert(MESSAGE_ID, messageId); requestObject.insert(MESSAGE_ID, messageId);
@ -1479,9 +1478,35 @@ void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, con
reactionType.insert(EMOJI, reaction); reactionType.insert(EMOJI, reaction);
requestObject.insert(REACTION_TYPE, reactionType); requestObject.insert(REACTION_TYPE, reactionType);
requestObject.insert(_TYPE, "addMessageReaction"); requestObject.insert(_TYPE, "addMessageReaction");
LOG("Add message reaction" << chatId << messageId << reaction);
} else { } else {
requestObject.insert("reaction", reaction); requestObject.insert("reaction", reaction);
requestObject.insert(_TYPE, "setMessageReaction"); requestObject.insert(_TYPE, "setMessageReaction");
LOG("Toggle message reaction" << chatId << messageId << reaction);
}
this->sendRequest(requestObject);
}
void TDLibWrapper::removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction)
{
QVariantMap requestObject;
requestObject.insert(CHAT_ID, chatId);
requestObject.insert(MESSAGE_ID, messageId);
if (versionNumber > VERSION_NUMBER(1,8,5)) {
// "reaction_type": {
// "@type": "reactionTypeEmoji",
// "emoji": "..."
// }
QVariantMap reactionType;
reactionType.insert(_TYPE, REACTION_TYPE_EMOJI);
reactionType.insert(EMOJI, reaction);
requestObject.insert(REACTION_TYPE, reactionType);
requestObject.insert(_TYPE, "removeMessageReaction");
LOG("Remove message reaction" << chatId << messageId << reaction);
} else {
requestObject.insert("reaction", reaction);
requestObject.insert(_TYPE, "setMessageReaction");
LOG("Toggle message reaction" << chatId << messageId << reaction);
} }
this->sendRequest(requestObject); this->sendRequest(requestObject);
} }
@ -2068,6 +2093,7 @@ void TDLibWrapper::handleActiveEmojiReactionsUpdated(const QStringList& emojis)
if (activeEmojiReactions != emojis) { if (activeEmojiReactions != emojis) {
activeEmojiReactions = emojis; activeEmojiReactions = emojis;
LOG(emojis.count() << "reaction(s) available"); LOG(emojis.count() << "reaction(s) available");
emit reactionsUpdated();
} }
} }

View file

@ -249,7 +249,8 @@ public:
Q_INVOKABLE void terminateSession(const QString &sessionId); Q_INVOKABLE void terminateSession(const QString &sessionId);
Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId); Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId);
Q_INVOKABLE void getPageSource(const QString &address); Q_INVOKABLE void getPageSource(const QString &address);
Q_INVOKABLE void setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction); Q_INVOKABLE void addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
Q_INVOKABLE void removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
Q_INVOKABLE void setNetworkType(NetworkType networkType); Q_INVOKABLE void setNetworkType(NetworkType networkType);
Q_INVOKABLE void setInactiveSessionTtl(int days); Q_INVOKABLE void setInactiveSessionTtl(int days);
@ -338,6 +339,7 @@ signals:
void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount);
void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount);
void tgUrlFound(const QString &tgUrl); void tgUrlFound(const QString &tgUrl);
void reactionsUpdated();
public slots: public slots:
void handleVersionDetected(const QString &version); void handleVersionDetected(const QString &version);