Skip to content

Commit 13807b7

Browse files
authored
Merge pull request #1644 from squidowl/add-reactions
Add reactions
2 parents 02c93b8 + 18fbdb0 commit 13807b7

28 files changed

+828
-143
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Added:
66
- Emoji and command picker entries are now clickable and insert the selected completion directly into the input.
77
- Multi-line send support (uses IRCv3 [`multiline`](https://ircv3.net/specs/extensions/multiline) when available)
88
- Typing indicator support (uses IRCv3 [`typing`](https://ircv3.net/specs/client-tags/typing))
9+
- Add emoji reactions for supported servers (uses IRCv3 [`react`](https://ircv3.net/specs/client-tags/react.html))
910

1011
Fixed:
1112

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Halloy is also available from [Flathub](https://flathub.org/apps/org.squidowl.ha
3939
* [msgid](https://ircv3.net/specs/extensions/message-ids)
4040
* [multi-prefix](https://ircv3.net/specs/extensions/multi-prefix)
4141
* [multiline](https://ircv3.net/specs/extensions/multiline)
42+
* [react](https://ircv3.net/specs/client-tags/react.html)
4243
* [read-marker](https://ircv3.net/specs/extensions/read-marker)
4344
* [sasl-3.1](https://ircv3.net/specs/extensions/sasl-3.1)
4445
* [server-time](https://ircv3.net/specs/extensions/server-time)

assets/fontello/config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@
257257
"css": "menu-1",
258258
"code": 59422,
259259
"src": "typicons"
260+
},
261+
{
262+
"uid": "70370693ada58ef0a60fa0984fe8d52a",
263+
"css": "plus-1",
264+
"code": 59424,
265+
"src": "entypo"
260266
}
261267
]
262268
}

book/src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [msgid](https://ircv3.net/specs/extensions/message-ids)
2323
* [multi-prefix](https://ircv3.net/specs/extensions/multi-prefix)
2424
* [multiline](https://ircv3.net/specs/extensions/multiline)
25+
* [react](https://ircv3.net/specs/client-tags/react.html)
2526
* [read-marker](https://ircv3.net/specs/extensions/read-marker)
2627
* [sasl-3.1](https://ircv3.net/specs/extensions/sasl-3.1)
2728
* [server-time](https://ircv3.net/specs/extensions/server-time)

data/src/client.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,15 @@ impl Client {
38143814

38153815
fn can_send_typing(&self) -> bool {
38163816
self.capabilities.acknowledged(Capability::MessageTags)
3817-
&& !isupport::is_client_only_tag_denied(&self.isupport, "typing")
3817+
&& isupport::is_client_tag_allowed(&self.isupport, "typing")
3818+
}
3819+
3820+
fn can_send_reactions(&self) -> bool {
3821+
self.capabilities.acknowledged(Capability::MessageTags)
3822+
&& isupport::is_client_tag_allowed(&self.isupport, "draft/react")
3823+
&& isupport::is_client_tag_allowed(&self.isupport, "draft/unreact")
3824+
&& (isupport::is_client_tag_allowed(&self.isupport, "draft/reply")
3825+
|| isupport::is_client_tag_allowed(&self.isupport, "reply"))
38183826
}
38193827

38203828
pub fn is_channel(&self, target: &str) -> bool {
@@ -4301,6 +4309,10 @@ impl Map {
43014309
self.client(server).is_some_and(Client::supports_typing)
43024310
}
43034311

4312+
pub fn get_server_can_send_reactions(&self, server: &Server) -> bool {
4313+
self.client(server).is_some_and(Client::can_send_reactions)
4314+
}
4315+
43044316
pub fn get_server_can_send_typing(&self, server: &Server) -> bool {
43054317
self.client(server).is_some_and(Client::can_send_typing)
43064318
}

data/src/command.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::collections::HashMap;
23
use std::str::FromStr;
34

@@ -47,12 +48,12 @@ pub enum Irc {
4748
React {
4849
target: String,
4950
msgid: message::Id,
50-
text: String,
51+
text: Cow<'static, str>,
5152
},
5253
Unreact {
5354
target: String,
5455
msgid: message::Id,
55-
text: String,
56+
text: Cow<'static, str>,
5657
},
5758
Me(String, String),
5859
Whois(Option<String>, String),
@@ -1263,12 +1264,12 @@ impl TryFrom<Irc> for proto::Message {
12631264
Irc::React { msgid, text, .. } => tags![
12641265
"+reply" => msgid.to_string(),
12651266
"+draft/reply" => msgid.to_string(),
1266-
"+draft/react" => text,
1267+
"+draft/react" => text.as_ref(),
12671268
],
12681269
Irc::Unreact { msgid, text, .. } => tags![
12691270
"+reply" => msgid.to_string(),
12701271
"+draft/reply" => msgid.to_string(),
1271-
"+draft/unreact" => text,
1272+
"+draft/unreact" => text.as_ref(),
12721273
],
12731274
Irc::Typing { value, .. } => tags!["+typing" => value.as_str()],
12741275
_ => tags![],

data/src/history.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,9 @@ pub fn insert_message(
10091009
if let Some(index) = replace_at {
10101010
if messages[index].server_time == message.server_time {
10111011
if has_matching_content(&messages[index], &message, false) {
1012-
messages[index].id = message.id;
1012+
if let Some(id) = message.id {
1013+
messages[index].id = Some(id);
1014+
}
10131015
messages[index].received_at = message.received_at;
10141016
} else {
10151017
messages[index] = message;

data/src/isupport.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,3 +1339,10 @@ pub fn is_client_only_tag_denied(
13391339

13401340
tag_denied || (has_deny_all && !tag_allowed)
13411341
}
1342+
1343+
pub fn is_client_tag_allowed(
1344+
isupport: &HashMap<Kind, Parameter>,
1345+
tag: &str,
1346+
) -> bool {
1347+
!is_client_only_tag_denied(isupport, tag)
1348+
}

fonts/halloy-icons.ttf

148 Bytes
Binary file not shown.

src/buffer.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::path::PathBuf;
23

34
use chrono::{DateTime, Utc};
@@ -205,6 +206,36 @@ impl Buffer {
205206
}
206207
}
207208

209+
pub fn reaction_message(
210+
&self,
211+
msgid: message::Id,
212+
text: Cow<'static, str>,
213+
unreact: bool,
214+
) -> Option<Message> {
215+
match self {
216+
Buffer::Channel(_) => Some(Message::Channel(
217+
channel::Message::ScrollView(if unreact {
218+
scroll_view::Message::Unreacted { msgid, text }
219+
} else {
220+
scroll_view::Message::Reacted { msgid, text }
221+
}),
222+
)),
223+
Buffer::Query(_) => {
224+
Some(Message::Query(query::Message::ScrollView(if unreact {
225+
scroll_view::Message::Unreacted { msgid, text }
226+
} else {
227+
scroll_view::Message::Reacted { msgid, text }
228+
})))
229+
}
230+
Buffer::Empty
231+
| Buffer::Server(_)
232+
| Buffer::FileTransfers(_)
233+
| Buffer::Logs(_)
234+
| Buffer::Highlights(_)
235+
| Buffer::ChannelDiscovery(_) => None,
236+
}
237+
}
238+
208239
pub fn update(
209240
&mut self,
210241
message: Message,

0 commit comments

Comments
 (0)