Skip to content

armgit / ente

Public Imported from GitHub
0

๐Ÿ’š End-to-end encrypted cloud for everything.

Add Space message emoji picker and reaction handling

Anand Baburajanf70475287111
diff --git a/rust/bindings/wasm/space/src/space.rs b/rust/bindings/wasm/space/src/space.rs
index 35e173beff..6773b52b5c 100644
--- a/rust/bindings/wasm/space/src/space.rs
+++ b/rust/bindings/wasm/space/src/space.rs
@@ -267,6 +267,7 @@ pub struct MessageResponse {
reply_message_id: Option<String>,
liked: bool,
viewer_liked: bool,
+ reaction: Option<String>,
is_deleted: bool,
created_at: String,
updated_at: String,
@@ -300,6 +301,7 @@ struct MessageConversationActivity {
outgoing: bool,
message_id: Option<String>,
text: Option<String>,
+ reaction: Option<String>,
post_id: Option<i64>,
reply_object_key: Option<String>,
post_space_id: Option<String>,
@@ -686,6 +688,14 @@ impl From<ente_space::Message> for MessageResponse {
(String::new(), None, false, true)
}
};
+ let reaction = message.reaction.unwrap_or_else(|error| {
+ log::warn!(
+ "Space message {} reaction is unavailable: {}",
+ message.message_id,
+ ente_core::error::chain(&error)
+ );
+ None
+ });
Self {
message_id: message.message_id,
kind: message.kind,
@@ -695,6 +705,7 @@ impl From<ente_space::Message> for MessageResponse {
reply_post_id: message.reply_post_id,
reply_object_key,
reply_message_id: message.reply_message_id,
+ reaction,
liked: message.liked,
viewer_liked: message.viewer_liked,
is_deleted,
@@ -719,7 +730,16 @@ impl From<ente_space::MessageActivity> for MessageConversationActivity {
(None, None, true)
}
};
+ let reaction = activity.reaction.unwrap_or_else(|error| {
+ log::warn!(
+ "Space conversation activity {} reaction is unavailable: {}",
+ activity.id,
+ ente_core::error::chain(&error)
+ );
+ None
+ });
Self {
+ reaction,
id: activity.id,
activity_type: activity.activity_type,
kind: activity.kind,
@@ -1258,6 +1278,20 @@ impl SpaceAccountCtxHandle {
.map_err(Into::into)
}
+ #[wasm_bindgen(js_name = setMessageReaction)]
+ pub async fn set_message_reaction(
+ &self,
+ space_id: String,
+ sender_space_id: String,
+ message_id: String,
+ emoji: Option<String>,
+ ) -> Result<(), Error> {
+ self.inner
+ .set_message_reaction(&space_id, &sender_space_id, &message_id, emoji.as_deref())
+ .await
+ .map_err(Into::into)
+ }
+
#[wasm_bindgen(js_name = deleteMessage)]
pub async fn delete_message(&self, space_id: String, message_id: String) -> Result<(), Error> {
self.inner
diff --git a/rust/crates/space/src/client/messages.rs b/rust/crates/space/src/client/messages.rs
index a187e8e0dc..82d9c6c0ef 100644
--- a/rust/crates/space/src/client/messages.rs
+++ b/rust/crates/space/src/client/messages.rs
@@ -114,7 +114,21 @@ impl AccountSpaceCtx {
})
};
let content = retain_content_error(content)?;
+ let reaction = if message.is_deleted {
+ Ok(None)
+ } else {
+ retain_content_error(
+ self.open_message_reaction(
+ viewer_space_id,
+ &message.message_id,
+ &message.encrypted_reaction,
+ message.liked,
+ )
+ .await,
+ )?
+ };
Ok(Message {
+ reaction,
message_id: message.message_id,
kind,
sender_space_id: message.sender_space_id,
@@ -204,7 +218,17 @@ impl AccountSpaceCtx {
})
};
let content = retain_content_error(content)?;
+ let reaction = retain_content_error(
+ self.open_message_reaction(
+ viewer_space_id,
+ activity.message_id.as_deref().unwrap_or_default(),
+ &activity.encrypted_reaction,
+ activity.activity_type == "message_like",
+ )
+ .await,
+ )?;
Ok(MessageActivity {
+ reaction,
id: activity.id,
activity_type: activity.activity_type,
kind,
diff --git a/rust/crates/space/src/client/mod.rs b/rust/crates/space/src/client/mod.rs
index 24c15520fe..a13bee31af 100644
--- a/rust/crates/space/src/client/mod.rs
+++ b/rust/crates/space/src/client/mod.rs
@@ -7,6 +7,7 @@ mod media;
mod messages;
mod posts;
mod profiles;
+mod reactions;
#[cfg(test)]
mod test_support;
diff --git a/rust/crates/space/src/client/reactions.rs b/rust/crates/space/src/client/reactions.rs
new file mode 100644
index 0000000000..27c456a066
--- /dev/null
+++ b/rust/crates/space/src/client/reactions.rs
@@ -0,0 +1,261 @@
+use super::AccountSpaceCtx;
+use crate::crypto::{open_with_keypair, seal_with_public_key};
+use crate::error::{Error, Result};
+use ente_core::b64;
+use serde::{Deserialize, Serialize};
+
+const REACTION_PAYLOAD_BYTES: usize = 256;
+
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct ReactionPayload {
+ message_id: String,
+ emoji: String,
+}
+
+impl AccountSpaceCtx {
+ pub async fn set_message_reaction(
+ &self,
+ space_id: &str,
+ sender_space_id: &str,
+ message_id: &str,
+ emoji: Option<&str>,
+ ) -> Result<()> {
+ if message_id.trim().is_empty() {
+ return Err(Error::InvalidInput("message id is required".into()));
+ }
+ let path = format!("/spaces/{space_id}/messages/{message_id}/reaction");
+ let Some(emoji) = emoji else {
+ self.api().delete(&path).send().await?.error_for_status()?;
+ return Ok(());
+ };
+ let payload = pack_reaction(message_id, emoji)?;
+ let identity = self.space_identity_for(space_id).await?;
+ let sender = self
+ .friend_actor_for_space(space_id, sender_space_id)
+ .await?;
+ let sender_cipher = seal_with_public_key(&payload, &b64::decode(&sender.public_key)?)?;
+ let recipient_cipher = seal_with_public_key(&payload, &identity.public_key)?;
+ self.api()
+ .put(&path)
+ .json(&serde_json::json!({
+ "senderEncryptedReaction": b64::encode(&sender_cipher),
+ "recipientEncryptedReaction": b64::encode(&recipient_cipher),
+ }))
+ .send()
+ .await?
+ .error_for_status()?;
+ Ok(())
+ }
+
+ pub(super) async fn open_message_reaction(
+ &self,
+ space_id: &str,
+ message_id: &str,
+ encrypted_reaction: &str,
+ liked: bool,
+ ) -> Result<Option<String>> {
+ if encrypted_reaction.is_empty() {
+ return Ok(liked.then(|| "โค๏ธ".to_owned()));
+ }
+ let identity = self.space_identity_for(space_id).await?;
+ let plaintext = open_with_keypair(
+ &b64::decode(encrypted_reaction)?,
+ &identity.public_key,
+ &identity.secret_key,
+ )?;
+ Ok(Some(unpack_reaction(message_id, &plaintext)?))
+ }
+}
+
+fn pack_reaction(message_id: &str, emoji: &str) -> Result<Vec<u8>> {
+ validate_emoji(emoji)?;
+ let mut payload = serde_json::to_vec(&ReactionPayload {
+ message_id: message_id.to_owned(),
+ emoji: emoji.to_owned(),
+ })
+ .map_err(|_| Error::InvalidInput("invalid reaction".into()))?;
+ if payload.len() > REACTION_PAYLOAD_BYTES {
+ return Err(Error::InvalidInput("reaction is too large".into()));
+ }
+ payload.resize(REACTION_PAYLOAD_BYTES, b' ');
+ Ok(payload)
+}
+
+fn unpack_reaction(message_id: &str, plaintext: &[u8]) -> Result<String> {
+ if plaintext.len() != REACTION_PAYLOAD_BYTES {
+ return Err(Error::InvalidInput("invalid reaction size".into()));
+ }
+ let payload: ReactionPayload = serde_json::from_slice(plaintext)
+ .map_err(|_| Error::InvalidInput("invalid reaction".into()))?;
+ if payload.message_id != message_id {
+ return Err(Error::InvalidInput(
+ "reaction belongs to another message".into(),
+ ));
+ }
+ validate_emoji(&payload.emoji)?;
+ Ok(payload.emoji)
+}
+
+fn validate_emoji(emoji: &str) -> Result<()> {
+ if emoji.is_empty() || emoji.len() > 64 || !is_emoji_sequence(emoji) {
+ return Err(Error::InvalidInput("a single emoji is required".into()));
+ }
+ Ok(())
+}
+
+fn is_emoji_sequence(emoji: &str) -> bool {
+ let mut chars = emoji.chars().peekable();
+ let Some(first) = chars.next() else {
+ return false;
+ };
+ if ('\u{1f1e6}'..='\u{1f1ff}').contains(&first) {
+ return chars
+ .next()
+ .is_some_and(|c| ('\u{1f1e6}'..='\u{1f1ff}').contains(&c))
+ && chars.next().is_none();
+ }
+ if first.is_ascii_digit() || first == '#' || first == '*' {
+ if chars.peek() == Some(&'\u{fe0f}') {
+ chars.next();
+ }
+ return chars.next() == Some('\u{20e3}') && chars.next().is_none();
+ }
+ let mut base = first;
+ loop {
+ if !matches!(base as u32, 0xa9 | 0xae | 0x203c | 0x2049 | 0x2122 | 0x2139 | 0x2194..=0x21ff | 0x2300..=0x23ff | 0x25a0..=0x27bf | 0x2934..=0x2935 | 0x2b00..=0x2bff | 0x3030 | 0x303d | 0x3297 | 0x3299 | 0x1f000..=0x1faff)
+ || matches!(base as u32, 0x1f1e6..=0x1f1ff | 0x1f3fb..=0x1f3ff)
+ {
+ return false;
+ }
+ if chars.peek() == Some(&'\u{fe0f}') {
+ chars.next();
+ }
+ if chars
+ .peek()
+ .is_some_and(|c| ('\u{1f3fb}'..='\u{1f3ff}').contains(c))
+ {
+ chars.next();
+ }
+ match chars.next() {
+ None => return true,
+ Some('\u{200d}') => match chars.next() {
+ Some(next) => base = next,
+ None => return false,
+ },
+ _ => return false,
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::crypto::generate_keypair;
+
+ #[tokio::test]
+ async fn reaction_endpoint_encrypts_for_both_participants_and_removes() {
+ use super::super::test_support::{test_account_ctx, test_public_key};
+ use mockito::Server;
+ use serde_json::json;
+ use std::sync::{Arc, Mutex};
+
+ let mut server = Server::new_async().await;
+ let recipient = test_account_ctx(&server.url());
+ let sender = test_account_ctx(&server.url());
+ let friends = server.mock("GET", "/spaces/space_owner_main/friends")
+ .with_status(200)
+ .with_body(json!([{
+ "friend": { "spaceId": "space_friend", "spaceSlug": "friend", "publicKey": b64::encode(&test_public_key(&sender)), "keyVersion": 1 },
+ "shareKeyVersion": 1, "createdAt": "2026-09-29T00:00:00Z"
+ }]).to_string()).create_async().await;
+ let captured = Arc::new(Mutex::new(serde_json::Value::Null));
+ let captured_request = captured.clone();
+ let put = server
+ .mock(
+ "PUT",
+ "/spaces/space_owner_main/messages/wmsg_test/reaction",
+ )
+ .match_header("x-space-session-token", "space-session-token")
+ .with_status(200)
+ .with_body_from_request(move |request| {
+ *captured_request.lock().unwrap() =
+ serde_json::from_slice(request.body().unwrap()).unwrap();
+ b"{\"liked\":true}".to_vec()
+ })
+ .create_async()
+ .await;
+ recipient
+ .set_message_reaction("space_owner_main", "space_friend", "wmsg_test", Some("๐Ÿ‘๐Ÿฝ"))
+ .await
+ .unwrap();
+ let body = captured.lock().unwrap().clone();
+ for (ctx, field) in [
+ (&sender, "senderEncryptedReaction"),
+ (&recipient, "recipientEncryptedReaction"),
+ ] {
+ let cipher = body[field].as_str().unwrap();
+ assert_eq!(b64::decode(cipher).unwrap().len(), 304);
+ assert_eq!(
+ ctx.open_message_reaction("space_owner_main", "wmsg_test", cipher, true)
+ .await
+ .unwrap()
+ .as_deref(),
+ Some("๐Ÿ‘๐Ÿฝ")
+ );
+ }
+ assert_eq!(
+ recipient
+ .open_message_reaction("space_owner_main", "wmsg_test", "", true)
+ .await
+ .unwrap()
+ .as_deref(),
+ Some("โค๏ธ")
+ );
+ assert_eq!(
+ recipient
+ .open_message_reaction("space_owner_main", "wmsg_test", "", false)
+ .await
+ .unwrap(),
+ None
+ );
+ let delete = server
+ .mock(
+ "DELETE",
+ "/spaces/space_owner_main/messages/wmsg_test/reaction",
+ )
+ .match_header("x-space-session-token", "space-session-token")
+ .with_status(200)
+ .create_async()
+ .await;
+ recipient
+ .set_message_reaction("space_owner_main", "space_friend", "wmsg_test", None)
+ .await
+ .unwrap();
+ put.assert_async().await;
+ delete.assert_async().await;
+ friends.assert_async().await;
+ }
+
+ #[test]
+ fn reaction_is_padded_and_readable_only_with_participant_key() {
+ let (public, secret) = generate_keypair().unwrap();
+ let (other_public, other_secret) = generate_keypair().unwrap();
+ for emoji in ["โค๏ธ", "๐Ÿ‘๐Ÿฝ", "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ", "๐Ÿ‡ฎ๐Ÿ‡ณ", "1๏ธโƒฃ"] {
+ let packed = pack_reaction("wmsg_test", emoji).unwrap();
+ let cipher = seal_with_public_key(&packed, &public).unwrap();
+ assert_eq!(cipher.len(), 304);
+ assert!(open_with_keypair(&cipher, &other_public, &other_secret).is_err());
+ let opened = open_with_keypair(&cipher, &public, &secret).unwrap();
+ assert_eq!(unpack_reaction("wmsg_test", &opened).unwrap(), emoji);
+ assert!(unpack_reaction("wmsg_other", &opened).is_err());
+ }
+ }
+
+ #[test]
+ fn reaction_rejects_text_multiple_emojis_and_incomplete_sequences() {
+ for emoji in ["", "hello", "๐Ÿ˜€๐Ÿ˜€", "๐Ÿ‘\u{200d}", "๐Ÿฝ", "๐Ÿ‡ฎ", "1", "\n"] {
+ assert!(validate_emoji(emoji).is_err(), "{emoji:?}");
+ }
+ }
+}
diff --git a/rust/crates/space/src/client/tests.rs b/rust/crates/space/src/client/tests.rs
index 5245de86cd..2cab2c2beb 100644
--- a/rust/crates/space/src/client/tests.rs
+++ b/rust/crates/space/src/client/tests.rs
@@ -60,6 +60,7 @@ async fn message_thread_keeps_content_failures_local_to_each_message() {
sender_space_id: "space_friend".into(),
recipient_space_id: "space_owner_main".into(),
message_cipher: b64::encode(&encrypt_secretbox_payload(&key, plaintext).unwrap()),
+ encrypted_reaction: String::new(),
encrypted_message_key: encrypted_key.clone(),
text: String::new(),
reply_post_id: None,
@@ -70,11 +71,12 @@ async fn message_thread_keeps_content_failures_local_to_each_message() {
created_at: "2026-09-23T00:00:00Z".into(),
updated_at: "2026-09-23T00:00:00Z".into(),
};
- let readable = message(
+ let mut readable = message(
"readable",
"regular",
br#"{"version":1,"kind":"regular","text":"hello","replyObjectKey":"photo"}"#,
);
+ readable.encrypted_reaction = "invalid".into();
let poke = message(
"poke",
"regular",
@@ -105,6 +107,7 @@ async fn message_thread_keeps_content_failures_local_to_each_message() {
assert_eq!(opened.next_cursor, "next");
assert_eq!(opened.items.len(), 6);
assert_eq!(content(&opened.items[0]).text, "hello");
+ assert!(opened.items[0].reaction.is_err());
assert_eq!(
content(&opened.items[0]).reply_object_key.as_deref(),
Some("photo")
@@ -136,6 +139,7 @@ async fn unread_poke_uses_latest_activity_kind() {
sender_space_id: "space_friend".into(),
recipient_space_id: "space_owner_main".into(),
message_cipher: String::new(),
+ encrypted_reaction: String::new(),
encrypted_message_key: String::new(),
reply_message_id: None,
post_id: None,
@@ -185,6 +189,7 @@ async fn conversation_activities_open_content_and_preserve_server_kind() {
sender_space_id: "space_friend".into(),
recipient_space_id: "space_owner_main".into(),
message_cipher: b64::encode(&encrypt_secretbox_payload(&key, &plaintext).unwrap()),
+ encrypted_reaction: String::new(),
encrypted_message_key: encrypted_key.clone(),
reply_message_id: None,
post_id: None,
@@ -216,6 +221,7 @@ async fn conversation_activities_open_content_and_preserve_server_kind() {
sender_space_id: "space_friend".into(),
recipient_space_id: "space_owner_main".into(),
message_cipher: b64::encode(&encrypt_secretbox_payload(&key, b"not-json").unwrap()),
+ encrypted_reaction: String::new(),
encrypted_message_key: encrypted_key,
reply_message_id: None,
post_id: None,
diff --git a/rust/crates/space/src/models.rs b/rust/crates/space/src/models.rs
index 1a5610558e..a67bf45ec2 100644
--- a/rust/crates/space/src/models.rs
+++ b/rust/crates/space/src/models.rs
@@ -195,6 +195,7 @@ pub struct Message {
pub sender_space_id: String,
pub recipient_space_id: String,
pub content: Result<Option<MessageContent>>,
+ pub reaction: Result<Option<String>>,
pub reply_post_id: Option<i64>,
pub reply_message_id: Option<String>,
pub liked: bool,
@@ -221,6 +222,7 @@ pub struct MessageActivity {
pub outgoing: bool,
pub message_id: Option<String>,
pub content: Result<Option<MessageContent>>,
+ pub reaction: Result<Option<String>>,
pub post_id: Option<i64>,
pub post_space_id: Option<String>,
}
diff --git a/rust/crates/space/src/transport.rs b/rust/crates/space/src/transport.rs
index e20441789f..c2ae655a94 100644
--- a/rust/crates/space/src/transport.rs
+++ b/rust/crates/space/src/transport.rs
@@ -156,6 +156,8 @@ pub struct MessageResponse {
#[serde(default)]
pub encrypted_message_key: String,
#[serde(default)]
+ pub encrypted_reaction: String,
+ #[serde(default)]
pub text: String,
#[serde(default)]
pub reply_post_id: Option<i64>,
@@ -201,6 +203,8 @@ pub struct MessageConversationActivity {
#[serde(default)]
pub encrypted_message_key: String,
#[serde(default)]
+ pub encrypted_reaction: String,
+ #[serde(default)]
pub reply_message_id: Option<String>,
#[serde(default)]
pub post_id: Option<i64>,
diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsx
index bd6b9f13e3..ace078ebf3 100644
--- a/web/apps/space/src/components/HomeHeader.tsx
+++ b/web/apps/space/src/components/HomeHeader.tsx
@@ -218,7 +218,7 @@ export const SpaceHomeHeader: React.FC<SpaceHomeHeaderProps> = ({
<HugeiconsIcon
icon={BubbleChatIcon}
size={headerIconSize}
- strokeWidth={2.5}
+ strokeWidth={2.2}
/>
{showUnreadIndicator && (
<Box
diff --git a/web/apps/space/src/components/MessageReactionPicker.tsx b/web/apps/space/src/components/MessageReactionPicker.tsx
new file mode 100644
index 0000000000..175309c8a0
--- /dev/null
+++ b/web/apps/space/src/components/MessageReactionPicker.tsx
@@ -0,0 +1,523 @@
+import { Add01Icon, Search01Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box, Dialog, Popover, useMediaQuery } from "@mui/material";
+import { SpaceBottomSheetTransition } from "components/BottomSheetTransition";
+import {
+ emojiName,
+ emojiWithSkinTone,
+ quickReactionEmojis,
+ searchEmojis,
+ spaceEmojis,
+ type SpaceEmoji,
+} from "data/emojis";
+import { useBrowserBackClose } from "hooks/use-browser-back-close";
+import React from "react";
+import {
+ spaceControlBackground,
+ spaceDialogBackground,
+ spaceMenuBackground,
+ spaceMenuHover,
+ spaceSurface,
+ spaceSurfaceHover,
+ spaceText,
+ spaceTextMuted,
+} from "styles/colors";
+
+const emojiFont =
+ '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif';
+const buttonSx = {
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ borderRadius: "12px",
+ color: spaceText,
+ cursor: "pointer",
+ display: "flex",
+ flexShrink: 0,
+ fontFamily: emojiFont,
+ fontSize: 26,
+ height: 40,
+ justifyContent: "center",
+ lineHeight: 1,
+ p: 0,
+ width: 40,
+ "&:hover, &[aria-pressed=true]": { bgcolor: spaceMenuHover },
+ "&:focus-visible": {
+ outline: `2px solid ${spaceTextMuted}`,
+ outlineOffset: -2,
+ },
+};
+
+export const MessageQuickReactions: React.FC<{
+ selected?: string;
+ onSelect: (emoji: string) => void;
+ onMore: () => void;
+}> = ({ selected, onSelect, onMore }) => {
+ const groupRef = React.useRef<HTMLDivElement>(null);
+ React.useEffect(() => {
+ groupRef.current?.focus({ preventScroll: true });
+ }, []);
+
+ return (
+ <Box
+ ref={groupRef}
+ role="group"
+ aria-label="React to message"
+ tabIndex={-1}
+ sx={{
+ bgcolor: spaceMenuBackground,
+ borderRadius: "999px",
+ boxShadow:
+ "0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.32)",
+ display: "flex",
+ gap: "2px",
+ outline: 0,
+ p: "4px",
+ }}
+ >
+ {quickReactionEmojis(selected).map((emoji) => {
+ const name = emojiName(emoji);
+ const label =
+ selected == emoji ? `Remove ${name} reaction` : name;
+ return (
+ <Box
+ key={emoji}
+ component="button"
+ type="button"
+ aria-label={label}
+ aria-pressed={selected == emoji}
+ title={label}
+ onClick={() => onSelect(emoji)}
+ sx={{
+ ...buttonSx,
+ borderRadius: "50%",
+ fontSize: 22,
+ height: 36,
+ pt: "2px",
+ width: 36,
+ }}
+ >
+ {emoji}
+ </Box>
+ );
+ })}
+ <Box
+ component="button"
+ type="button"
+ aria-label="More reactions"
+ title="More reactions"
+ onClick={onMore}
+ sx={{
+ ...buttonSx,
+ bgcolor: spaceControlBackground,
+ borderRadius: "50%",
+ height: 36,
+ width: 36,
+ }}
+ >
+ <HugeiconsIcon icon={Add01Icon} size={20} strokeWidth={1.8} />
+ </Box>
+ </Box>
+ );
+};
+
+const skinTones = [
+ { tone: "", name: "Default" },
+ { tone: "๐Ÿป", name: "Light" },
+ { tone: "๐Ÿผ", name: "Medium light" },
+ { tone: "๐Ÿฝ", name: "Medium" },
+ { tone: "๐Ÿพ", name: "Medium dark" },
+ { tone: "๐Ÿฟ", name: "Dark" },
+];
+const tonePickerWidth = skinTones.length * 40 + 8;
+
+export const MessageReactionPicker: React.FC<{
+ selected?: string;
+ onSelect: (emoji: string) => void;
+ onClose: () => void;
+}> = ({ selected, onSelect, onClose }) => {
+ const isBottomSheet = useMediaQuery("(max-width: 599px)");
+ const resultsID = React.useId();
+ const [open, setOpen] = React.useState(true);
+ useBrowserBackClose({
+ open,
+ onClose: () => setOpen(false),
+ stateKey: "space-message-reaction-picker",
+ });
+ const [query, setQuery] = React.useState("");
+ const [tonePicker, setTonePicker] = React.useState<{
+ entry: SpaceEmoji;
+ position: { top: number; left: number };
+ } | null>(null);
+ const tone = selected?.match(/[\u{1F3FB}-\u{1F3FF}]/u)?.[0] ?? "";
+ const [focusedIndex, setFocusedIndex] = React.useState(0);
+ const gridRef = React.useRef<HTMLDivElement>(null);
+ const dragStartY = React.useRef<number | undefined>(undefined);
+ const wasDragged = React.useRef(false);
+ const [isDragging, setIsDragging] = React.useState(false);
+ const [dragOffset, setDragOffset] = React.useState(0);
+ const entries = query.trim()
+ ? searchEmojis(spaceEmojis, query)
+ : spaceEmojis;
+
+ const select = (entry: SpaceEmoji, selectedTone = tone) => {
+ onSelect(emojiWithSkinTone(entry, selectedTone));
+ setOpen(false);
+ };
+
+ const navigate = (event: React.KeyboardEvent<HTMLDivElement>) => {
+ const grid = gridRef.current;
+ if (!grid) return;
+ const columns =
+ getComputedStyle(grid).gridTemplateColumns.split(" ").length;
+ const offsets: Record<string, number> = {
+ ArrowLeft: -1,
+ ArrowRight: 1,
+ ArrowUp: -columns,
+ ArrowDown: columns,
+ Home: -focusedIndex,
+ End: entries.length - 1 - focusedIndex,
+ };
+ const offset = offsets[event.key];
+ if (offset == undefined) return;
+ event.preventDefault();
+ const next = Math.max(
+ 0,
+ Math.min(entries.length - 1, focusedIndex + offset),
+ );
+ setFocusedIndex(next);
+ grid.querySelectorAll<HTMLButtonElement>("button")[next]?.focus();
+ };
+
+ return (
+ <Dialog
+ open={open}
+ onClose={() => setOpen(false)}
+ maxWidth={false}
+ slots={
+ isBottomSheet
+ ? { transition: SpaceBottomSheetTransition }
+ : undefined
+ }
+ sx={{ zIndex: 1500 }}
+ slotProps={{
+ paper: {
+ "aria-label": "React to message",
+ style: {
+ translate: `0 ${dragOffset}px`,
+ transition: isDragging
+ ? "none"
+ : "translate 160ms ease-out",
+ },
+ sx: {
+ bgcolor: spaceDialogBackground,
+ borderRadius: "28px 28px 0 0",
+ bottom: 0,
+ boxShadow: "none",
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ height: "min(420px, 60dvh)",
+ left: 0,
+ m: 0,
+ maxHeight: "calc(100dvh - 16px)",
+ maxWidth: "none",
+ overflow: "hidden",
+ p: "0 16px max(16px, env(safe-area-inset-bottom))",
+ position: "fixed",
+ width: "100vw",
+ "@media (min-width: 600px)": {
+ borderRadius: "20px",
+ bottom: "auto",
+ left: "50%",
+ p: "0 20px 20px",
+ top: "50%",
+ transform: "translate(-50%, -50%)",
+ width: 420,
+ },
+ },
+ },
+ transition: { onExited: onClose },
+ }}
+ >
+ <Box
+ component="button"
+ type="button"
+ aria-label="Dismiss emoji picker"
+ onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
+ if (event.detail == 0 || !wasDragged.current)
+ setOpen(false);
+ wasDragged.current = false;
+ }}
+ onPointerDown={(
+ event: React.PointerEvent<HTMLButtonElement>,
+ ) => {
+ if (event.button != 0) return;
+ dragStartY.current = event.clientY;
+ wasDragged.current = false;
+ setIsDragging(true);
+ event.currentTarget.setPointerCapture(event.pointerId);
+ }}
+ onPointerMove={(
+ event: React.PointerEvent<HTMLButtonElement>,
+ ) => {
+ if (dragStartY.current == undefined) return;
+ const distance = event.clientY - dragStartY.current;
+ if (Math.abs(distance) > 4) wasDragged.current = true;
+ setDragOffset(Math.max(0, distance));
+ }}
+ onPointerUp={(event: React.PointerEvent<HTMLButtonElement>) => {
+ if (dragStartY.current == undefined) return;
+ const distance = event.clientY - dragStartY.current;
+ dragStartY.current = undefined;
+ setIsDragging(false);
+ if (distance > 80) setOpen(false);
+ else setDragOffset(0);
+ }}
+ onPointerCancel={() => {
+ dragStartY.current = undefined;
+ wasDragged.current = true;
+ setIsDragging(false);
+ setDragOffset(0);
+ }}
+ sx={{
+ ...buttonSx,
+ borderRadius: "999px",
+ cursor: isDragging ? "grabbing" : "grab",
+ height: 32,
+ touchAction: "none",
+ width: "100%",
+ "&:hover": { bgcolor: "transparent" },
+ }}
+ >
+ <Box
+ component="span"
+ sx={{
+ bgcolor: "#686868",
+ borderRadius: "999px",
+ height: 4,
+ width: 32,
+ }}
+ />
+ </Box>
+ <Box
+ sx={{
+ alignItems: "center",
+ bgcolor: spaceSurface,
+ borderRadius: "12px",
+ display: "flex",
+ flexShrink: 0,
+ gap: "8px",
+ mb: "12px",
+ px: "12px",
+ }}
+ >
+ <HugeiconsIcon
+ icon={Search01Icon}
+ size={16}
+ color={spaceTextMuted}
+ />
+ <Box
+ component="input"
+ type="search"
+ aria-label="Search emojis"
+ aria-controls={resultsID}
+ autoFocus={!isBottomSheet}
+ placeholder="Search"
+ value={query}
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
+ setQuery(event.target.value);
+ setFocusedIndex(0);
+ gridRef.current?.scrollTo({ top: 0 });
+ }}
+ sx={{
+ bgcolor: "transparent",
+ border: 0,
+ color: spaceText,
+ fontFamily: "inherit",
+ fontSize: 14,
+ height: 40,
+ minWidth: 0,
+ outline: 0,
+ width: "100%",
+ "&::placeholder": { color: spaceTextMuted, opacity: 1 },
+ }}
+ />
+ </Box>
+ <Box
+ id={resultsID}
+ ref={gridRef}
+ role="group"
+ aria-label={query.trim() ? "Emoji search results" : "Emojis"}
+ onKeyDown={navigate}
+ sx={{
+ alignContent: "start",
+ display: "grid",
+ gap: "4px",
+ gridTemplateColumns: "repeat(auto-fill, minmax(38px, 1fr))",
+ minHeight: 0,
+ overflowY: "auto",
+ overscrollBehavior: "contain",
+ p: "2px",
+ }}
+ >
+ {entries.map((entry, index) => {
+ const emoji = emojiWithSkinTone(entry, tone);
+ return (
+ <Box
+ key={entry.emoji}
+ component="button"
+ type="button"
+ aria-label={entry.name}
+ aria-pressed={selected == emoji}
+ aria-haspopup={
+ entry.skinTone ? "dialog" : undefined
+ }
+ aria-expanded={
+ entry.skinTone
+ ? tonePicker?.entry.emoji == entry.emoji
+ : undefined
+ }
+ tabIndex={index == focusedIndex ? 0 : -1}
+ title={entry.name}
+ onFocus={() => setFocusedIndex(index)}
+ onClick={(
+ event: React.MouseEvent<HTMLButtonElement>,
+ ) => {
+ if (entry.skinTone) {
+ const anchor =
+ event.currentTarget.getBoundingClientRect();
+ const grid =
+ gridRef.current!.getBoundingClientRect();
+ setTonePicker({
+ entry,
+ position: {
+ top: anchor.top,
+ left: Math.max(
+ grid.left + tonePickerWidth / 2,
+ Math.min(
+ grid.right -
+ tonePickerWidth / 2,
+ anchor.left +
+ anchor.width / 2,
+ ),
+ ),
+ },
+ });
+ } else select(entry);
+ }}
+ sx={{
+ ...buttonSx,
+ height: 42,
+ position: "relative",
+ width: "100%",
+ }}
+ >
+ {emoji}
+ {entry.skinTone && (
+ <Box
+ component="span"
+ aria-hidden
+ sx={{
+ borderRight: `5px solid ${spaceTextMuted}`,
+ borderTop: "5px solid transparent",
+ bottom: 5,
+ position: "absolute",
+ right: 5,
+ }}
+ />
+ )}
+ </Box>
+ );
+ })}
+ {!entries.length && (
+ <Box
+ role="status"
+ sx={{
+ color: spaceTextMuted,
+ fontSize: 14,
+ gridColumn: "1 / -1",
+ py: "36px",
+ textAlign: "center",
+ }}
+ >
+ No emojis found. Try another search.
+ </Box>
+ )}
+ </Box>
+ <Popover
+ open={open && Boolean(tonePicker)}
+ anchorReference="anchorPosition"
+ anchorPosition={tonePicker?.position}
+ onClose={() => setTonePicker(null)}
+ transformOrigin={{ vertical: "bottom", horizontal: "center" }}
+ sx={{ zIndex: 1501 }}
+ slotProps={{
+ paper: {
+ role: "dialog",
+ "aria-label": `Skin tones for ${tonePicker?.entry.name ?? "emoji"}`,
+ sx: {
+ bgcolor: spaceSurfaceHover,
+ backgroundImage: "none",
+ borderRadius: "999px",
+ boxShadow: "0 8px 24px rgba(0, 0, 0, 0.3)",
+ display: "flex",
+ p: "4px",
+ width: tonePickerWidth,
+ },
+ },
+ }}
+ >
+ {tonePicker &&
+ skinTones.map((item, index) => {
+ const emoji = emojiWithSkinTone(
+ tonePicker.entry,
+ item.tone,
+ );
+ return (
+ <Box
+ key={item.tone}
+ component="button"
+ type="button"
+ autoFocus={item.tone == tone}
+ aria-label={`${tonePicker.entry.name}: ${item.name.toLowerCase()} skin tone`}
+ aria-pressed={selected == emoji}
+ onClick={() =>
+ select(tonePicker.entry, item.tone)
+ }
+ onKeyDown={(
+ event: React.KeyboardEvent<HTMLButtonElement>,
+ ) => {
+ const offsets: Record<string, number> = {
+ ArrowLeft: -1,
+ ArrowRight: 1,
+ Home: -index,
+ End: skinTones.length - 1 - index,
+ };
+ const offset = offsets[event.key];
+ if (offset == undefined) return;
+ event.preventDefault();
+ const next = Math.max(
+ 0,
+ Math.min(
+ skinTones.length - 1,
+ index + offset,
+ ),
+ );
+ const buttons =
+ event.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>(
+ "button",
+ );
+ buttons?.[next]?.focus();
+ }}
+ sx={{ ...buttonSx, borderRadius: "50%" }}
+ >
+ {emoji}
+ </Box>
+ );
+ })}
+ </Popover>
+ </Dialog>
+ );
+};
diff --git a/web/apps/space/src/components/MessagesPage.tsx b/web/apps/space/src/components/MessagesPage.tsx
index 12dbcda4c7..8d96a40b75 100644
--- a/web/apps/space/src/components/MessagesPage.tsx
+++ b/web/apps/space/src/components/MessagesPage.tsx
@@ -19,7 +19,7 @@ import {
replyToCurrentMessage,
sendCurrentMessage,
sendCurrentPoke,
- setCurrentMessageLiked,
+ setCurrentMessageReaction,
shouldAutoReadMessageActivities,
type SpaceMessage,
type SpaceMessageConversation,
@@ -135,6 +135,10 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
const [showFriendRequestCanceledToast, setShowFriendRequestCanceledToast] =
React.useState(false);
const [messages, setMessages] = React.useState<SpaceMessage[]>([]);
+ const reactionQueues = React.useRef(new Map<string, Promise<void>>());
+ const savedReactions = React.useRef(new Map<string, string | undefined>());
+ const localReactions = React.useRef(new Map<string, string | undefined>());
+
const [selectedFriendProfile, setSelectedFriendProfile] =
React.useState<SpaceMessageConversation["friend"]>();
const [
@@ -611,6 +615,10 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
let cancelled = false;
selectedFriendSpaceIdRef.current = selectedSpaceId;
+ for (const messageId of localReactions.current.keys()) {
+ if (!reactionQueues.current.has(messageId))
+ localReactions.current.delete(messageId);
+ }
setMessages([]);
setIsThreadLoading(true);
const viewer = currentProfileMessageActor(profile);
@@ -627,7 +635,19 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
page.items.map((message) => message.id),
);
setMessages((currentMessages) => [
- ...page.items,
+ ...page.items.map((message) => {
+ if (!localReactions.current.has(message.id))
+ return message;
+ const reaction = localReactions.current.get(
+ message.id,
+ );
+ return {
+ ...message,
+ reaction,
+ liked: Boolean(reaction),
+ viewerLiked: Boolean(reaction),
+ };
+ }),
...currentMessages.filter(
(message) => !loadedMessageIds.has(message.id),
),
@@ -815,20 +835,56 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
}
void refreshConversations();
}}
- onSetMessageLiked={async (messageId, liked) => {
- await setCurrentMessageLiked(
- actorSpaceId,
- messageId,
- liked,
- );
- setMessages((currentMessages) =>
- currentMessages.map((message) =>
- message.id == messageId
- ? { ...message, liked, viewerLiked: liked }
- : message,
- ),
- );
- void refreshConversations();
+ onSetMessageReaction={async (messageId, emoji) => {
+ const message = messages.find(
+ (item) => item.id == messageId,
+ )!;
+ const previous = reactionQueues.current.get(messageId);
+ if (!previous)
+ savedReactions.current.set(messageId, message.reaction);
+ const update = (reaction: string | undefined) => {
+ localReactions.current.set(messageId, reaction);
+ setMessages((items) =>
+ items.map((item) =>
+ item.id == messageId
+ ? {
+ ...item,
+ reaction,
+ liked: Boolean(reaction),
+ viewerLiked: Boolean(reaction),
+ }
+ : item,
+ ),
+ );
+ };
+ update(emoji);
+ const request = (previous ?? Promise.resolve())
+ .catch(() => undefined)
+ .then(async () => {
+ await setCurrentMessageReaction(
+ actorSpaceId,
+ message.sender.spaceId!,
+ messageId,
+ emoji,
+ );
+ savedReactions.current.set(messageId, emoji);
+ });
+ reactionQueues.current.set(messageId, request);
+ try {
+ await request;
+ if (reactionQueues.current.get(messageId) == request)
+ update(emoji);
+ } catch (error) {
+ if (reactionQueues.current.get(messageId) == request)
+ update(savedReactions.current.get(messageId));
+ throw error;
+ } finally {
+ if (reactionQueues.current.get(messageId) == request) {
+ reactionQueues.current.delete(messageId);
+ savedReactions.current.delete(messageId);
+ void refreshConversations();
+ }
+ }
}}
profileLink={spaceInviteURL({
spaceUsername: profile.username,
diff --git a/web/apps/space/src/data/emojis.ts b/web/apps/space/src/data/emojis.ts
new file mode 100644
index 0000000000..046190ef91
--- /dev/null
+++ b/web/apps/space/src/data/emojis.ts
@@ -0,0 +1,871 @@
+export interface SpaceEmoji {
+ emoji: string;
+ name: string;
+ keywords: string;
+ skinTone: boolean;
+}
+
+export interface SpaceEmojiCategory {
+ name: string;
+ emojis: SpaceEmoji[];
+}
+
+const category = (name: string, entries: string): SpaceEmojiCategory => ({
+ name,
+ emojis: entries
+ .trim()
+ .split("\n")
+ .map((entry) => {
+ const [emoji = "", label = "", keywords = ""] = entry.split("|");
+ return {
+ emoji,
+ name: label.replace("*", ""),
+ keywords,
+ skinTone: label.endsWith("*"),
+ };
+ }),
+});
+
+const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
+const flagRegions =
+ "AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW EU UN";
+
+export const spaceEmojiCategories = [
+ category(
+ "Faces",
+ `
+๐Ÿ˜€|Big smile|happy grin
+๐Ÿ˜ƒ|Happy face|smile joy
+๐Ÿ˜„|Beaming smile|happy laugh
+๐Ÿ˜|Grinning eyes|happy teeth
+๐Ÿ˜†|Laughing|haha lol
+๐Ÿ˜…|Nervous laugh|sweat relief
+๐Ÿ˜‚|Tears of laughter|joy funny lol haha
+๐Ÿคฃ|Rolling with laughter|rofl funny lol
+๐Ÿ˜Š|Warm smile|blush happy
+๐Ÿ™‚|Little smile|happy
+๐Ÿ™ƒ|Upside down|sarcasm silly
+๐Ÿ˜‰|Wink|playful
+๐Ÿ˜Œ|Relieved|calm peace
+๐Ÿ˜|Heart eyes|love crush
+๐Ÿฅฐ|Feeling loved|hearts love
+๐Ÿ˜˜|Blowing a kiss|love
+๐Ÿ˜—|Kiss|love
+๐Ÿ˜™|Smiling kiss|love
+๐Ÿ˜š|Blushing kiss|love
+๐Ÿ˜‹|Yummy|delicious food
+๐Ÿ˜›|Tongue out|silly
+๐Ÿ˜œ|Winking tongue|silly playful
+๐Ÿคช|Goofy|crazy silly
+๐Ÿ˜|Squinting tongue|silly
+๐Ÿค‘|Money face|rich cash
+๐Ÿค—|Hug|thanks cuddle
+๐Ÿคญ|Hand over mouth|oops giggle
+๐Ÿซข|Surprised gasp|shock
+๐Ÿซฃ|Peeking|shy scared
+๐Ÿคซ|Shush|quiet secret
+๐Ÿค”|Thinking|hmm question
+๐Ÿซก|Salute|respect yes
+๐Ÿค|Sealed lips|secret quiet
+๐Ÿคจ|Raised eyebrow|skeptical
+๐Ÿ˜|Neutral|blank
+๐Ÿ˜‘|Unimpressed|expressionless
+๐Ÿ˜ถ|Speechless|silent
+๐Ÿซฅ|Invisible|awkward
+๐Ÿ˜|Smirk|sly
+๐Ÿ˜’|Not amused|annoyed
+๐Ÿ™„|Eye roll|whatever
+๐Ÿ˜ฌ|Awkward grin|oops
+๐Ÿ˜ฎโ€๐Ÿ’จ|Sigh|relief exhausted
+๐Ÿคฅ|Lying|pinocchio
+๐Ÿ˜”|Downhearted|sad
+๐Ÿ˜ช|Sleepy|tired
+๐Ÿคค|Drooling|hungry
+๐Ÿ˜ด|Sleeping|tired snooze
+๐Ÿ˜ท|Face mask|sick
+๐Ÿค’|Fever|sick ill
+๐Ÿค•|Injured|hurt bandage
+๐Ÿคข|Nauseous|sick gross
+๐Ÿคฎ|Vomiting|sick gross
+๐Ÿคง|Sneezing|cold sick
+๐Ÿฅต|Too hot|sweating
+๐Ÿฅถ|Freezing|cold
+๐Ÿฅด|Woozy|dizzy
+๐Ÿ˜ต|Dizzy|shock
+๐Ÿคฏ|Mind blown|amazing wow
+๐Ÿค |Cowboy|hat
+๐Ÿฅณ|Party face|celebrate birthday
+๐Ÿฅธ|Disguise|glasses mustache
+๐Ÿ˜Ž|Cool|sunglasses
+๐Ÿค“|Nerd|glasses clever
+๐Ÿง|Monocle|curious
+๐Ÿ˜•|Confused|unsure
+๐Ÿซค|Unsure|uneasy
+๐Ÿ˜Ÿ|Worried|concern
+๐Ÿ™|Frown|sad
+โ˜น๏ธ|Sad face|unhappy
+๐Ÿ˜ฎ|Surprised|wow oh
+๐Ÿ˜ฏ|Hushed|surprise
+๐Ÿ˜ฒ|Astonished|wow shock
+๐Ÿ˜ณ|Flushed|embarrassed
+๐Ÿฅบ|Pleading|please puppy
+๐Ÿฅน|Holding back tears|touched grateful
+๐Ÿ˜ฆ|Worried gasp|shock
+๐Ÿ˜ง|Anguished|worried
+๐Ÿ˜จ|Fearful|scared
+๐Ÿ˜ฐ|Anxious|sweat nervous
+๐Ÿ˜ฅ|Sad and relieved|disappointed
+๐Ÿ˜ข|Crying|sad tear
+๐Ÿ˜ญ|Sobbing|cry sad
+๐Ÿ˜ฑ|Screaming|scared shock
+๐Ÿ˜–|Frustrated|upset
+๐Ÿ˜ฃ|Struggling|persevere
+๐Ÿ˜ž|Disappointed|sad
+๐Ÿ˜“|Cold sweat|stress
+๐Ÿ˜ฉ|Weary|tired
+๐Ÿ˜ซ|Exhausted|tired
+๐Ÿฅฑ|Yawning|bored sleepy
+๐Ÿ˜ค|Huffing|angry proud
+๐Ÿ˜ก|Angry|mad rage
+๐Ÿ˜ |Annoyed|angry
+๐Ÿคฌ|Swearing|angry rage
+๐Ÿ˜ˆ|Cheeky devil|mischief
+๐Ÿ‘ฟ|Angry devil|mad
+๐Ÿ’€|Skull|dead dying laugh
+โ˜ ๏ธ|Skull and bones|danger
+๐Ÿ’ฉ|Poop|silly
+๐Ÿคก|Clown|silly joke
+๐Ÿ‘ป|Ghost|boo spooky
+๐Ÿ‘ฝ|Alien|space
+๐Ÿค–|Robot|technology
+๐Ÿ˜บ|Smiling cat|happy
+๐Ÿ˜ธ|Grinning cat|happy
+๐Ÿ˜น|Laughing cat|funny lol
+๐Ÿ˜ป|Heart eyes cat|love
+๐Ÿ˜ผ|Smirking cat|sly
+๐Ÿ˜ฝ|Kissing cat|love
+๐Ÿ™€|Shocked cat|surprise
+๐Ÿ˜ฟ|Crying cat|sad
+๐Ÿ˜พ|Angry cat|mad
+๐Ÿ™ˆ|See no evil|shy monkey
+๐Ÿ™‰|Hear no evil|monkey
+๐Ÿ™Š|Speak no evil|secret monkey
+`,
+ ),
+ category(
+ "People",
+ `
+๐Ÿ‘‹|Wave*|hello goodbye hi
+๐Ÿคš|Raised back of hand*|stop
+๐Ÿ–๏ธ|Open hand*|five
+โœ‹|Raised hand*|stop high five
+๐Ÿ––|Vulcan salute*|live prosper
+๐Ÿซฑ|Hand right*|handshake
+๐Ÿซฒ|Hand left*|handshake
+๐Ÿ‘Œ|Okay*|ok perfect
+๐ŸคŒ|Pinched fingers*|chef kiss
+๐Ÿค|Tiny amount*|small
+โœŒ๏ธ|Peace*|victory two
+๐Ÿคž|Crossed fingers*|luck hope
+๐Ÿซฐ|Finger heart*|love
+๐ŸคŸ|Love you*|hand
+๐Ÿค˜|Rock on*|metal
+๐Ÿค™|Call me*|hang loose
+๐Ÿ‘ˆ|Point left*|direction
+๐Ÿ‘‰|Point right*|direction
+๐Ÿ‘†|Point up*|direction
+๐Ÿ‘‡|Point down*|direction
+โ˜๏ธ|One moment*|up attention
+๐Ÿซต|You*|point
+๐Ÿ‘|Thumbs up*|yes good like approve
+๐Ÿ‘Ž|Thumbs down*|no dislike
+โœŠ|Raised fist*|solidarity
+๐Ÿ‘Š|Fist bump*|punch
+๐Ÿค›|Left fist*|bump
+๐Ÿคœ|Right fist*|bump
+๐Ÿ‘|Clapping*|bravo applause congratulations
+๐Ÿ™Œ|Celebration hands*|hooray praise
+๐Ÿซถ|Heart hands*|love
+๐Ÿ‘|Open hands*|welcome
+๐Ÿคฒ|Palms together*|hope
+๐Ÿค|Handshake|deal agreement
+๐Ÿ™|Folded hands*|please thanks pray grateful
+โœ๏ธ|Writing*|note
+๐Ÿ’…|Nail polish*|beauty fancy
+๐Ÿคณ|Selfie*|camera
+๐Ÿ’ช|Strong arm*|strength flex workout
+๐Ÿฆพ|Mechanical arm|strength
+๐Ÿฆต|Leg*|kick
+๐Ÿฆถ|Foot*|step
+๐Ÿ‘‚|Ear*|listen
+๐Ÿ‘ƒ|Nose*|smell
+๐Ÿง |Brain|think smart
+๐Ÿซ€|Anatomical heart|health
+๐Ÿฆท|Tooth|dentist
+๐Ÿ‘€|Eyes|look watching
+๐Ÿ‘๏ธ|Eye|watch
+๐Ÿ‘…|Tongue|taste
+๐Ÿ‘„|Lips|kiss
+๐Ÿ‘ถ|Baby*|child
+๐Ÿง’|Child*|young
+๐Ÿง‘|Person*|adult
+๐Ÿ‘ฉ|Woman*|adult
+๐Ÿ‘จ|Man*|adult
+๐Ÿง“|Older person*|elder
+๐Ÿ‘ต|Grandmother*|elder
+๐Ÿ‘ด|Grandfather*|elder
+๐Ÿ™|Frowning person*|sad
+๐Ÿ™Ž|Pouting person*|angry
+๐Ÿ™…|No gesture*|stop
+๐Ÿ™†|Okay gesture*|yes
+๐Ÿ’|Helping hand*|information
+๐Ÿ™‹|Hand raised*|question
+๐Ÿง|Deaf person*|hearing
+๐Ÿ™‡|Bowing*|sorry respect
+๐Ÿคฆ|Facepalm*|oops disbelief
+๐Ÿคท|Shrug*|idk whatever
+๐Ÿ‘ฎ|Police officer*|law
+๐Ÿ•ต๏ธ|Detective*|mystery
+๐Ÿ’‚|Guard*|royal
+๐Ÿ‘ท|Builder*|construction
+๐Ÿง‘โ€โš•๏ธ|Health worker*|doctor nurse
+๐Ÿง‘โ€๐ŸŽ“|Graduate*|student school
+๐Ÿง‘โ€๐Ÿซ|Teacher*|school
+๐Ÿง‘โ€๐Ÿณ|Cook*|chef food
+๐Ÿง‘โ€๐Ÿ’ป|Developer*|computer work coding
+๐Ÿง‘โ€๐ŸŽจ|Artist*|paint creative
+๐Ÿง‘โ€๐Ÿš€|Astronaut*|space
+๐Ÿ‘ผ|Angel*|innocent
+๐ŸŽ…|Santa*|christmas
+๐Ÿฆธ|Superhero*|hero
+๐Ÿฆน|Villain*|evil
+๐Ÿง™|Wizard*|magic
+๐Ÿงš|Fairy*|magic
+๐Ÿง›|Vampire*|halloween
+๐Ÿงœ|Merperson*|sea
+๐Ÿง|Elf*|fantasy
+๐Ÿงž|Genie|wish
+๐ŸงŸ|Zombie|halloween
+๐Ÿ’ƒ|Dancing woman*|party
+๐Ÿ•บ|Dancing man*|party
+๐Ÿšถ|Walking*|stroll
+๐Ÿƒ|Running*|exercise
+๐Ÿง˜|Meditating*|calm yoga
+๐Ÿ›Œ|In bed*|sleep
+๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ|Family|parents children
+`,
+ ),
+ category(
+ "Nature",
+ `
+๐Ÿถ|Dog|puppy pet
+๐Ÿฑ|Cat|kitten pet
+๐Ÿญ|Mouse|animal
+๐Ÿน|Hamster|pet
+๐Ÿฐ|Rabbit|bunny
+๐ŸฆŠ|Fox|animal
+๐Ÿป|Bear|animal
+๐Ÿผ|Panda|bear
+๐Ÿปโ€โ„๏ธ|Polar bear|snow
+๐Ÿจ|Koala|animal
+๐Ÿฏ|Tiger|cat
+๐Ÿฆ|Lion|cat
+๐Ÿฎ|Cow|moo
+๐Ÿท|Pig|oink
+๐Ÿธ|Frog|animal
+๐Ÿต|Monkey|animal
+๐Ÿ”|Chicken|bird
+๐Ÿง|Penguin|bird
+๐Ÿฆ|Bird|tweet
+๐Ÿค|Chick|baby bird
+๐Ÿฆ†|Duck|quack
+๐Ÿฆ…|Eagle|bird
+๐Ÿฆ‰|Owl|bird wise
+๐Ÿฆ‡|Bat|night
+๐Ÿบ|Wolf|howl
+๐Ÿ—|Boar|pig
+๐Ÿด|Horse|pony
+๐Ÿฆ„|Unicorn|magic
+๐Ÿ|Bee|honey
+๐Ÿฆ‹|Butterfly|insect
+๐ŸŒ|Snail|slow
+๐Ÿž|Ladybug|luck
+๐Ÿœ|Ant|insect
+๐Ÿ•ท๏ธ|Spider|web
+๐Ÿฆ‚|Scorpion|animal
+๐Ÿข|Turtle|slow
+๐Ÿ|Snake|reptile
+๐ŸฆŽ|Lizard|reptile
+๐Ÿฆ–|Dinosaur|t rex
+๐Ÿ™|Octopus|sea
+๐Ÿฆ‘|Squid|sea
+๐Ÿฆ€|Crab|sea
+๐Ÿ |Tropical fish|sea
+๐ŸŸ|Fish|sea
+๐Ÿฌ|Dolphin|sea
+๐Ÿณ|Whale|sea
+๐Ÿฆˆ|Shark|sea
+๐ŸŠ|Crocodile|reptile
+๐Ÿ˜|Elephant|animal
+๐Ÿฆ’|Giraffe|animal
+๐Ÿฆ“|Zebra|stripes
+๐Ÿฆ|Gorilla|ape
+๐Ÿฆง|Orangutan|ape
+๐Ÿช|Camel|desert
+๐Ÿฆ™|Llama|animal
+๐Ÿฆ˜|Kangaroo|animal
+๐Ÿฆฅ|Sloth|slow
+๐Ÿฆฆ|Otter|water
+๐Ÿฆ”|Hedgehog|animal
+๐Ÿพ|Paw prints|pet
+๐Ÿ‰|Dragon|fantasy
+๐ŸŒต|Cactus|desert plant
+๐ŸŽ„|Christmas tree|holiday
+๐ŸŒฒ|Evergreen|tree forest
+๐ŸŒณ|Tree|forest
+๐ŸŒด|Palm tree|tropical beach
+๐ŸŒฑ|Seedling|growth plant
+๐ŸŒฟ|Herb|green plant
+โ˜˜๏ธ|Shamrock|luck
+๐Ÿ€|Four leaf clover|luck
+๐Ÿ|Maple leaf|autumn
+๐Ÿ‚|Falling leaves|autumn
+๐Ÿƒ|Leaf in wind|breeze
+๐Ÿ„|Mushroom|nature
+๐ŸŒน|Rose|flower love
+๐Ÿฅ€|Wilted flower|sad
+๐ŸŒท|Tulip|flower
+๐ŸŒธ|Cherry blossom|flower spring
+๐ŸŒผ|Blossom|flower
+๐ŸŒป|Sunflower|flower sun
+๐ŸŒบ|Hibiscus|flower
+๐Ÿ’|Bouquet|flowers thanks
+๐ŸŒ|Earth|world globe
+๐ŸŒŽ|Americas globe|world earth
+๐ŸŒ|Asia globe|world earth
+๐ŸŒ™|Crescent moon|night
+๐ŸŒ•|Full moon|night
+โญ|Star|favorite
+๐ŸŒŸ|Glowing star|sparkle
+โœจ|Sparkles|magic beautiful
+โ˜€๏ธ|Sun|bright sunny
+๐ŸŒค๏ธ|Partly sunny|weather
+โ˜๏ธ|Cloud|weather
+๐ŸŒง๏ธ|Rain|weather
+โ›ˆ๏ธ|Storm|thunder
+๐ŸŒˆ|Rainbow|color
+โ„๏ธ|Snowflake|winter cold
+โ˜ƒ๏ธ|Snowman|winter
+โšก|Lightning|energy fast
+๐Ÿ”ฅ|Fire|hot lit amazing
+๐Ÿ’ง|Droplet|water
+๐ŸŒŠ|Wave|ocean water
+`,
+ ),
+ category(
+ "Food",
+ `
+๐ŸŽ|Apple|fruit
+๐Ÿ|Green apple|fruit
+๐Ÿ|Pear|fruit
+๐ŸŠ|Orange|fruit
+๐Ÿ‹|Lemon|fruit
+๐ŸŒ|Banana|fruit
+๐Ÿ‰|Watermelon|fruit
+๐Ÿ‡|Grapes|fruit
+๐Ÿ“|Strawberry|fruit
+๐Ÿซ|Blueberries|fruit
+๐Ÿ’|Cherries|fruit
+๐Ÿ‘|Peach|fruit
+๐Ÿฅญ|Mango|fruit
+๐Ÿ|Pineapple|fruit
+๐Ÿฅฅ|Coconut|fruit
+๐Ÿฅ|Kiwi|fruit
+๐Ÿ…|Tomato|vegetable
+๐Ÿฅ‘|Avocado|food
+๐Ÿฅฆ|Broccoli|vegetable
+๐Ÿฅฌ|Leafy greens|salad
+๐Ÿฅ’|Cucumber|vegetable
+๐ŸŒถ๏ธ|Chili|spicy pepper
+๐Ÿซ‘|Bell pepper|vegetable
+๐ŸŒฝ|Corn|vegetable
+๐Ÿฅ•|Carrot|vegetable
+๐Ÿง„|Garlic|food
+๐Ÿง…|Onion|food
+๐Ÿฅ”|Potato|vegetable
+๐Ÿž|Bread|toast
+๐Ÿฅ|Croissant|pastry
+๐Ÿฅฏ|Bagel|bread
+๐Ÿง€|Cheese|food
+๐Ÿฅš|Egg|breakfast
+๐Ÿณ|Fried egg|breakfast cooking
+๐Ÿฅž|Pancakes|breakfast
+๐Ÿง‡|Waffle|breakfast
+๐Ÿฅ“|Bacon|food
+๐Ÿ—|Chicken leg|food
+๐Ÿ”|Burger|food
+๐ŸŸ|Fries|food
+๐Ÿ•|Pizza|food
+๐ŸŒญ|Hot dog|food
+๐Ÿฅช|Sandwich|lunch
+๐ŸŒฎ|Taco|food
+๐ŸŒฏ|Burrito|food
+๐Ÿฅ—|Salad|healthy
+๐Ÿ|Pasta|spaghetti
+๐Ÿœ|Noodles|ramen soup
+๐Ÿฒ|Stew|soup
+๐Ÿ›|Curry rice|food
+๐Ÿฃ|Sushi|food
+๐ŸฅŸ|Dumpling|food
+๐Ÿš|Rice|food
+๐Ÿ™|Rice ball|food
+๐Ÿฟ|Popcorn|movie
+๐Ÿง‚|Salt|food
+๐Ÿฆ|Ice cream cone|dessert
+๐Ÿจ|Ice cream|dessert
+๐Ÿฉ|Doughnut|dessert
+๐Ÿช|Cookie|dessert
+๐ŸŽ‚|Birthday cake|celebrate
+๐Ÿฐ|Cake slice|dessert
+๐Ÿง|Cupcake|dessert
+๐Ÿฅง|Pie|dessert
+๐Ÿซ|Chocolate|sweet
+๐Ÿฌ|Candy|sweet
+๐Ÿญ|Lollipop|sweet
+๐Ÿฏ|Honey|sweet
+๐Ÿฅ›|Milk|drink
+โ˜•|Coffee|tea drink
+๐Ÿซ–|Teapot|tea
+๐Ÿต|Tea|drink
+๐Ÿงƒ|Juice|drink
+๐Ÿฅค|Soft drink|soda
+๐Ÿง‹|Bubble tea|boba drink
+๐Ÿบ|Beer|drink
+๐Ÿป|Beer cheers|celebrate
+๐Ÿฅ‚|Cheers|celebrate toast
+๐Ÿท|Wine|drink
+๐Ÿธ|Cocktail|drink
+๐Ÿน|Tropical drink|vacation
+๐Ÿพ|Champagne|celebrate
+`,
+ ),
+ category(
+ "Travel",
+ `
+๐Ÿš—|Car|drive
+๐Ÿš•|Taxi|ride
+๐ŸšŒ|Bus|transport
+๐ŸšŽ|Trolleybus|transport
+๐ŸŽ๏ธ|Racing car|fast
+๐Ÿš“|Police car|transport
+๐Ÿš‘|Ambulance|health
+๐Ÿš’|Fire engine|rescue
+๐Ÿšš|Delivery truck|transport
+๐Ÿšœ|Tractor|farm
+๐Ÿ›ต|Scooter|ride
+๐Ÿ๏ธ|Motorcycle|ride
+๐Ÿšฒ|Bicycle|cycle
+๐Ÿ›ด|Kick scooter|ride
+๐Ÿš‚|Locomotive|train
+๐Ÿš†|Train|transport
+๐Ÿš‡|Metro|subway
+โœˆ๏ธ|Airplane|flight vacation
+๐Ÿ›ซ|Taking off|flight
+๐Ÿ›ฌ|Landing|flight
+๐Ÿš|Helicopter|flight
+๐Ÿš€|Rocket|space launch
+๐Ÿ›ธ|Flying saucer|ufo alien
+โ›ต|Sailboat|sea
+๐Ÿšค|Speedboat|sea
+๐Ÿšข|Ship|cruise sea
+โš“|Anchor|sea
+๐Ÿšฆ|Traffic light|road
+๐Ÿ—บ๏ธ|Map|travel
+๐Ÿงญ|Compass|direction
+โ›ฐ๏ธ|Mountain|hike
+๐Ÿ”๏ธ|Snowy mountain|hike
+๐ŸŒ‹|Volcano|lava
+๐Ÿ•๏ธ|Camping|tent
+๐Ÿ–๏ธ|Beach|vacation
+๐Ÿœ๏ธ|Desert|sand
+๐Ÿ๏ธ|Island|vacation
+๐Ÿ |Home|house
+๐Ÿก|House and garden|home
+๐Ÿข|Office|work
+๐Ÿฅ|Hospital|health
+๐Ÿซ|School|education
+๐Ÿฐ|Castle|royal
+๐Ÿ—ผ|Tower|tokyo
+๐Ÿ—ฝ|Statue of liberty|new york
+โ›ช|Church|building
+๐Ÿ•Œ|Mosque|building
+๐Ÿ›•|Temple|building
+โ›ฉ๏ธ|Shrine|building
+๐ŸŒ…|Sunrise|morning
+๐ŸŒ„|Mountain sunrise|morning
+๐ŸŒ‡|Sunset|evening
+๐ŸŒƒ|City at night|stars
+๐ŸŒŒ|Galaxy|space stars
+๐ŸŒ‰|Bridge at night|city
+๐ŸŽก|Ferris wheel|fun fair
+๐ŸŽข|Roller coaster|fun
+โ›ฒ|Fountain|water
+โ›บ|Tent|camping
+๐Ÿงณ|Luggage|travel
+โŒ›|Hourglass|time waiting
+โฐ|Alarm clock|time
+โŒš|Watch|time
+`,
+ ),
+ category(
+ "Activities",
+ `
+โšฝ|Football|soccer sport
+๐Ÿ€|Basketball|sport
+๐Ÿˆ|American football|sport
+โšพ|Baseball|sport
+๐ŸŽพ|Tennis|sport
+๐Ÿ|Volleyball|sport
+๐Ÿ‰|Rugby|sport
+๐Ÿฅ|Flying disc|frisbee
+๐ŸŽฑ|Pool|billiards
+๐Ÿ“|Table tennis|ping pong
+๐Ÿธ|Badminton|sport
+๐Ÿ|Cricket|sport
+๐Ÿ’|Ice hockey|sport
+๐Ÿ‘|Field hockey|sport
+โ›ณ|Golf|sport
+๐Ÿน|Archery|bow arrow
+๐ŸŽฃ|Fishing|sport
+๐ŸฅŠ|Boxing glove|sport
+๐Ÿฅ‹|Martial arts|sport
+๐ŸŽฝ|Running shirt|sport
+๐Ÿ›น|Skateboard|sport
+๐Ÿ›ผ|Roller skates|sport
+โ›ธ๏ธ|Ice skate|sport
+๐ŸŽฟ|Skiing|snow sport
+๐Ÿ‚|Snowboarder*|snow sport
+๐Ÿ„|Surfing*|wave sport
+๐ŸŠ|Swimming*|water sport
+๐Ÿšด|Cycling*|bike sport
+๐Ÿง—|Climbing*|sport
+๐Ÿ†|Trophy|winner award
+๐Ÿฅ‡|Gold medal|first winner
+๐Ÿฅˆ|Silver medal|second
+๐Ÿฅ‰|Bronze medal|third
+๐Ÿ…|Medal|award
+๐ŸŽ–๏ธ|Military medal|award
+๐ŸŽฏ|Bullseye|target goal
+๐ŸŽฎ|Video game|play gaming
+๐Ÿ•น๏ธ|Joystick|gaming
+๐ŸŽฒ|Dice|luck game
+๐Ÿงฉ|Puzzle|piece
+โ™Ÿ๏ธ|Chess pawn|game
+๐ŸŽญ|Theater|drama acting
+๐ŸŽจ|Paint palette|art creative
+๐Ÿงต|Thread|sewing
+๐Ÿงถ|Yarn|knitting
+๐ŸŽผ|Music score|song
+๐ŸŽต|Music note|song
+๐ŸŽถ|Music notes|song
+๐ŸŽค|Microphone|sing karaoke
+๐ŸŽง|Headphones|music listen
+๐ŸŽท|Saxophone|music
+๐ŸŽธ|Guitar|music rock
+๐ŸŽน|Piano|music
+๐ŸŽบ|Trumpet|music
+๐ŸŽป|Violin|music
+๐Ÿฅ|Drum|music
+๐ŸŽฌ|Movie clapper|film
+๐ŸŽช|Circus|show
+๐ŸŽŸ๏ธ|Tickets|event
+๐ŸŽ‰|Party popper|congratulations celebrate tada
+๐ŸŽŠ|Confetti|celebrate
+๐ŸŽˆ|Balloon|birthday party
+๐ŸŽ|Gift|present birthday
+๐ŸŽ€|Ribbon|gift
+๐ŸŽ†|Fireworks|celebrate
+๐ŸŽ‡|Sparkler|celebrate
+๐Ÿช”|Oil lamp|diwali
+๐ŸŽƒ|Pumpkin|halloween
+`,
+ ),
+ category(
+ "Objects",
+ `
+๐Ÿ“ฑ|Phone|mobile
+โ˜Ž๏ธ|Telephone|call
+๐Ÿ’ป|Laptop|computer work
+๐Ÿ–ฅ๏ธ|Desktop computer|work
+โŒจ๏ธ|Keyboard|computer
+๐Ÿ–ฑ๏ธ|Computer mouse|click
+๐Ÿ–จ๏ธ|Printer|paper
+๐Ÿ“ท|Camera|photo
+๐Ÿ“ธ|Taking a photo|camera flash
+๐Ÿ“น|Video camera|film
+๐ŸŽฅ|Movie camera|film
+๐Ÿ“บ|Television|watch
+๐Ÿ“ป|Radio|music
+๐Ÿ’ก|Light bulb|idea
+๐Ÿ”ฆ|Flashlight|torch light
+๐Ÿ•ฏ๏ธ|Candle|light
+๐Ÿ”‹|Battery|energy
+๐Ÿ”Œ|Plug|power
+๐Ÿ’ธ|Flying money|spending
+๐Ÿ’ฐ|Money bag|rich cash
+๐Ÿ’ณ|Credit card|pay
+๐Ÿ’Ž|Gem|diamond
+โš–๏ธ|Scales|balance justice
+๐Ÿ”ง|Wrench|tool fix
+๐Ÿ”จ|Hammer|tool
+๐Ÿ› ๏ธ|Tools|fix build
+โš™๏ธ|Gear|settings
+๐Ÿงฒ|Magnet|attract
+๐Ÿงช|Test tube|science
+๐Ÿ”ฌ|Microscope|science
+๐Ÿ”ญ|Telescope|space
+๐Ÿ’Š|Pill|medicine
+๐Ÿ’‰|Syringe|medicine
+๐Ÿฉน|Bandage|healing
+๐Ÿฉบ|Stethoscope|doctor
+๐Ÿ›๏ธ|Bed|sleep
+๐Ÿ›‹๏ธ|Sofa|relax
+๐Ÿšช|Door|entry
+๐Ÿช‘|Chair|seat
+๐ŸชŸ|Window|home
+๐Ÿงน|Broom|clean
+๐Ÿงผ|Soap|clean
+๐Ÿงฝ|Sponge|clean
+๐Ÿงด|Lotion|care
+๐Ÿชฅ|Toothbrush|clean
+๐Ÿงป|Paper roll|tissue
+๐Ÿงบ|Basket|laundry
+๐Ÿงธ|Teddy bear|cuddle toy
+๐Ÿช|Kite|play
+๐Ÿช„|Magic wand|wish
+๐Ÿชฉ|Disco ball|dance party
+๐Ÿ“ฆ|Package|delivery box
+โœ‰๏ธ|Envelope|mail
+๐Ÿ’Œ|Love letter|mail
+๐Ÿ“ฉ|Incoming mail|email
+๐Ÿ“š|Books|read study
+๐Ÿ“–|Open book|read
+๐Ÿ““|Notebook|notes
+๐Ÿ“„|Page|document
+๐Ÿ“ฐ|Newspaper|news
+๐Ÿ“|Memo|write notes
+โœ๏ธ|Pencil|write
+๐Ÿ–Š๏ธ|Pen|write
+๐Ÿ–Œ๏ธ|Paintbrush|art
+๐Ÿ“…|Calendar|date
+๐Ÿ“†|Tear off calendar|date
+๐Ÿ“ˆ|Chart rising|growth
+๐Ÿ“‰|Chart falling|decline
+๐Ÿ“Š|Bar chart|data
+๐Ÿ“Œ|Pin|save
+๐Ÿ“|Location pin|place
+๐Ÿ“Ž|Paperclip|attachment
+โœ‚๏ธ|Scissors|cut
+๐Ÿ”’|Locked|private secure
+๐Ÿ”“|Unlocked|open
+๐Ÿ”‘|Key|password
+๐Ÿ—๏ธ|Old key|unlock
+๐Ÿ””|Bell|notification
+๐Ÿ”•|Muted bell|quiet
+๐Ÿ“ข|Loudspeaker|announcement
+๐Ÿ“ฃ|Megaphone|cheer
+๐Ÿ”|Magnifier|search
+`,
+ ),
+ category(
+ "Symbols",
+ `
+โค๏ธ|Red heart|love like
+๐Ÿงก|Orange heart|love
+๐Ÿ’›|Yellow heart|love friendship
+๐Ÿ’š|Green heart|love
+๐Ÿ’™|Blue heart|love
+๐Ÿ’œ|Purple heart|love
+๐Ÿ–ค|Black heart|love
+๐Ÿค|White heart|love
+๐ŸคŽ|Brown heart|love
+๐Ÿฉท|Pink heart|love
+๐Ÿฉต|Light blue heart|love
+๐Ÿฉถ|Gray heart|love
+๐Ÿ’”|Broken heart|sad heartbreak
+โค๏ธโ€๐Ÿ”ฅ|Heart on fire|passion love
+โค๏ธโ€๐Ÿฉน|Healing heart|care recovery
+๐Ÿ’•|Two hearts|love
+๐Ÿ’ž|Spinning hearts|love
+๐Ÿ’“|Beating heart|love
+๐Ÿ’—|Growing heart|love
+๐Ÿ’–|Sparkling heart|love
+๐Ÿ’˜|Heart and arrow|love cupid
+๐Ÿ’|Heart gift|love
+๐Ÿ’Ÿ|Heart decoration|love
+โฃ๏ธ|Heart exclamation|love
+๐Ÿ’‹|Kiss mark|love
+๐Ÿ’ฏ|Hundred|perfect agree
+๐Ÿ’ข|Anger symbol|mad
+๐Ÿ’ฅ|Boom|explosion impact
+๐Ÿ’ซ|Dizzy stars|sparkle
+๐Ÿ’ฆ|Sweat drops|water
+๐Ÿ’จ|Dash|fast wind
+๐Ÿ•ณ๏ธ|Hole|empty
+๐Ÿ’ฌ|Speech bubble|chat message
+๐Ÿ’ญ|Thought bubble|thinking
+๐Ÿ—ฏ๏ธ|Angry bubble|shout
+๐Ÿ’ค|Sleep symbol|zzz tired
+โœ…|Check mark|yes done correct
+โ˜‘๏ธ|Checked box|done
+โœ”๏ธ|Check|yes correct
+โŒ|Cross|no wrong
+โŽ|Crossed box|no
+โž•|Plus|add
+โž–|Minus|remove
+โœ–๏ธ|Multiply|times
+โž—|Divide|math
+โ™พ๏ธ|Infinity|forever
+โ“|Question|what
+โ”|Light question|what
+โ—|Exclamation|attention
+โ•|Light exclamation|attention
+โ€ผ๏ธ|Double exclamation|wow
+โ‰๏ธ|Question and exclamation|what wow
+โš ๏ธ|Warning|caution
+โ›”|No entry|stop
+๐Ÿšซ|Prohibited|no
+๐Ÿ”ž|Adults only|eighteen
+โ™ป๏ธ|Recycle|green environment
+โšœ๏ธ|Fleur de lis|symbol
+๐Ÿ”ฑ|Trident|symbol
+โš•๏ธ|Medical symbol|health
+โ˜ฎ๏ธ|Peace symbol|peace
+โ˜ฏ๏ธ|Yin yang|balance
+โ˜ธ๏ธ|Dharma wheel|religion
+โœก๏ธ|Star of David|religion
+โœ๏ธ|Cross symbol|religion
+โ˜ช๏ธ|Crescent and star|religion
+๐Ÿ•‰๏ธ|Om|religion
+๐Ÿชฏ|Khanda|religion
+๐Ÿ”ด|Red circle|color
+๐ŸŸ |Orange circle|color
+๐ŸŸก|Yellow circle|color
+๐ŸŸข|Green circle|color
+๐Ÿ”ต|Blue circle|color
+๐ŸŸฃ|Purple circle|color
+โšซ|Black circle|color
+โšช|White circle|color
+๐ŸŸค|Brown circle|color
+๐ŸŸฅ|Red square|color
+๐ŸŸง|Orange square|color
+๐ŸŸจ|Yellow square|color
+๐ŸŸฉ|Green square|color
+๐ŸŸฆ|Blue square|color
+๐ŸŸช|Purple square|color
+โฌ›|Black square|color
+โฌœ|White square|color
+๐ŸŸซ|Brown square|color
+๐Ÿ”ถ|Orange diamond|shape
+๐Ÿ”ท|Blue diamond|shape
+๐Ÿ”บ|Up triangle|shape
+๐Ÿ”ป|Down triangle|shape
+โฌ†๏ธ|Up arrow|direction
+โฌ‡๏ธ|Down arrow|direction
+โฌ…๏ธ|Left arrow|direction
+โžก๏ธ|Right arrow|direction
+โ†—๏ธ|Up right arrow|direction
+โ†˜๏ธ|Down right arrow|direction
+โ†™๏ธ|Down left arrow|direction
+โ†–๏ธ|Up left arrow|direction
+๐Ÿ”„|Repeat|refresh
+๐Ÿ”™|Back|arrow
+๐Ÿ”œ|Soon|arrow
+๐Ÿ”|Top|arrow
+๐Ÿ†•|New|fresh
+๐Ÿ†’|Cool button|nice
+๐Ÿ†—|OK button|yes
+๐Ÿ†˜|SOS|help
+๐Ÿ†™|Up button|level
+0๏ธโƒฃ|Zero|number
+1๏ธโƒฃ|One|number
+2๏ธโƒฃ|Two|number
+3๏ธโƒฃ|Three|number
+4๏ธโƒฃ|Four|number
+5๏ธโƒฃ|Five|number
+6๏ธโƒฃ|Six|number
+7๏ธโƒฃ|Seven|number
+8๏ธโƒฃ|Eight|number
+9๏ธโƒฃ|Nine|number
+๐Ÿ”Ÿ|Ten|number
+#๏ธโƒฃ|Hash|number key
+*๏ธโƒฃ|Asterisk|key
+๐Ÿ|Finish flag|racing
+๐Ÿšฉ|Red flag|warning
+๐Ÿณ๏ธ|White flag|surrender
+๐Ÿด|Black flag|flag
+๐Ÿณ๏ธโ€๐ŸŒˆ|Rainbow flag|pride
+๐Ÿณ๏ธโ€โšง๏ธ|Transgender flag|pride
+๐Ÿดโ€โ˜ ๏ธ|Pirate flag|skull
+`,
+ ),
+ {
+ name: "Flags",
+ emojis: flagRegions
+ .split(" ")
+ .map((region) => ({
+ emoji: String.fromCodePoint(
+ region.charCodeAt(0) + 127397,
+ region.charCodeAt(1) + 127397,
+ ),
+ name: regionNames.of(region)!,
+ keywords: `flag ${region.toLowerCase()}`,
+ skinTone: false,
+ })),
+ },
+];
+
+export const spaceEmojis = spaceEmojiCategories.flatMap(({ emojis }) => emojis);
+
+export const emojiWithSkinTone = (entry: SpaceEmoji, tone: string) => {
+ if (!tone || !entry.skinTone) return entry.emoji;
+ const first = String.fromCodePoint(entry.emoji.codePointAt(0)!);
+ return `${first}${tone}${entry.emoji.slice(first.length).replace("\uFE0F", "")}`;
+};
+
+export const quickReactionEmojis = (selected?: string) => {
+ const tone = selected?.match(/[\u{1F3FB}-\u{1F3FF}]/u)?.[0] ?? "";
+ const emojis = ["โค๏ธ", "๐Ÿ˜‚", "๐Ÿ˜ฎ", "๐Ÿ˜ข", "๐Ÿ™", "๐Ÿ‘"].map((emoji) =>
+ emojiWithSkinTone(
+ spaceEmojis.find((entry) => entry.emoji == emoji)!,
+ tone,
+ ),
+ );
+ return selected && !emojis.includes(selected)
+ ? [...emojis.slice(0, 5), selected]
+ : emojis;
+};
+
+export const searchEmojis = (entries: SpaceEmoji[], query: string) => {
+ const normalized = query
+ .trim()
+ .toLowerCase()
+ .replace(/[\u{1F3FB}-\u{1F3FF}]/gu, "");
+ const terms = normalized.split(/\s+/u);
+ return entries.filter((entry) =>
+ terms.every((term) =>
+ `${entry.emoji} ${entry.name} ${entry.keywords}`
+ .toLowerCase()
+ .includes(term),
+ ),
+ );
+};
+
+export const emojiName = (emoji: string) =>
+ spaceEmojis.find(
+ (entry) =>
+ entry.emoji.replace(/\uFE0F/gu, "") ==
+ emoji
+ .replace(/[\u{1F3FB}-\u{1F3FF}]/gu, "")
+ .replace(/\uFE0F/gu, ""),
+ )?.name ?? "Emoji";
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index efff120330..5798cee8b0 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -612,7 +612,7 @@ const FeedLikeButton: React.FC<FeedLikeButtonProps> = ({
icon={FavouriteIcon}
primaryColor={isLiked ? green : feedActionForeground}
size={feedActionIconSize}
- strokeWidth={2}
+ strokeWidth={2.2}
/>
</Box>
</Box>
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index 8c99ae07fc..e0cab345cd 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -15,13 +15,19 @@ import {
MenuList,
Popper,
} from "@mui/material";
+import { SpaceActionToast } from "components/ActionToast";
import { SpaceAvatarImage } from "components/AvatarImage";
import { SpaceLiveStatus } from "components/LiveStatus";
+import {
+ MessageQuickReactions,
+ MessageReactionPicker,
+} from "components/MessageReactionPicker";
import { SpacePostPhotoInput } from "components/PostPhotoInput";
import { SpacePostPhotosBadge } from "components/PostPhotosBadge";
import { SpaceLoadingSpinner } from "components/RouteFallback";
import { SpaceShareInviteButton } from "components/ShareInviteButton";
import { SpaceSkipLink } from "components/SkipLink";
+import { emojiName } from "data/emojis";
import { formatTimeAgo } from "ente-base/date";
import log from "ente-base/log";
import React from "react";
@@ -37,6 +43,8 @@ import {
spaceAppBackground,
spaceAppBackgroundColor,
spaceDialogBackground,
+ spaceMenuBackground,
+ spaceMenuHover,
spaceOnAccent,
spaceSurface,
spaceSurfaceHover,
@@ -129,7 +137,10 @@ interface MessagesScreenProps {
) => Promise<void>;
onSendPoke: (spaceId: string) => Promise<void>;
onSendMessage: (spaceId: string, text: string) => Promise<void>;
- onSetMessageLiked: (messageId: string, liked: boolean) => Promise<void>;
+ onSetMessageReaction: (
+ messageId: string,
+ emoji: string | undefined,
+ ) => Promise<void>;
profileLink?: string;
newConversationIds?: string[];
profile: SetupProfile;
@@ -240,11 +251,11 @@ const conversationPreview = (conversation: SpaceMessageConversation) => {
if (activity.type == "message_like") {
return text
? activity.outgoing
- ? `You liked "${text}"`
- : `Liked "${text}"`
+ ? `You reacted ${activity.reaction ?? ""} to "${text}"`
+ : `Reacted ${activity.reaction ?? ""} to "${text}"`
: activity.outgoing
- ? "You liked a message"
- : "Liked a message";
+ ? `You reacted ${activity.reaction ?? ""} to a message`
+ : `Reacted ${activity.reaction ?? ""} to a message`;
}
if (activity.kind == "poke") {
return activity.outgoing
@@ -278,7 +289,7 @@ const ConversationPreviewLine: React.FC<{
return (
<Box sx={{ ...previewLineSx, display: "flex" }}>
<Box component="span" sx={{ flexShrink: 0 }}>
- {activity.outgoing ? 'You liked "' : 'Liked "'}
+ {`${activity.outgoing ? "You reacted" : "Reacted"} ${activity.reaction ?? ""} to "`}
</Box>
<Box
component="span"
@@ -932,6 +943,7 @@ const bodyBubblesCanGroup = (
) => {
if (!first || !second) return false;
if (!sameMessageSender(first, second)) return false;
+ if (first.reaction) return false;
if (first.kind == "post_like" || first.kind == "friend_added") return false;
if (
(second.kind != "regular" && second.kind != "poke") ||
@@ -969,54 +981,6 @@ const ReplyIcon: React.FC = () => (
</svg>
);
-const HeartIcon: React.FC<{ filled?: boolean; small?: boolean }> = ({
- filled,
- small,
-}) => (
- <svg
- width={small ? "13" : "16"}
- height={small ? "11" : "14"}
- viewBox="0 0 16 14"
- fill={filled ? green : "none"}
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M6.63749 12.3742C4.66259 10.885 0.75 7.4804 0.75 4.41664C0.75 2.39161 2.22368 0.75 4.25 0.75C5.3 0.75 6.35 1.10294 7.75 2.51469C9.15 1.10294 10.2 0.75 11.25 0.75C13.2763 0.75 14.75 2.39161 14.75 4.41664C14.75 7.4804 10.8374 10.885 8.86251 12.3742C8.19793 12.8753 7.30207 12.8753 6.63749 12.3742Z"
- stroke={filled ? green : "currentColor"}
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const MessageLikeHeartIcon: React.FC = () => (
- <svg
- width="17"
- height="15"
- viewBox="-2 -2 20 18"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M6.63749 12.3742C4.66259 10.885 0.75 7.4804 0.75 4.41664C0.75 2.39161 2.22368 0.75 4.25 0.75C5.3 0.75 6.35 1.10294 7.75 2.51469C9.15 1.10294 10.2 0.75 11.25 0.75C13.2763 0.75 14.75 2.39161 14.75 4.41664C14.75 7.4804 10.8374 10.885 8.86251 12.3742C8.19793 12.8753 7.30207 12.8753 6.63749 12.3742Z"
- fill={green}
- stroke={spaceAppBackgroundColor}
- strokeWidth="4"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- <path
- d="M6.63749 12.3742C4.66259 10.885 0.75 7.4804 0.75 4.41664C0.75 2.39161 2.22368 0.75 4.25 0.75C5.3 0.75 6.35 1.10294 7.75 2.51469C9.15 1.10294 10.2 0.75 11.25 0.75C13.2763 0.75 14.75 2.39161 14.75 4.41664C14.75 7.4804 10.8374 10.885 8.86251 12.3742C8.19793 12.8753 7.30207 12.8753 6.63749 12.3742Z"
- fill={green}
- stroke={green}
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
const DeleteIcon: React.FC = () => (
<svg
width="13"
@@ -1050,11 +1014,6 @@ const CopyIcon: React.FC = () => (
</svg>
);
-const messageActionsPopperModifiers = [
- { name: "offset", options: { offset: [0, 6] } },
- { name: "preventOverflow", options: { padding: 14 } },
- { name: "flip", options: { padding: 14 } },
-];
const messageActionsTransitionDuration = { enter: 140, exit: 100 };
const MessageActionMenuItem: React.FC<{
@@ -1077,14 +1036,18 @@ const MessageActionMenuItem: React.FC<{
py: "7px",
"&.Mui-focusVisible": {
bgcolor:
- tone == "danger" ? "rgba(246, 58, 58, 0.14)" : spaceSurface,
+ tone == "danger"
+ ? "rgba(246, 58, 58, 0.14)"
+ : spaceMenuHover,
outline: 0,
},
"&:focus": { outline: 0 },
"&:focus-visible": { outline: 0 },
"&:hover": {
bgcolor:
- tone == "danger" ? "rgba(246, 58, 58, 0.14)" : spaceSurface,
+ tone == "danger"
+ ? "rgba(246, 58, 58, 0.14)"
+ : spaceMenuHover,
},
}}
>
@@ -1651,8 +1614,12 @@ const MessageBubble: React.FC<{
maxWidth: "100%",
minWidth: 0,
position: "relative",
+ transition: "margin-bottom 180ms ease-out",
width: "100%",
- zIndex: isHighlighted ? 3 : message.liked ? 1 : "auto",
+ zIndex: isHighlighted ? 3 : message.reaction ? 1 : "auto",
+ "@media (prefers-reduced-motion: reduce)": {
+ transition: "none",
+ },
}}
>
{isFriendAdded ? (
@@ -1717,6 +1684,21 @@ const MessageBubble: React.FC<{
)}
<Box
data-message-bubble
+ tabIndex={isUnavailable ? undefined : 0}
+ onKeyDown={(
+ event: React.KeyboardEvent<HTMLElement>,
+ ) => {
+ if (
+ event.key == "ContextMenu" ||
+ (event.shiftKey && event.key == "F10")
+ ) {
+ event.preventDefault();
+ openActions(
+ event.currentTarget,
+ "contextmenu",
+ );
+ }
+ }}
onContextMenu={handleContextMenu}
onPointerCancel={cancelGesture}
onPointerDown={handlePointerDown}
@@ -1728,6 +1710,10 @@ const MessageBubble: React.FC<{
? outgoingBubble
: incomingBubble,
borderRadius: bubbleBorderRadius,
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
color: isOwn
? outgoingMessageText
: incomingMessageText,
@@ -1736,7 +1722,7 @@ const MessageBubble: React.FC<{
: "context-menu",
display: "block",
maxWidth: "100%",
- minWidth: 0,
+ minWidth: message.reaction ? 48 : 0,
ml: 0,
overflow: "visible",
position: "relative",
@@ -1747,8 +1733,11 @@ const MessageBubble: React.FC<{
transform: `translateX(${swipeOffset}px)`,
transition:
swipeOffset > 0
- ? "none"
- : "transform 160ms ease-out",
+ ? "border-radius 180ms ease-out"
+ : "transform 160ms ease-out, border-radius 180ms ease-out",
+ "@media (prefers-reduced-motion: reduce)": {
+ transition: "none",
+ },
userSelect: "none",
WebkitTouchCallout: "none",
WebkitUserSelect: "none",
@@ -1784,27 +1773,37 @@ const MessageBubble: React.FC<{
? pokeText
: message.text}
</Box>
- {!isUnavailable && message.liked && (
+ {!isUnavailable && message.reaction && (
<Box
component="span"
role="img"
- aria-label="Liked"
+ aria-label={`Reaction: ${emojiName(message.reaction)}`}
sx={{
alignItems: "center",
- bottom: -5,
+ bottom: -16,
+ bgcolor: spaceDialogBackground,
+ border: `2px solid ${spaceAppBackgroundColor}`,
+ borderRadius: "12px",
+ fontFamily:
+ '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif',
+ fontSize: 14,
+ minHeight: 24,
+ minWidth: 28,
+ pt: "2px",
+ px: "3px",
color: green,
display: "inline-flex",
justifyContent: "center",
- lineHeight: 0,
+ lineHeight: 1,
pointerEvents: "none",
position: "absolute",
zIndex: 2,
...(isOwn
- ? { left: -2 }
- : { right: -2 }),
+ ? { right: 14 }
+ : { left: 14 }),
}}
>
- <MessageLikeHeartIcon />
+ {message.reaction}
</Box>
)}
</Box>
@@ -1839,7 +1838,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
onReplyToMessage,
onSendPoke,
onSendMessage,
- onSetMessageLiked,
+ onSetMessageReaction,
profile,
profileLink,
selectedFriend,
@@ -1848,6 +1847,9 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
const [messageText, setMessageText] = React.useState("");
const [messageContextMenu, setMessageContextMenu] =
React.useState<MessageContextMenuState | null>(null);
+ const [reactionPickerMessage, setReactionPickerMessage] =
+ React.useState<MessageContextMenuState | null>(null);
+ const [reactionError, setReactionError] = React.useState(false);
const [replyingTo, setReplyingTo] = React.useState<SpaceMessage | null>(
null,
);
@@ -1979,9 +1981,6 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
() => new Map(messages.map((message) => [message.id, message])),
[messages],
);
- const isContextMessageLiked = Boolean(
- messageContextMenu?.message.viewerLiked,
- );
const isContextMessageOwn = Boolean(
messageContextMenu?.message &&
isCurrentProfileMessage(messageContextMenu.message, profile),
@@ -2098,9 +2097,27 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
composerRef.current?.focus();
};
- const handleMessageAction = (
- action: "copy" | "delete" | "like" | "reply",
- ) => {
+ const reactToMessage = (message: SpaceMessage, emoji: string) => {
+ if (!canInteract || isCurrentProfileMessage(message, profile)) return;
+ closeMessageActions();
+ setReactionError(false);
+ const current = messageByID.get(message.id) ?? message;
+ const reaction = current.reaction == emoji ? undefined : emoji;
+ void onSetMessageReaction(message.id, reaction)
+ .then(() => {
+ setActionStatus(
+ reaction
+ ? `Reacted with ${emojiName(reaction)}`
+ : "Reaction removed",
+ );
+ })
+ .catch((error: unknown) => {
+ log.error("Failed to update message reaction", error);
+ setReactionError(true);
+ });
+ };
+
+ const handleMessageAction = (action: "copy" | "delete" | "reply") => {
const targetMessage = messageContextMenu?.message;
if (!targetMessage) return;
if (!canInteract && action != "copy") {
@@ -2116,16 +2133,6 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
log.error("Failed to copy message", error),
);
break;
- case "like":
- closeMessageActions();
- if (isCurrentProfileMessage(targetMessage, profile)) return;
- void onSetMessageLiked(
- targetMessage.id,
- !targetMessage.viewerLiked,
- ).catch((error: unknown) =>
- log.error("Failed to update message like", error),
- );
- break;
case "reply":
startReply(targetMessage);
break;
@@ -2212,6 +2219,8 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
React.useEffect(() => {
setReplyingTo(null);
setMessageContextMenu(null);
+ setReactionPickerMessage(null);
+ setReactionError(false);
setMessageText("");
stickToThreadBottomRef.current = true;
smoothNextMessageScrollRef.current = false;
@@ -2276,14 +2285,6 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
);
const messageActionMenuItems = [
- !isContextMessagePoke && canInteract && !isContextMessageOwn ? (
- <MessageActionMenuItem
- key="like"
- icon={<HeartIcon small />}
- label={isContextMessageLiked ? "Unlike" : "Like"}
- onClick={() => handleMessageAction("like")}
- />
- ) : null,
!isContextMessagePoke && canInteract ? (
<MessageActionMenuItem
key="reply"
@@ -2314,6 +2315,37 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
return (
<>
<SpaceLiveStatus>{actionStatus}</SpaceLiveStatus>
+ {reactionPickerMessage && (
+ <MessageReactionPicker
+ selected={
+ messageByID.get(reactionPickerMessage.message.id)
+ ?.reaction
+ }
+ onSelect={(emoji) =>
+ reactToMessage(reactionPickerMessage.message, emoji)
+ }
+ onClose={() => {
+ reactionPickerMessage.anchorEl.focus();
+ setReactionPickerMessage(null);
+ }}
+ />
+ )}
+ {reactionError && (
+ <SpaceActionToast
+ animateEntrance
+ closeLabel="Dismiss reaction error"
+ icon={
+ <HugeiconsIcon
+ icon={Cancel01Icon}
+ size={20}
+ color={dangerColor}
+ />
+ }
+ message="Couldnโ€™t update your reaction. Try again."
+ onClose={() => setReactionError(false)}
+ zIndex={1600}
+ />
+ )}
<SpacePostPhotoInput
inputRef={postPhotoInputRef}
onSelect={onPostPhotoSelect}
@@ -2722,9 +2754,47 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
</Box>
<Popper
anchorEl={messageContextMenu?.anchorEl ?? null}
- modifiers={messageActionsPopperModifiers}
+ modifiers={[
+ {
+ name: "offset",
+ options: {
+ offset: [
+ 0,
+ messageContextMenu?.message
+ .reaction
+ ? 24
+ : 8,
+ ],
+ },
+ },
+ {
+ name: "preventOverflow",
+ options: {
+ altAxis: true,
+ boundary: threadScrollRef.current,
+ padding: 8,
+ },
+ },
+ {
+ name: "flip",
+ options: {
+ boundary: threadScrollRef.current,
+ padding: 8,
+ fallbackPlacements: [
+ isContextMessageOwn
+ ? "top-end"
+ : "top-start",
+ ],
+ flipVariations: false,
+ },
+ },
+ ]}
open={Boolean(messageContextMenu?.open)}
- placement="bottom-end"
+ placement={
+ isContextMessageOwn
+ ? "bottom-end"
+ : "bottom-start"
+ }
sx={{ outline: 0, zIndex: 1300 }}
transition
>
@@ -2739,10 +2809,15 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
<Grow
{...(TransitionProps ?? {})}
style={{
- transformOrigin:
+ transformOrigin: `${
+ placement.endsWith("end")
+ ? "right"
+ : "left"
+ } ${
placement.startsWith("top")
- ? "right bottom"
- : "right top",
+ ? "bottom"
+ : "top"
+ }`,
}}
onExited={() => {
TransitionProps?.onExited();
@@ -2753,28 +2828,68 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
}
>
<Box
+ onKeyDown={(
+ event: React.KeyboardEvent<HTMLElement>,
+ ) => {
+ if (event.key == "Escape") {
+ closeMessageActions();
+ messageContextMenu?.anchorEl.focus();
+ }
+ }}
sx={{
WebkitTapHighlightColor:
"transparent",
- bgcolor:
- spaceDialogBackground,
- borderRadius: "16px",
- boxShadow:
- "0 14px 40px rgba(0, 0, 0, 0.14)",
- minWidth: 132,
+ display: "flex",
+ flexDirection: "column",
+ gap: "4px",
outline: 0,
- p: "4px",
}}
>
+ {!isContextMessagePoke &&
+ canInteract &&
+ !isContextMessageOwn &&
+ messageContextMenu && (
+ <MessageQuickReactions
+ selected={
+ messageContextMenu
+ .message
+ .reaction
+ }
+ onSelect={(emoji) =>
+ reactToMessage(
+ messageContextMenu.message,
+ emoji,
+ )
+ }
+ onMore={() => {
+ setReactionPickerMessage(
+ messageContextMenu,
+ );
+ closeMessageActions();
+ }}
+ />
+ )}
<MenuList
aria-label="Message actions"
- autoFocus
+ autoFocus={
+ isContextMessagePoke ||
+ !canInteract ||
+ isContextMessageOwn
+ }
onKeyDown={
handleMessageActionsKeyDown
}
sx={{
+ alignSelf: "flex-start",
+ bgcolor:
+ spaceMenuBackground,
+ borderRadius: "16px",
+ boxShadow:
+ "0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.32)",
+ minWidth: 132,
outline: 0,
- p: 0,
+ p: "4px",
+ width: "max-content",
"&:focus": {
outline: 0,
},
diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.ts
index 3291a0b257..a4dc8b2946 100644
--- a/web/apps/space/src/services/space.ts
+++ b/web/apps/space/src/services/space.ts
@@ -149,6 +149,7 @@ export interface SpaceMessage {
isDeleted: boolean;
kind: SpaceMessageKind;
liked: boolean;
+ reaction?: string;
quote?: SpaceMessageQuote;
recipient: FriendProfile;
replyMessageId?: string;
@@ -174,6 +175,7 @@ export interface SpaceMessageActivity {
post?: SpaceMessageActivityPost;
text?: string;
type: SpaceMessageActivityType;
+ reaction?: string;
isUnavailable?: boolean;
}
@@ -689,6 +691,7 @@ const messageFromSpaceMessage = async (
isUnavailable: message.isUnavailable,
kind: message.kind,
liked: message.liked,
+ reaction: message.reaction ?? undefined,
quote,
recipient,
replyMessageId: message.replyMessageId,
@@ -750,6 +753,7 @@ const messageActivityFromSpaceActivity = (
post,
text: activity.text?.trim() || undefined,
type: activity.type,
+ reaction: activity.reaction ?? undefined,
isUnavailable: activity.isUnavailable,
};
};
@@ -1255,14 +1259,20 @@ export const replyToCurrentMessage = async (
}
};
-export const setCurrentMessageLiked = async (
+export const setCurrentMessageReaction = async (
spaceId: string,
+ senderSpaceId: string,
messageId: string,
- liked: boolean,
+ emoji: string | undefined,
) => {
const ctx = await ensureCurrentSpaceContext();
try {
- await ctx.likeMessage(spaceId, messageId, liked);
+ await ctx.setMessageReaction(
+ spaceId,
+ senderSpaceId,
+ messageId,
+ emoji ?? null,
+ );
} finally {
releaseCurrentSpaceContext(ctx);
}
diff --git a/web/apps/space/src/styles/colors.ts b/web/apps/space/src/styles/colors.ts
index 142531ce2a..1139e6fd13 100644
--- a/web/apps/space/src/styles/colors.ts
+++ b/web/apps/space/src/styles/colors.ts
@@ -7,6 +7,8 @@ export const spaceSurface = "#28282B";
export const spaceSurfaceHover = "#3A3A3A";
export const spaceControlBackground = "#343434";
export const spaceControlBackgroundHover = "#3E3E3E";
+export const spaceMenuBackground = "#424242";
+export const spaceMenuHover = "#505050";
export const spaceText = "#F2F2F2";
export const spaceTextMuted = "#B0B0B0";
export const spaceOnAccent = "#FFFFFF";
diff --git a/web/apps/space/tests/emoji-picker.test.ts b/web/apps/space/tests/emoji-picker.test.ts
new file mode 100644
index 0000000000..6bedbb1535
--- /dev/null
+++ b/web/apps/space/tests/emoji-picker.test.ts
@@ -0,0 +1,104 @@
+import { describe, expect, test } from "vitest";
+import {
+ emojiName,
+ emojiWithSkinTone,
+ quickReactionEmojis,
+ searchEmojis,
+ spaceEmojis,
+} from "../src/data/emojis";
+
+describe("quick reactions", () => {
+ test("keeps the defaults when no reaction is selected", () => {
+ expect(quickReactionEmojis()).toEqual([
+ "โค๏ธ",
+ "๐Ÿ˜‚",
+ "๐Ÿ˜ฎ",
+ "๐Ÿ˜ข",
+ "๐Ÿ™",
+ "๐Ÿ‘",
+ ]);
+ });
+
+ test.each(["โค๏ธ", "๐Ÿ˜‚", "๐Ÿ˜ฎ", "๐Ÿ˜ข", "๐Ÿ™", "๐Ÿ‘"])(
+ "keeps selected default %s in its usual slot",
+ (selected) => {
+ expect(quickReactionEmojis(selected)).toEqual([
+ "โค๏ธ",
+ "๐Ÿ˜‚",
+ "๐Ÿ˜ฎ",
+ "๐Ÿ˜ข",
+ "๐Ÿ™",
+ "๐Ÿ‘",
+ ]);
+ },
+ );
+
+ test.each(["๐Ÿ”ฅ", "๐Ÿชฟ"])(
+ "includes a selected %s outside the defaults",
+ (selected) => {
+ expect(quickReactionEmojis(selected)).toEqual([
+ "โค๏ธ",
+ "๐Ÿ˜‚",
+ "๐Ÿ˜ฎ",
+ "๐Ÿ˜ข",
+ "๐Ÿ™",
+ selected,
+ ]);
+ },
+ );
+
+ test("preserves skin tones and the selected variant's usual slot", () => {
+ expect(quickReactionEmojis("๐Ÿ™๐Ÿฝ")).toEqual([
+ "โค๏ธ",
+ "๐Ÿ˜‚",
+ "๐Ÿ˜ฎ",
+ "๐Ÿ˜ข",
+ "๐Ÿ™๐Ÿฝ",
+ "๐Ÿ‘๐Ÿฝ",
+ ]);
+ });
+});
+
+describe("emoji search", () => {
+ test("finds aliases, multiple words and literal toned emoji", () => {
+ expect(
+ searchEmojis(spaceEmojis, " LOL ").map((item) => item.emoji),
+ ).toContain("๐Ÿ˜‚");
+ expect(
+ searchEmojis(spaceEmojis, "blue heart").map((item) => item.emoji),
+ ).toEqual(["๐Ÿ’™", "๐Ÿฉต"]);
+ expect(
+ searchEmojis(spaceEmojis, "๐Ÿ‘๐Ÿฝ").map((item) => item.emoji),
+ ).toEqual(["๐Ÿ‘"]);
+ expect(searchEmojis(spaceEmojis, "no-such-emoji")).toEqual([]);
+ });
+
+ test("inserts tones before joined professions and drops the text selector", () => {
+ const peace = spaceEmojis.find((entry) => entry.emoji == "โœŒ๏ธ")!;
+ const developer = spaceEmojis.find((entry) => entry.emoji == "๐Ÿง‘โ€๐Ÿ’ป")!;
+ expect(emojiWithSkinTone(peace, "๐Ÿฝ")).toBe("โœŒ๐Ÿฝ");
+ expect(emojiWithSkinTone(developer, "๐Ÿฟ")).toBe("๐Ÿง‘๐Ÿฟโ€๐Ÿ’ป");
+ expect(emojiName("๐Ÿง‘๐Ÿฟโ€๐Ÿ’ป")).toBe("Developer");
+ expect(
+ emojiWithSkinTone(
+ spaceEmojis.find((entry) => entry.emoji == "โค๏ธ")!,
+ "๐Ÿฝ",
+ ),
+ ).toBe("โค๏ธ");
+ });
+
+ test("catalog entries and all tone variants contain a single grapheme", () => {
+ const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" });
+ expect(new Set(spaceEmojis.map((entry) => entry.emoji)).size).toBe(
+ spaceEmojis.length,
+ );
+ for (const entry of spaceEmojis) {
+ for (const tone of ["", "๐Ÿป", "๐Ÿผ", "๐Ÿฝ", "๐Ÿพ", "๐Ÿฟ"]) {
+ expect(
+ [...segmenter.segment(emojiWithSkinTone(entry, tone))],
+ entry.name,
+ ).toHaveLength(1);
+ }
+ }
+ });
+});