Skip to content

armgit / ente

Public Imported from GitHub
0

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

Replace waves with pokes in Space

Anand Baburajan0ed91876dfab
diff --git a/rust/bindings/wasm/space/src/space.rs b/rust/bindings/wasm/space/src/space.rs
index 1a68ea603e..3c93394b5d 100644
--- a/rust/bindings/wasm/space/src/space.rs
+++ b/rust/bindings/wasm/space/src/space.rs
@@ -3,9 +3,9 @@ use std::collections::BTreeMap;
use ente_core::b64;
use ente_space::{
AccountSpaceCtx, CreatedSpace, DecryptedMessage, DecryptedPost, DecryptedSpaceProfile,
- MessageConversationActivity, MessageResponse, OpenAccountSpaceCtxInput, OpenSpaceLinkCtxInput,
- PostPhotoAssetOptions, PostResponse, ProfileAvatarResponse, ProfileCoverResponse,
- SpaceActorResponse, SpaceKeyResponse, SpaceLinkCtx,
+ MessageConversationActivity, MessagePayload, MessageResponse, OpenAccountSpaceCtxInput,
+ OpenSpaceLinkCtxInput, PostPhotoAssetOptions, PostResponse, ProfileAvatarResponse,
+ ProfileCoverResponse, SpaceActorResponse, SpaceKeyResponse, SpaceLinkCtx,
};
use serde::{Deserialize, Serialize};
use serde_wasm_bindgen as swb;
@@ -190,6 +190,7 @@ struct MessageConversationActivityJs {
id: String,
#[serde(rename = "type")]
activity_type: String,
+ kind: String,
created_at: String,
outgoing: bool,
message_id: Option<String>,
@@ -495,9 +496,10 @@ fn link_post_to_js(post: PostResponse, decrypted: DecryptedPost) -> Result<PostJ
}
async fn account_message_to_js(
- message: MessageResponse,
+ mut message: MessageResponse,
decrypted: DecryptedMessage,
) -> Result<MessageJs, Error> {
+ message.kind = decrypted.payload.kind;
Ok(message_to_js(message, decrypted.payload.text))
}
@@ -574,11 +576,11 @@ async fn resilient_account_message_response_to_js(
}
}
-async fn message_conversation_activity_text(
+async fn message_conversation_activity_payload(
ctx: &AccountSpaceCtx,
viewer_space_id: &str,
activity: &MessageConversationActivity,
-) -> Result<Option<String>, Error> {
+) -> Result<Option<MessagePayload>, Error> {
if activity.message_cipher.trim().is_empty()
|| activity.encrypted_message_key.trim().is_empty()
|| activity.message_id.is_none()
@@ -607,7 +609,7 @@ async fn message_conversation_activity_text(
updated_at: activity.created_at.clone(),
};
let decrypted = ctx.decrypt_message(viewer_space_id, &message).await?;
- Ok(Some(decrypted.payload.text))
+ Ok(Some(decrypted.payload))
}
async fn message_conversation_activity_to_js(
@@ -615,10 +617,16 @@ async fn message_conversation_activity_to_js(
viewer_space_id: &str,
activity: MessageConversationActivity,
) -> Result<MessageConversationActivityJs, Error> {
- let text = message_conversation_activity_text(ctx, viewer_space_id, &activity).await?;
+ let payload = message_conversation_activity_payload(ctx, viewer_space_id, &activity).await?;
+ let kind = payload
+ .as_ref()
+ .map(|payload| payload.kind.clone())
+ .unwrap_or_else(|| activity.kind.clone());
+ let text = payload.map(|payload| payload.text);
Ok(MessageConversationActivityJs {
id: activity.id,
activity_type: activity.activity_type,
+ kind,
created_at: activity.created_at,
outgoing: activity.outgoing,
message_id: activity.message_id,
@@ -635,6 +643,7 @@ fn unavailable_message_conversation_activity_to_js(
MessageConversationActivityJs {
id: activity.id,
activity_type: activity.activity_type,
+ kind: activity.kind,
created_at: activity.created_at,
outgoing: activity.outgoing,
message_id: activity.message_id,
@@ -1211,6 +1220,20 @@ impl SpaceAccountCtxHandle {
swb::to_value(&account_message_to_js(message, decrypted).await?).map_err(Into::into)
}
+ #[wasm_bindgen(js_name = sendPoke)]
+ pub async fn send_poke(
+ &self,
+ sender_space_id: String,
+ space_id: String,
+ ) -> Result<JsValue, Error> {
+ let message = self.inner.send_poke(&sender_space_id, &space_id).await?;
+ let decrypted = self
+ .inner
+ .decrypt_message(&sender_space_id, &message)
+ .await?;
+ swb::to_value(&account_message_to_js(message, decrypted).await?).map_err(Into::into)
+ }
+
#[wasm_bindgen(js_name = replyToMessage)]
pub async fn reply_to_message(
&self,
diff --git a/rust/crates/space/src/client/messages.rs b/rust/crates/space/src/client/messages.rs
index a05fb0ee6d..7bcc531cbe 100644
--- a/rust/crates/space/src/client/messages.rs
+++ b/rust/crates/space/src/client/messages.rs
@@ -1,5 +1,6 @@
use super::{
- AccountSpaceCtx, MESSAGE_KIND_POST_REPLY, MESSAGE_KIND_REGULAR, validate_message_payload,
+ AccountSpaceCtx, MESSAGE_KIND_POKE, MESSAGE_KIND_POST_REPLY, MESSAGE_KIND_REGULAR,
+ validate_message_payload,
};
use crate::crypto::{
decrypt_secretbox_payload, encrypt_secretbox_payload, generate_key, open_with_keypair,
@@ -13,8 +14,8 @@ use crate::transport::{
};
use ente_core::b64;
-const MESSAGE_NOTIFICATION_KIND_WAVE: &str = "wave";
-const WAVE_MESSAGE_TEXT: &str = "πŸ‘‹";
+const MESSAGE_NOTIFICATION_KIND_POKE: &str = "poke";
+const POKE_MESSAGE_TEXT: &str = "Poked";
impl AccountSpaceCtx {
pub async fn list_conversations(&self, space_id: &str) -> Result<ConversationsResponse> {
@@ -60,22 +61,55 @@ impl AccountSpaceCtx {
sender_space_id: &str,
space_id: &str,
text: &str,
+ ) -> Result<MessageResponse> {
+ self.send_direct_message(
+ sender_space_id,
+ space_id,
+ MessagePayload {
+ version: 1,
+ kind: MESSAGE_KIND_REGULAR.to_owned(),
+ text: text.to_owned(),
+ },
+ None,
+ )
+ .await
+ }
+
+ pub async fn send_poke(
+ &self,
+ sender_space_id: &str,
+ space_id: &str,
+ ) -> Result<MessageResponse> {
+ self.send_direct_message(
+ sender_space_id,
+ space_id,
+ MessagePayload {
+ version: 1,
+ kind: MESSAGE_KIND_POKE.to_owned(),
+ text: POKE_MESSAGE_TEXT.to_owned(),
+ },
+ Some(MESSAGE_NOTIFICATION_KIND_POKE),
+ )
+ .await
+ }
+
+ async fn send_direct_message(
+ &self,
+ sender_space_id: &str,
+ space_id: &str,
+ payload: MessagePayload,
+ notification_kind: Option<&str>,
) -> Result<MessageResponse> {
let friend = self
.friend_actor_for_space(sender_space_id, space_id)
.await?;
- let payload = MessagePayload {
- version: 1,
- kind: MESSAGE_KIND_REGULAR.to_owned(),
- text: text.to_owned(),
- };
let request = self
.message_request_for_payload(
sender_space_id,
&friend.public_key,
&payload,
None,
- (text == WAVE_MESSAGE_TEXT).then(|| MESSAGE_NOTIFICATION_KIND_WAVE.to_owned()),
+ notification_kind.map(str::to_owned),
)
.await?;
let path = format!("/spaces/{sender_space_id}/friends/{space_id}/messages");
diff --git a/rust/crates/space/src/client/mod.rs b/rust/crates/space/src/client/mod.rs
index 3a83763c34..14b76444cf 100644
--- a/rust/crates/space/src/client/mod.rs
+++ b/rust/crates/space/src/client/mod.rs
@@ -43,6 +43,7 @@ use ente_core::{
const UPLOAD_PURPOSE_AVATAR: &str = "avatar";
const UPLOAD_PURPOSE_COVER: &str = "cover";
const MESSAGE_KIND_REGULAR: &str = "regular";
+const MESSAGE_KIND_POKE: &str = "poke";
const MESSAGE_KIND_POST_REPLY: &str = "post_reply";
const ONLY_PHOTOS_UPLOAD_MESSAGE: &str = "only photos can be uploaded";
pub const MAX_SPACE_POST_UPLOAD_BYTES: usize = 5 * 1024 * 1024;
diff --git a/rust/crates/space/src/client/tests.rs b/rust/crates/space/src/client/tests.rs
index fac15f37f1..0b548f155a 100644
--- a/rust/crates/space/src/client/tests.rs
+++ b/rust/crates/space/src/client/tests.rs
@@ -1492,7 +1492,7 @@ async fn message_actions_use_message_endpoints() {
}
#[tokio::test]
-async fn wave_message_requests_special_notification() {
+async fn poke_message_requests_special_notification() {
let mut server = Server::new_async().await;
let space_root_key = generate_key();
let ctx = test_account_ctx_with_space_root_key(&server.url(), space_root_key);
@@ -1517,14 +1517,14 @@ async fn wave_message_requests_special_notification() {
)
.create_async()
.await;
- let wave = server
+ let poke = server
.mock(
"POST",
"/spaces/space_owner_main/friends/space_friend/messages",
)
.match_header("x-space-session-token", "space-session-token")
.match_body(Matcher::AllOf(vec![
- Matcher::Regex("\"notificationKind\":\"wave\"".into()),
+ Matcher::Regex("\"notificationKind\":\"poke\"".into()),
Matcher::Regex("\"messageCipher\":\"[^\"]+\"".into()),
Matcher::Regex("\"senderEncryptedMessageKey\":\"[^\"]+\"".into()),
Matcher::Regex("\"recipientEncryptedMessageKey\":\"[^\"]+\"".into()),
@@ -1532,7 +1532,7 @@ async fn wave_message_requests_special_notification() {
.with_status(200)
.with_body(
json!({
- "messageId": "wmsg_wave",
+ "messageId": "wmsg_poke",
"kind": "regular",
"senderSpaceId": "space_owner_main",
"recipientSpaceId": "space_friend",
@@ -1548,13 +1548,13 @@ async fn wave_message_requests_special_notification() {
.await;
let message = ctx
- .send_message("space_owner_main", "space_friend", "πŸ‘‹")
+ .send_poke("space_owner_main", "space_friend")
.await
- .expect("wave should be sent");
+ .expect("poke should be sent");
- assert_eq!(message.message_id, "wmsg_wave");
+ assert_eq!(message.message_id, "wmsg_poke");
friends.assert_async().await;
- wave.assert_async().await;
+ poke.assert_async().await;
}
#[test]
diff --git a/server/space/controller/messages.go b/server/space/controller/messages.go
index 86955a56d1..b337aec1e4 100644
--- a/server/space/controller/messages.go
+++ b/server/space/controller/messages.go
@@ -18,7 +18,7 @@ const (
spaceMessageKindPostLike = "post_like"
spaceMessageKindFriendAdded = "friend_added"
- spaceMessageNotificationKindWave = "wave"
+ spaceMessageNotificationKindPoke = "poke"
maxSpaceMessageCipherEncodedBytes = 8 * 1024
maxSpaceMessageCipherDecodedBytes = 6 * 1024
@@ -59,8 +59,8 @@ func (c *MessagesController) Create(ctx context.Context, senderSpace *repo.Space
if err != nil {
return nil, err
}
- if notificationKind == spaceMessageNotificationKindWave && replyMessageID.Valid {
- return nil, ente.NewBadRequestWithMessage("wave notification is not supported for replies")
+ if notificationKind == spaceMessageNotificationKindPoke && replyMessageID.Valid {
+ return nil, ente.NewBadRequestWithMessage("poke notification is not supported for replies")
}
message, err := c.MessagesRepo.CreateMessage(ctx, repo.CreateSpaceMessageRecord{
MessageID: messageID,
@@ -78,8 +78,8 @@ func (c *MessagesController) Create(ctx context.Context, senderSpace *repo.Space
}
return nil, err
}
- if notificationKind == spaceMessageNotificationKindWave {
- go c.ActivityNotifier.OnSpaceWaveSent(spaceActivityActor(senderSpace), recipientSpace.OwnerID)
+ if notificationKind == spaceMessageNotificationKindPoke {
+ go c.ActivityNotifier.OnSpacePokeSent(spaceActivityActor(senderSpace), recipientSpace.OwnerID)
} else {
go c.ActivityNotifier.OnSpaceMessageSent(spaceActivityActor(senderSpace), recipientSpace.OwnerID)
}
@@ -353,7 +353,7 @@ func normalizeOptionalMessageID(messageID string) (string, error) {
func normalizeMessageNotificationKind(notificationKind string) (string, error) {
notificationKind = strings.TrimSpace(notificationKind)
- if notificationKind == "" || notificationKind == spaceMessageNotificationKindWave {
+ if notificationKind == "" || notificationKind == spaceMessageNotificationKindPoke {
return notificationKind, nil
}
return "", ente.NewBadRequestWithMessage("notificationKind is invalid")
diff --git a/server/space/controller/messages_test.go b/server/space/controller/messages_test.go
index 69e11f4429..f2b57b0d28 100644
--- a/server/space/controller/messages_test.go
+++ b/server/space/controller/messages_test.go
@@ -58,14 +58,14 @@ func TestMessageReplyValidation(t *testing.T) {
require.Equal(t, bobMessage.MessageID, *reply.ReplyMessageID)
_, err = controller.Create(ctx, aliceSpace, bobSpace.SpaceID, models.CreateMessageRequest{
- MessageCipher: spaceTestB64("wave-reply-cipher"),
- SenderEncryptedMessageKey: spaceTestB64("wave-reply-sender-key"),
- RecipientEncryptedMessageKey: spaceTestB64("wave-reply-recipient-key"),
+ MessageCipher: spaceTestB64("poke-reply-cipher"),
+ SenderEncryptedMessageKey: spaceTestB64("poke-reply-sender-key"),
+ RecipientEncryptedMessageKey: spaceTestB64("poke-reply-recipient-key"),
ReplyMessageID: bobMessage.MessageID,
- NotificationKind: spaceMessageNotificationKindWave,
+ NotificationKind: spaceMessageNotificationKindPoke,
})
require.Error(t, err)
- require.Contains(t, err.Error(), "wave notification is not supported for replies")
+ require.Contains(t, err.Error(), "poke notification is not supported for replies")
require.NoError(t, repos.Messages.DeleteMessage(ctx, bobMessage.MessageID, bobSpace.SpaceID))
_, err = controller.Create(ctx, aliceSpace, bobSpace.SpaceID, models.CreateMessageRequest{
diff --git a/server/space/controller/notifications.go b/server/space/controller/notifications.go
index cf8f65844a..225ba574f9 100644
--- a/server/space/controller/notifications.go
+++ b/server/space/controller/notifications.go
@@ -26,7 +26,7 @@ const (
spaceActivityPostLiked = "post_liked"
spaceActivityPostReplied = "post_replied"
spaceActivityMessageSent = "message_sent"
- spaceActivityWaveSent = "wave_sent"
+ spaceActivityPokeSent = "poke_sent"
spaceActivityMessageLiked = "message_liked"
spaceActivityFriendAdded = "friend_added"
spaceActivityFriendRequested = "friend_requested"
@@ -59,7 +59,7 @@ type SpaceActivityNotifier interface {
OnSpacePostLiked(actor SpaceActivityActor, recipientUserID int64)
OnSpacePostReplied(actor SpaceActivityActor, recipientUserID int64)
OnSpaceMessageSent(actor SpaceActivityActor, recipientUserID int64)
- OnSpaceWaveSent(actor SpaceActivityActor, recipientUserID int64)
+ OnSpacePokeSent(actor SpaceActivityActor, recipientUserID int64)
OnSpaceMessageLiked(actor SpaceActivityActor, recipientUserID int64)
OnSpaceFriendAdded(actor SpaceActivityActor, recipientUserID int64)
OnSpaceFriendRequested(actor SpaceActivityActor, recipientUserID int64)
@@ -138,8 +138,8 @@ func (n *SpaceWebPushSender) OnSpaceMessageSent(actor SpaceActivityActor, recipi
n.sendAccountActivity(actor, "sent you a message", "Check it out", spaceActivityMessageSent, conversationURL(actor.SpaceID), recipientUserID)
}
-func (n *SpaceWebPushSender) OnSpaceWaveSent(actor SpaceActivityActor, recipientUserID int64) {
- n.sendAccountActivity(actor, "waved at you πŸ‘‹", "Post something", spaceActivityWaveSent, "/app/post", recipientUserID)
+func (n *SpaceWebPushSender) OnSpacePokeSent(actor SpaceActivityActor, recipientUserID int64) {
+ n.sendAccountActivity(actor, "poked you", "Post something", spaceActivityPokeSent, "/app/post", recipientUserID)
}
func (n *SpaceWebPushSender) OnSpaceMessageLiked(actor SpaceActivityActor, recipientUserID int64) {
diff --git a/server/space/controller/notifications_test.go b/server/space/controller/notifications_test.go
index 2b849b5ecf..8fce441553 100644
--- a/server/space/controller/notifications_test.go
+++ b/server/space/controller/notifications_test.go
@@ -53,8 +53,8 @@ func (n *recordingSpaceActivityNotifier) OnSpaceMessageSent(actor SpaceActivityA
n.record(spaceActivityMessageSent, actor, recipientUserID)
}
-func (n *recordingSpaceActivityNotifier) OnSpaceWaveSent(actor SpaceActivityActor, recipientUserID int64) {
- n.record(spaceActivityWaveSent, actor, recipientUserID)
+func (n *recordingSpaceActivityNotifier) OnSpacePokeSent(actor SpaceActivityActor, recipientUserID int64) {
+ n.record(spaceActivityPokeSent, actor, recipientUserID)
}
func (n *recordingSpaceActivityNotifier) OnSpaceMessageLiked(actor SpaceActivityActor, recipientUserID int64) {
@@ -251,12 +251,12 @@ func TestMessageActivitiesAndLikeTransition(t *testing.T) {
recipientIDs: []int64{bobID},
}, requireSpaceActivity(t, notifier))
- waveRequest := request
- waveRequest.NotificationKind = spaceMessageNotificationKindWave
- _, err = messages.Create(ctx, aliceSpace, bobSpace.SpaceID, waveRequest)
+ pokeRequest := request
+ pokeRequest.NotificationKind = spaceMessageNotificationKindPoke
+ _, err = messages.Create(ctx, aliceSpace, bobSpace.SpaceID, pokeRequest)
require.NoError(t, err)
require.Equal(t, recordedSpaceActivity{
- event: spaceActivityWaveSent,
+ event: spaceActivityPokeSent,
actorUserID: aliceID,
actorSpaceID: aliceSpace.SpaceID,
actorSlug: aliceSpace.SpaceSlug,
@@ -339,7 +339,7 @@ func TestFriendActivitiesOnlyOnRelationshipTransitions(t *testing.T) {
}, requireSpaceActivity(t, notifier))
}
-func TestSpaceWebPushSenderUsesWavePayloadAndPrunesDeadEndpoint(t *testing.T) {
+func TestSpaceWebPushSenderUsesPokePayloadAndPrunesDeadEndpoint(t *testing.T) {
_, repos, ctx := setupPostsControllerTest(t)
recipientID := insertSpaceControllerUser(t, repos, "[email protected]", "recipient-public")
sessionHash := []byte("space-push-session-hash")
@@ -363,10 +363,10 @@ func TestSpaceWebPushSenderUsesWavePayloadAndPrunesDeadEndpoint(t *testing.T) {
}
sender := NewSpaceWebPushSender(repos.WebPush, config)
- sender.OnSpaceWaveSent(SpaceActivityActor{UserID: 1, SpaceID: "alice_space", Slug: "alice"}, recipientID)
+ sender.OnSpacePokeSent(SpaceActivityActor{UserID: 1, SpaceID: "alice_space", Slug: "alice"}, recipientID)
require.Equal(t, spaceWebPushPayload{
Title: "Ente Space",
- Body: "@alice waved at you πŸ‘‹",
+ Body: "@alice poked you",
Action: "Post something",
URL: "/app/post",
}, payload)
diff --git a/server/space/controller/test_helpers_test.go b/server/space/controller/test_helpers_test.go
index b31733b15f..0ce6576418 100644
--- a/server/space/controller/test_helpers_test.go
+++ b/server/space/controller/test_helpers_test.go
@@ -32,7 +32,7 @@ func (noopSpaceActivityNotifier) OnSpacePostCreated(SpaceActivityActor)
func (noopSpaceActivityNotifier) OnSpacePostLiked(SpaceActivityActor, int64) {}
func (noopSpaceActivityNotifier) OnSpacePostReplied(SpaceActivityActor, int64) {}
func (noopSpaceActivityNotifier) OnSpaceMessageSent(SpaceActivityActor, int64) {}
-func (noopSpaceActivityNotifier) OnSpaceWaveSent(SpaceActivityActor, int64) {}
+func (noopSpaceActivityNotifier) OnSpacePokeSent(SpaceActivityActor, int64) {}
func (noopSpaceActivityNotifier) OnSpaceMessageLiked(SpaceActivityActor, int64) {}
func (noopSpaceActivityNotifier) OnSpaceFriendAdded(SpaceActivityActor, int64) {}
func (noopSpaceActivityNotifier) OnSpaceFriendRequested(SpaceActivityActor, int64) {}
diff --git a/web/apps/space/src/components/MessagesPage.tsx b/web/apps/space/src/components/MessagesPage.tsx
index 54550afdf4..f8a565be9b 100644
--- a/web/apps/space/src/components/MessagesPage.tsx
+++ b/web/apps/space/src/components/MessagesPage.tsx
@@ -21,6 +21,7 @@ import {
markCurrentMessagesRead,
replyToCurrentMessage,
sendCurrentMessage,
+ sendCurrentPoke,
setCurrentMessageLiked,
shouldAutoReadMessageActivities,
type SpaceMessage,
@@ -84,11 +85,13 @@ const currentProfileMessageActor = (
});
const createLocalMessage = ({
+ kind,
profile,
recipient,
replyMessageId,
text,
}: {
+ kind: SpaceMessage["kind"];
profile: SetupProfile;
recipient: SpaceMessageConversation["friend"];
replyMessageId?: string;
@@ -99,7 +102,7 @@ const createLocalMessage = ({
createdAtMs,
id: createLocalMessageID(),
isDeleted: false,
- kind: "regular",
+ kind,
liked: false,
recipient,
replyMessageId,
@@ -702,11 +705,44 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
onLoadActivityPost={(post) =>
loadCurrentMessageActivityPostPreview(post, actorSpaceId)
}
+ onSendPoke={async (spaceId) => {
+ const sender = currentProfileMessageActor(profile);
+ const recipient =
+ selectedFriend ?? placeholderFriend(spaceId);
+ const optimisticMessage = createLocalMessage({
+ kind: "poke",
+ profile,
+ recipient,
+ text: "Poked",
+ });
+ appendMessageIfThreadIsCurrent(spaceId, optimisticMessage);
+ try {
+ const message = await sendCurrentPoke(
+ actorSpaceId,
+ spaceId,
+ sender,
+ recipient,
+ );
+ replaceMessageIfThreadIsCurrent(
+ spaceId,
+ optimisticMessage.id,
+ message,
+ );
+ } catch (error) {
+ removeMessageIfThreadIsCurrent(
+ spaceId,
+ optimisticMessage.id,
+ );
+ throw error;
+ }
+ void refreshConversations();
+ }}
onSendMessage={async (spaceId, text) => {
const sender = currentProfileMessageActor(profile);
const recipient =
selectedFriend ?? placeholderFriend(spaceId);
const optimisticMessage = createLocalMessage({
+ kind: "regular",
profile,
recipient,
text,
@@ -739,6 +775,7 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({
const recipient =
selectedFriend ?? placeholderFriend(spaceId);
const optimisticMessage = createLocalMessage({
+ kind: "regular",
profile,
recipient,
replyMessageId: messageId,
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index 351e243e56..233ab0702e 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -2,7 +2,6 @@ import { SpaceFriendLimitToast } from "components/FriendLimitToast";
import { SpaceFriendRequestCanceledToast } from "components/FriendRequestCanceledToast";
import { SpacePageMeta } from "components/PageMeta";
import { SpaceRouteFallback } from "components/RouteFallback";
-import type { FriendProfile } from "data/friends";
import log from "ente-base/log";
import React, { useEffect, useState } from "react";
import { HomeScreen } from "screens/HomeScreen";
@@ -25,7 +24,6 @@ import {
loadCurrentSpacePostAssetURL,
loadCurrentUnreadStatus,
replyToCurrentPost,
- sendCurrentMessage,
setCurrentPostLiked,
type SpaceFriendRequest,
type SpacePost,
@@ -33,7 +31,6 @@ import {
import { useSpaceAppState } from "state/app-state";
import { spaceAppBackgroundColor } from "styles/colors";
import { maximumSpaceFriendCount } from "utils/friend-limits";
-import { spaceWaveMessageText } from "utils/message-limits";
import { useSpaceRouter } from "utils/route-transitions";
import { spaceRoutes } from "utils/routes";
@@ -198,29 +195,6 @@ const Page: React.FC = () => {
[spaceId],
);
- const waveAtFriend = async (friend: FriendProfile) => {
- if (!profile?.spaceId) throw new Error("Missing space.");
-
- await sendCurrentMessage(
- profile.spaceId,
- friend.spaceId ?? friend.id,
- spaceWaveMessageText,
- {
- avatarKeyVersion: profile.avatarKeyVersion,
- avatarObjectID: profile.avatarObjectID,
- avatarUpdatedAt: profile.avatarUpdatedAt,
- avatarUrl: profile.avatarUrl,
- friendsCount: 0,
- fullName: profile.fullName,
- id: profile.spaceId,
- spaceId: profile.spaceId,
- spaceSlug: profile.spaceSlug,
- username: profile.username,
- },
- friend,
- );
- };
-
if (
profileLoadStatus == "error" ||
(profileLoadStatus == "ready" && !profile)
@@ -400,7 +374,6 @@ const Page: React.FC = () => {
: undefined
}
onSetPostLiked={setLatestPostLiked}
- onWaveFriend={profile?.spaceId ? waveAtFriend : undefined}
/>
{showFriendRequestCanceledToast && (
<SpaceFriendRequestCanceledToast
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index dbfa797e40..6130d1c2f5 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -65,9 +65,6 @@ const avatarFallbackTextColor = "#FFFFFF";
const mediaPlaceholderColor = spaceHomeHeaderChromeColor;
const homeHorizontalPadding = "16px";
const postTileMediaLoadRootMargin = "640px 0px";
-const waveAnimationDurationMs = 1100;
-const waveHoldDurationMs = 500;
-const waveHoldMovementTolerancePx = 12;
interface HomeScreenProps {
latestPosts: SpacePost[];
unreadPosts: SpacePost[];
@@ -98,7 +95,6 @@ interface HomeScreenProps {
text: string,
) => Promise<void>;
onSetPostLiked?: (postId: number, liked: boolean) => Promise<void>;
- onWaveFriend?: (friend: FriendProfile) => Promise<void>;
profile: SetupProfile | null;
profileLink?: string;
viewerSpaceId?: string;
@@ -259,7 +255,6 @@ interface FriendPostTileProps {
posts: SpacePost[],
photo: SpaceViewerPhoto,
) => void;
- onWave?: () => Promise<void>;
isTwoTileLayout?: boolean;
placement?: HomeTilePlacement;
posts: SpacePost[];
@@ -282,26 +277,16 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
onOpenFriend,
onOpenFriendRequest,
onOpenPosts,
- onWave,
isTwoTileLayout = false,
placement,
posts,
showFriendRequestDetails = false,
}) => {
const rootRef = React.useRef<HTMLLIElement | null>(null);
- const holdOriginRef = React.useRef<
- { pointerID: number; x: number; y: number } | undefined
- >(undefined);
- const holdTimeoutRef = React.useRef<number | undefined>(undefined);
- const suppressClickRef = React.useRef(false);
- const waveAnimationTimeoutRef = React.useRef<number | undefined>(undefined);
const [shouldLoadMedia, setShouldLoadMedia] = useState(Boolean(imageUrl));
- const [isHoldingWave, setIsHoldingWave] = useState(false);
- const [isWaveSending, setIsWaveSending] = useState(false);
const [friendRequestAction, setFriendRequestAction] = useState<
"accept" | "discard" | null
>(null);
- const [waveAnimationID, setWaveAnimationID] = useState(0);
const decodedPhoto = useDecodedImage(imageUrl, true);
const decodedAvatar = useDecodedImage(
avatarUrl ?? friend.avatarUrl ?? null,
@@ -428,34 +413,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
shouldLoadMedia,
]);
- React.useEffect(
- () => () => {
- if (holdTimeoutRef.current !== undefined) {
- window.clearTimeout(holdTimeoutRef.current);
- }
- if (waveAnimationTimeoutRef.current !== undefined) {
- window.clearTimeout(waveAnimationTimeoutRef.current);
- }
- },
- [],
- );
-
- const cancelWaveHold = () => {
- if (holdTimeoutRef.current !== undefined) {
- window.clearTimeout(holdTimeoutRef.current);
- holdTimeoutRef.current = undefined;
- }
- holdOriginRef.current = undefined;
- setIsHoldingWave(false);
- };
-
- const suppressPendingClick = () => {
- suppressClickRef.current = true;
- window.setTimeout(() => {
- suppressClickRef.current = false;
- }, 0);
- };
-
const updateFriendRequest = (
action: "accept" | "discard",
handler?: () => Promise<void>,
@@ -469,74 +426,7 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
.finally(() => setFriendRequestAction(null));
};
- const handlePointerDown: React.PointerEventHandler<HTMLButtonElement> = (
- event,
- ) => {
- if (isWaveSending || !onWave || !event.isPrimary || event.button != 0) {
- return;
- }
-
- cancelWaveHold();
- holdOriginRef.current = {
- pointerID: event.pointerId,
- x: event.clientX,
- y: event.clientY,
- };
- setIsHoldingWave(true);
- holdTimeoutRef.current = window.setTimeout(() => {
- holdTimeoutRef.current = undefined;
- suppressClickRef.current = true;
- setIsHoldingWave(false);
- setWaveAnimationID((currentID) => currentID + 1);
- if (waveAnimationTimeoutRef.current !== undefined) {
- window.clearTimeout(waveAnimationTimeoutRef.current);
- }
- waveAnimationTimeoutRef.current = window.setTimeout(() => {
- waveAnimationTimeoutRef.current = undefined;
- setWaveAnimationID(0);
- }, waveAnimationDurationMs);
- setIsWaveSending(true);
- void onWave()
- .catch((error: unknown) =>
- log.error("Failed to send wave", error),
- )
- .finally(() => setIsWaveSending(false));
- }, waveHoldDurationMs);
- };
-
- const handlePointerMove: React.PointerEventHandler<HTMLButtonElement> = (
- event,
- ) => {
- const origin = holdOriginRef.current;
- if (origin?.pointerID != event.pointerId) return;
-
- const bounds = event.currentTarget.getBoundingClientRect();
- const moved =
- Math.hypot(event.clientX - origin.x, event.clientY - origin.y) >
- waveHoldMovementTolerancePx;
- const outside =
- event.clientX < bounds.left ||
- event.clientX > bounds.right ||
- event.clientY < bounds.top ||
- event.clientY > bounds.bottom;
- if (!moved && !outside) return;
-
- cancelWaveHold();
- suppressClickRef.current = true;
- };
-
- const handlePointerEnd: React.PointerEventHandler<
- HTMLButtonElement
- > = () => {
- cancelWaveHold();
- if (suppressClickRef.current) suppressPendingClick();
- };
-
const openTile = () => {
- if (suppressClickRef.current) {
- suppressClickRef.current = false;
- return;
- }
if (isRequestPending) {
if (friendRequestDirection == "sent") onOpenFriendRequest?.();
return;
@@ -565,10 +455,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
};
const openFriend = () => {
- if (suppressClickRef.current) {
- suppressClickRef.current = false;
- return;
- }
if (isRequestPending) {
onOpenFriendRequest?.();
return;
@@ -589,14 +475,12 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
minWidth: 0,
position: placement ? "absolute" : "relative",
transition: placement
- ? "left 420ms cubic-bezier(0.2, 0.8, 0.2, 1), top 420ms cubic-bezier(0.2, 0.8, 0.2, 1), width 420ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 160ms ease-out"
- : "transform 160ms ease-out",
- transform: isHoldingWave ? "scale(0.98)" : "scale(1)",
+ ? "left 420ms cubic-bezier(0.2, 0.8, 0.2, 1), top 420ms cubic-bezier(0.2, 0.8, 0.2, 1), width 420ms cubic-bezier(0.2, 0.8, 0.2, 1)"
+ : "none",
width: placement?.size ?? "100%",
...(placement && { left: placement.x, top: placement.y }),
"@media (prefers-reduced-motion: reduce)": {
transition: "none",
- transform: "none",
},
}}
>
@@ -620,13 +504,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
}
disabled={isTileDisabled}
onClick={openTile}
- onContextMenu={(event) => {
- if (onWave) event.preventDefault();
- }}
- onPointerCancel={handlePointerEnd}
- onPointerDown={handlePointerDown}
- onPointerMove={handlePointerMove}
- onPointerUp={handlePointerEnd}
sx={{
alignItems: "center",
appearance: "none",
@@ -643,8 +520,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
overflow: "hidden",
p: 0,
position: "relative",
- userSelect: "none",
- WebkitTouchCallout: "none",
width: "100%",
zIndex: 1,
}}
@@ -807,13 +682,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
}
disabled={!canOpenFriend || isFriendRequestActionBusy}
onClick={openFriend}
- onContextMenu={(event) => {
- if (onWave) event.preventDefault();
- }}
- onPointerCancel={handlePointerEnd}
- onPointerDown={handlePointerDown}
- onPointerMove={handlePointerMove}
- onPointerUp={handlePointerEnd}
sx={{
appearance: "none",
bgcolor: "transparent",
@@ -1111,61 +979,6 @@ export const FriendPostTile: React.FC<FriendPostTileProps> = ({
)}
</Box>
)}
- {waveAnimationID > 0 && (
- <Box
- key={waveAnimationID}
- component="span"
- aria-hidden
- sx={{
- "@keyframes spaceHomeWaveSent": {
- "0%": {
- opacity: 0,
- transform:
- "translateY(9px) scale(0.65) rotate(0deg)",
- },
- "12%": {
- opacity: 1,
- transform:
- "translateY(0) scale(1.1) rotate(-22deg)",
- },
- "32%": {
- transform:
- "translateY(-2px) scale(1.1) rotate(22deg)",
- },
- "52%": {
- transform:
- "translateY(-5px) scale(1.08) rotate(-20deg)",
- },
- "72%": {
- opacity: 1,
- transform:
- "translateY(-9px) scale(1.05) rotate(17deg)",
- },
- "100%": {
- opacity: 0,
- transform:
- "translateY(-20px) scale(0.92) rotate(0deg)",
- },
- },
- animation: `spaceHomeWaveSent ${waveAnimationDurationMs}ms ease-out both`,
- bottom: "8%",
- fontSize: placement
- ? Math.max(32, Math.min(54, placement.size * 0.27))
- : 38,
- lineHeight: 1,
- pointerEvents: "none",
- position: "absolute",
- right: "8%",
- transformOrigin: "70% 75%",
- zIndex: 3,
- "@media (prefers-reduced-motion: reduce)": {
- animation: "none",
- },
- }}
- >
- πŸ‘‹
- </Box>
- )}
</Box>
);
};
@@ -1208,7 +1021,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
onOpenProfile,
onReplyToPost,
onSetPostLiked,
- onWaveFriend,
profile,
profileLink,
viewerSpaceId,
@@ -1643,7 +1455,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}
onOpenFriend={onOpenFriend}
onOpenPosts={openPostPhotos}
- onWave={onWaveFriend ? () => onWaveFriend(friend) : undefined}
placement={placement}
posts={posts}
/>
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index ee11cb13dd..2967991453 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -2,6 +2,7 @@ import {
ArrowLeft02Icon,
Cancel01Icon,
FavouriteIcon,
+ HandPointingRightIcon,
ImageDelete02Icon,
Navigation03Icon,
} from "@hugeicons/core-free-icons";
@@ -39,10 +40,7 @@ import {
} from "styles/colors";
import { spaceTouchTargetSize } from "styles/touch-targets";
import { firstNameFrom } from "utils/display";
-import {
- clampSpaceMessageText,
- spaceWaveMessageText,
-} from "utils/message-limits";
+import { clampSpaceMessageText } from "utils/message-limits";
import { spacePostImageInputAccept } from "utils/post-image";
const green = "#08C225";
@@ -76,9 +74,6 @@ const messageLongPressMs = 520;
const messageLongPressMoveTolerancePx = 10;
const messageActionsTouchOpenMouseSuppressMs = 900;
const dayMs = 24 * 60 * 60 * 1000;
-const isWaveMessageText = (text: string | undefined) =>
- text?.trim() == spaceWaveMessageText;
-
const shouldShowPostSomething = (
conversation: SpaceMessageConversation,
latestPostCreatedAtMs: number | null | undefined,
@@ -91,7 +86,7 @@ const shouldShowPostSomething = (
(activity.type == "message" || activity.type == "post_reply") &&
!activity.outgoing &&
!activity.isUnavailable &&
- isWaveMessageText(activity.text)
+ activity.kind == "poke"
);
};
@@ -127,6 +122,7 @@ interface MessagesScreenProps {
messageId: string,
text: string,
) => Promise<void>;
+ onSendPoke: (spaceId: string) => Promise<void>;
onSendMessage: (spaceId: string, text: string) => Promise<void>;
onSetMessageLiked: (messageId: string, liked: boolean) => Promise<void>;
profileLink?: string;
@@ -245,6 +241,9 @@ const conversationPreview = (conversation: SpaceMessageConversation) => {
? "You liked a message"
: "Liked a message";
}
+ if (activity.kind == "poke") {
+ return activity.outgoing ? "You poked" : "Poked you";
+ }
if (text) {
return activity.outgoing ? `You: ${text}` : text;
}
@@ -927,7 +926,11 @@ const bodyBubblesCanGroup = (
if (!first || !second) return false;
if (!sameMessageSender(first, second)) return false;
if (first.kind == "post_like" || first.kind == "friend_added") return false;
- if (second.kind != "regular" || second.replyMessageId) return false;
+ if (
+ (second.kind != "regular" && second.kind != "poke") ||
+ second.replyMessageId
+ )
+ return false;
if (
!isSameLocalDate(
new Date(first.createdAtMs),
@@ -1394,7 +1397,8 @@ const MessageBubble: React.FC<{
}) => {
const isOwn = message.sender.spaceId == ownSpaceID;
const isUnavailable = Boolean(message.isUnavailable);
- const isWave = !isUnavailable && isWaveMessageText(message.text);
+ const isPoke = !isUnavailable && message.kind == "poke";
+ const pokeText = isOwn ? "You poked" : "Poked you";
const bubbleBorderRadius = isOwn
? `20px ${groupsWithPrevious ? "6px" : "20px"} ${groupsWithNext ? "6px" : "20px"} 20px`
: `${groupsWithPrevious ? "6px" : "20px"} 20px 20px ${groupsWithNext ? "6px" : "20px"}`;
@@ -1620,19 +1624,22 @@ const MessageBubble: React.FC<{
: incomingMessageText,
fontFamily:
'"Inter Variable", Inter, sans-serif',
- fontSize: isWave ? 40 : 14,
- fontStyle: isUnavailable
- ? "italic"
- : "normal",
+ fontStyle:
+ isUnavailable || isPoke
+ ? "italic"
+ : "normal",
+ fontSize: 14,
fontWeight: 600,
- lineHeight: isWave ? "48px" : "21px",
+ lineHeight: "21px",
overflowWrap: "anywhere",
whiteSpace: "pre-wrap",
}}
>
{isUnavailable
? "Message unavailable"
- : message.text}
+ : isPoke
+ ? pokeText
+ : message.text}
</Box>
{!isUnavailable && message.liked && (
<Box
@@ -1686,6 +1693,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
onPostPhotoSelect,
onLoadActivityPost,
onReplyToMessage,
+ onSendPoke,
onSendMessage,
onSetMessageLiked,
profile,
@@ -1725,6 +1733,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
isThreadOpen && !isThreadReadOnly && !isThreadRecipientLoading;
const canSend =
canInteract && messageText.trim().length > 0 && sendPhase == "idle";
+ const canPoke = canInteract && sendPhase == "idle";
const selectedName = selectedFriend
? selectedFriend.fullName.trim() || selectedFriend.username
: "";
@@ -1794,10 +1803,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
messageContextMenu?.message &&
isCurrentProfileMessage(messageContextMenu.message, profile),
);
- const isContextMessageWave = Boolean(
- messageContextMenu?.message &&
- isWaveMessageText(messageContextMenu.message.text),
- );
+ const isContextMessagePoke = messageContextMenu?.message.kind == "poke";
const handlePostPhotoSelect: React.ChangeEventHandler<HTMLInputElement> = (
event,
@@ -1836,13 +1842,28 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
});
};
+ const sendPoke = () => {
+ if (!selectedFriend || !canPoke) return;
+ const spaceId = selectedFriend.spaceId ?? selectedFriend.id;
+ stickToThreadBottomRef.current = true;
+ smoothNextMessageScrollRef.current = true;
+ setSendPhase("sending");
+ void onSendPoke(spaceId)
+ .then(() => setSendPhase("idle"))
+ .catch((error: unknown) => {
+ smoothNextMessageScrollRef.current = false;
+ log.error("Failed to send poke", error);
+ setSendPhase("idle");
+ });
+ };
+
const openMessageActions = (
message: SpaceMessage,
anchorEl: HTMLElement,
source: MessageActionsOpenSource,
) => {
if (
- isWaveMessageText(message.text) &&
+ message.kind == "poke" &&
(!canInteract || !isCurrentProfileMessage(message, profile))
) {
return;
@@ -2069,7 +2090,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
);
const messageActionMenuItems = [
- !isContextMessageWave && canInteract && !isContextMessageOwn ? (
+ !isContextMessagePoke && canInteract && !isContextMessageOwn ? (
<MessageActionMenuItem
key="like"
icon={<HeartIcon small />}
@@ -2077,7 +2098,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
onClick={() => handleMessageAction("like")}
/>
) : null,
- !isContextMessageWave && canInteract ? (
+ !isContextMessagePoke && canInteract ? (
<MessageActionMenuItem
key="reply"
icon={<ReplyIcon />}
@@ -2085,7 +2106,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
onClick={() => handleMessageAction("reply")}
/>
) : null,
- !isContextMessageWave ? (
+ !isContextMessagePoke ? (
<MessageActionMenuItem
key="copy"
icon={<CopyIcon />}
@@ -2281,7 +2302,49 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
Messages
</Box>
)}
- <Box aria-hidden />
+ {isThreadOpen && selectedFriend && canInteract ? (
+ <Box
+ component="button"
+ type="button"
+ aria-label={
+ selectedName
+ ? `Poke ${selectedName}`
+ : "Send poke"
+ }
+ disabled={!canPoke}
+ onClick={sendPoke}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ borderRadius: "50%",
+ color: "inherit",
+ cursor: canPoke ? "pointer" : "default",
+ display: "flex",
+ height: spaceTouchTargetSize,
+ justifyContent: "center",
+ justifySelf: "end",
+ lineHeight: 1,
+ mr: "-8px",
+ opacity: canPoke ? 1 : 0.5,
+ p: 0,
+ width: spaceTouchTargetSize,
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={HandPointingRightIcon}
+ size={24}
+ strokeWidth={1.8}
+ />
+ </Box>
+ ) : (
+ <Box aria-hidden />
+ )}
</Box>
{isThreadOpen && selectedFriend ? (
@@ -2298,7 +2361,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
py: "12px",
}}
>
- {isThreadLoading ? (
+ {isThreadLoading || isThreadRecipientLoading ? (
<Box
sx={{
alignItems: "center",
diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsx
index 8947df5d86..a5ffa1499d 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -1389,7 +1389,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
<HugeiconsIcon
icon={BubbleChatIcon}
size={20}
- strokeWidth={1.8}
+ strokeWidth={2}
/>
</Box>
) : (
diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.ts
index 627bf65396..bb806638c2 100644
--- a/web/apps/space/src/services/space.ts
+++ b/web/apps/space/src/services/space.ts
@@ -106,6 +106,7 @@ type SpaceMessageConversationActivityType =
interface SpaceMessageConversationActivity {
createdAt: string;
id: string;
+ kind?: SpaceMessageKindResponse;
messageId?: string;
outgoing?: boolean;
postId?: number;
@@ -123,6 +124,7 @@ interface SpaceFriend {
type SpaceMessageKindResponse =
| "friend_added"
+ | "poke"
| "post_like"
| "post_reply"
| "regular";
@@ -307,6 +309,7 @@ export interface SpaceMessageActivityPost {
export interface SpaceMessageActivity {
createdAtMs: number;
id: string;
+ kind?: SpaceMessageKind;
messageId?: string;
outgoing: boolean;
post?: SpaceMessageActivityPost;
@@ -975,6 +978,7 @@ const messageActivityFromSpaceActivity = (
return {
createdAtMs: timestampMsFromSpaceDate(activity.createdAt),
id: activity.id,
+ kind: activity.kind || undefined,
messageId: activity.messageId,
outgoing: Boolean(activity.outgoing),
post,
@@ -984,21 +988,20 @@ const messageActivityFromSpaceActivity = (
};
};
-const isWaveMessageActivity = (activity: SpaceMessageActivity) =>
- (activity.type == "message" || activity.type == "post_reply") &&
- activity.text?.trim() == "πŸ‘‹";
+const isPokeMessageActivity = (activity: SpaceMessageActivity) =>
+ activity.kind == "poke";
const isPassiveAutoReadMessageActivity = (activity: SpaceMessageActivity) =>
activity.type == "friend_added" ||
activity.type == "message_like" ||
activity.type == "post_like" ||
- isWaveMessageActivity(activity);
+ isPokeMessageActivity(activity);
const messageConversationUnreadCount = (activities: SpaceMessageActivity[]) => {
const onlyActivity = activities.length == 1 ? activities[0] : undefined;
if (
onlyActivity?.type == "post_like" ||
- (onlyActivity && isWaveMessageActivity(onlyActivity))
+ (onlyActivity && isPokeMessageActivity(onlyActivity))
) {
return 0;
}
@@ -1420,6 +1423,29 @@ export const sendCurrentMessage = async (
}
};
+export const sendCurrentPoke = async (
+ senderSpaceId: string,
+ spaceId: string,
+ sender: FriendProfile,
+ recipient: FriendProfile,
+) => {
+ const ctx = await ensureCurrentSpaceContext();
+ try {
+ return await messageFromSpaceMessage(
+ ctx,
+ (await ctx.sendPoke(
+ senderSpaceId,
+ spaceId,
+ )) as SpaceMessageResponse,
+ true,
+ senderSpaceId,
+ { friend: recipient, viewer: sender },
+ );
+ } finally {
+ releaseCurrentSpaceContext(ctx);
+ }
+};
+
export const replyToCurrentMessage = async (
senderSpaceId: string,
spaceId: string,
@@ -1502,8 +1528,8 @@ export const loadCurrentMessageConversations = async (
.map(messageActivityFromSpaceActivity)
.map((activity) =>
activity.id == latestActivity?.id &&
- isWaveMessageActivity(latestActivity)
- ? { ...activity, text: latestActivity.text }
+ isPokeMessageActivity(latestActivity)
+ ? { ...activity, kind: "poke" as const }
: activity,
)
: [];
diff --git a/web/apps/space/src/utils/message-limits.ts b/web/apps/space/src/utils/message-limits.ts
index 37ce477e3c..91e8da789a 100644
--- a/web/apps/space/src/utils/message-limits.ts
+++ b/web/apps/space/src/utils/message-limits.ts
@@ -1,5 +1,4 @@
export const spaceMessageTextMaxLength = 1000;
-export const spaceWaveMessageText = "πŸ‘‹";
export const clampSpaceMessageText = (text: string) =>
Array.from(text).slice(0, spaceMessageTextMaxLength).join("");