@blocklet/discuss-kit-ux 1.6.222 → 1.6.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/avatars/author-info.d.ts +2 -1
- package/dist/components/chat/chat-client.d.ts +11 -0
- package/dist/components/chat/chat-in-wallet.d.ts +7 -0
- package/dist/components/chat/chat-list-in-wallet.d.ts +7 -0
- package/dist/components/chat/chat-list.d.ts +2 -1
- package/dist/components/chat/chat-room.d.ts +2 -1
- package/dist/components/chat/context.d.ts +5 -2
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/user-search.d.ts +7 -0
- package/dist/{editor-Bv0IhrR_.mjs → editor-xw6iQCuH.mjs} +1 -1
- package/dist/{index-BHZcv0rr.mjs → index-BYwPg7XF.mjs} +370 -69
- package/dist/index.es.js +35 -33
- package/dist/index.umd.js +335 -35
- package/package.json +7 -6
|
@@ -19,7 +19,7 @@ import joinUrl from "url-join";
|
|
|
19
19
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
20
20
|
import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
|
|
21
21
|
import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
|
|
22
|
-
import { useSize, useInViewport, useSetState, useGetState, useReactive } from "ahooks";
|
|
22
|
+
import { useSize, useInViewport, useSetState, useRequest, useGetState, useReactive } from "ahooks";
|
|
23
23
|
import LoadingButton from "@mui/lab/LoadingButton";
|
|
24
24
|
import { Send, Save, ChatBubbleOutlineOutlined, MoreVert, NavigateNext, DeleteOutlineOutlined, ContentCopy, ArrowUpward, ArrowDownward, ArrowBackIos, Add, BorderColorOutlined } from "@mui/icons-material";
|
|
25
25
|
import { LocaleContext, useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
@@ -32,7 +32,7 @@ import { grey, green, amber } from "@mui/material/colors";
|
|
|
32
32
|
import useMediaQuery$1 from "@mui/material/useMediaQuery";
|
|
33
33
|
import DID from "@arcblock/ux/lib/DID";
|
|
34
34
|
import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
|
|
35
|
-
import { Link, useNavigate, useLocation, useSearchParams, useBlocker
|
|
35
|
+
import { Link, useNavigate, useLocation, useParams, useSearchParams, useBlocker } from "react-router-dom";
|
|
36
36
|
import UxRelativeTime from "@arcblock/ux/lib/RelativeTime";
|
|
37
37
|
import Chip from "@mui/material/Chip";
|
|
38
38
|
import Stack from "@mui/material/Stack";
|
|
@@ -43,9 +43,9 @@ import trim from "lodash/trim";
|
|
|
43
43
|
import Avatar$1 from "@mui/material/Avatar";
|
|
44
44
|
import BrokenImageIcon from "@mui/icons-material/BrokenImage";
|
|
45
45
|
import { Icon } from "@iconify/react";
|
|
46
|
-
import Empty$
|
|
46
|
+
import Empty$3 from "@arcblock/ux/lib/Empty";
|
|
47
47
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
48
|
-
import { useTheme as useTheme$1, useMediaQuery, Box as Box$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Divider, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
48
|
+
import { useTheme as useTheme$1, useMediaQuery, Box as Box$1, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Divider, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Autocomplete, Typography as Typography$1, TextField as TextField$1, InputAdornment, Backdrop, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
49
49
|
import NotificationsActiveOutlinedIcon from "@mui/icons-material/NotificationsActiveOutlined";
|
|
50
50
|
import CheckboxPlugin from "@blocklet/editor/lib/ext/CheckboxPlugin";
|
|
51
51
|
import DIDAddress from "@arcblock/did-connect/lib/Address";
|
|
@@ -57,7 +57,7 @@ import Dialog from "@arcblock/ux/lib/Dialog";
|
|
|
57
57
|
import orderBy from "lodash/orderBy";
|
|
58
58
|
import Typography from "@mui/material/Typography";
|
|
59
59
|
import Skeleton$1 from "@mui/material/Skeleton";
|
|
60
|
-
import { createPortal } from "react-dom";
|
|
60
|
+
import ReactDOM, { createPortal } from "react-dom";
|
|
61
61
|
import dayjs from "dayjs";
|
|
62
62
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
63
63
|
import mitt from "mitt";
|
|
@@ -65,6 +65,7 @@ import CircularProgress from "@mui/material/CircularProgress";
|
|
|
65
65
|
import { Helmet } from "react-helmet";
|
|
66
66
|
import { Flipper, Flipped } from "react-flip-toolkit";
|
|
67
67
|
import grey$1 from "@mui/material/colors/grey";
|
|
68
|
+
import bridge from "@arcblock/bridge";
|
|
68
69
|
import Fab from "@mui/material/Fab";
|
|
69
70
|
import debounce from "lodash/debounce";
|
|
70
71
|
import TextField from "@mui/material/TextField";
|
|
@@ -855,7 +856,7 @@ function EmptyStatus() {
|
|
|
855
856
|
flexDirection: "column",
|
|
856
857
|
alignItems: "cetner",
|
|
857
858
|
justifyContent: "center",
|
|
858
|
-
children: /* @__PURE__ */ jsx(Empty$
|
|
859
|
+
children: /* @__PURE__ */ jsx(Empty$3, { children: t("profile.empty") })
|
|
859
860
|
}
|
|
860
861
|
);
|
|
861
862
|
}
|
|
@@ -1007,7 +1008,8 @@ function Badge({
|
|
|
1007
1008
|
}
|
|
1008
1009
|
},
|
|
1009
1010
|
...restProps
|
|
1010
|
-
}
|
|
1011
|
+
},
|
|
1012
|
+
badgeName
|
|
1011
1013
|
);
|
|
1012
1014
|
})
|
|
1013
1015
|
},
|
|
@@ -1216,6 +1218,7 @@ function AuthorInfo({
|
|
|
1216
1218
|
newTitle = void 0,
|
|
1217
1219
|
profileUse = false,
|
|
1218
1220
|
children,
|
|
1221
|
+
linkToProfile = true,
|
|
1219
1222
|
...rest
|
|
1220
1223
|
}) {
|
|
1221
1224
|
const theme = useTheme();
|
|
@@ -1241,6 +1244,9 @@ function AuthorInfo({
|
|
|
1241
1244
|
};
|
|
1242
1245
|
const click = (e) => {
|
|
1243
1246
|
var _a2, _b2;
|
|
1247
|
+
if (!linkToProfile) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1244
1250
|
(_a2 = e == null ? void 0 : e.stopPropagation) == null ? void 0 : _a2.call(e);
|
|
1245
1251
|
(_b2 = e == null ? void 0 : e.preventDefault) == null ? void 0 : _b2.call(e);
|
|
1246
1252
|
setOpen(false);
|
|
@@ -3561,6 +3567,10 @@ class ChatClient {
|
|
|
3561
3567
|
this.emitter.on("deleteChannel", callback);
|
|
3562
3568
|
return () => this.emitter.off("deleteChannel", callback);
|
|
3563
3569
|
}
|
|
3570
|
+
onUpdateLastAckTime(callback) {
|
|
3571
|
+
this.emitter.on("updateLastAckTime", callback);
|
|
3572
|
+
return () => this.emitter.off("updateLastAckTime", callback);
|
|
3573
|
+
}
|
|
3564
3574
|
}
|
|
3565
3575
|
const iconoirChatBubbleEmpty = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12c0 1.821.487 3.53 1.338 5L2.5 21.5l4.5-.838A9.955 9.955 0 0 0 12 22Z" }) });
|
|
3566
3576
|
const UnreadNotificationContext = createContext(
|
|
@@ -3597,7 +3607,7 @@ const uniqAndSort = (list, order = "asc") => {
|
|
|
3597
3607
|
const sorted = orderBy(unique, ["createdAt", "id"], [order, order]);
|
|
3598
3608
|
return sorted;
|
|
3599
3609
|
};
|
|
3600
|
-
function ChatProvider({ client: client2, activeChatId, children }) {
|
|
3610
|
+
function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
|
|
3601
3611
|
const [state, setState] = useSetState({
|
|
3602
3612
|
initialized: false,
|
|
3603
3613
|
chats: [],
|
|
@@ -3634,9 +3644,11 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3634
3644
|
return { ...prev, chats };
|
|
3635
3645
|
});
|
|
3636
3646
|
};
|
|
3637
|
-
const updateLastAckTime = async (chatId) => {
|
|
3647
|
+
const updateLastAckTime = async (chatId, clientOnly) => {
|
|
3638
3648
|
updateChat(chatId, (chat) => ({ ...chat, lastAckTime: chat.lastMessageAt }));
|
|
3639
|
-
|
|
3649
|
+
if (!clientOnly) {
|
|
3650
|
+
await client2.updateLastAckTime(chatId);
|
|
3651
|
+
}
|
|
3640
3652
|
};
|
|
3641
3653
|
const addMessage = (chatId, message) => {
|
|
3642
3654
|
updateChat(chatId, (chat) => ({
|
|
@@ -3661,7 +3673,11 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3661
3673
|
const chatId = chat == null ? void 0 : chat.id;
|
|
3662
3674
|
setState((prev) => ({ ...prev, activeChatId: chatId }));
|
|
3663
3675
|
if (chatId) {
|
|
3664
|
-
|
|
3676
|
+
if (isInWallet) {
|
|
3677
|
+
navigate(`/chat-in-wallet/${chatId}`, { replace: true });
|
|
3678
|
+
} else {
|
|
3679
|
+
navigate(`/chat/${chatId}`, { replace: true });
|
|
3680
|
+
}
|
|
3665
3681
|
updateChat(chatId, (origin) => ({
|
|
3666
3682
|
...origin,
|
|
3667
3683
|
isActivated: true
|
|
@@ -3673,6 +3689,22 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3673
3689
|
navigate("/chat", { replace: true });
|
|
3674
3690
|
}
|
|
3675
3691
|
};
|
|
3692
|
+
const setActiveChatInWallet = (chat) => {
|
|
3693
|
+
const chatId = chat == null ? void 0 : chat.id;
|
|
3694
|
+
setState((prev) => ({ ...prev, activeChatId: chatId }));
|
|
3695
|
+
if (chatId) {
|
|
3696
|
+
navigate(`/chat-in-wallet/${chatId}`, { replace: true });
|
|
3697
|
+
updateChat(chatId, (origin) => ({
|
|
3698
|
+
...origin,
|
|
3699
|
+
isActivated: true
|
|
3700
|
+
}));
|
|
3701
|
+
if ((chat.type !== "channel" || chat.hasJoined) && hasUnreadMessages(chat)) {
|
|
3702
|
+
updateLastAckTime(chatId);
|
|
3703
|
+
}
|
|
3704
|
+
} else {
|
|
3705
|
+
navigate("/chat-in-wallet", { replace: true });
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3676
3708
|
const addChat = (chat) => {
|
|
3677
3709
|
setState((prev) => ({ ...prev, chats: uniqAndSort([...state.chats, chat]) }));
|
|
3678
3710
|
};
|
|
@@ -3691,7 +3723,7 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3691
3723
|
const sendMessage = async (chatId, content) => {
|
|
3692
3724
|
const saved = await client2.sendMessage(chatId, content);
|
|
3693
3725
|
addMessage(chatId, saved);
|
|
3694
|
-
updateLastAckTime(chatId);
|
|
3726
|
+
updateLastAckTime(chatId, true);
|
|
3695
3727
|
};
|
|
3696
3728
|
const getLastMessageText = (chat) => {
|
|
3697
3729
|
const lastMessage = chat && chat.messages && chat.messages[chat.messages.length - 1];
|
|
@@ -3763,9 +3795,10 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3763
3795
|
setState({ error: e.message });
|
|
3764
3796
|
}
|
|
3765
3797
|
};
|
|
3766
|
-
const
|
|
3767
|
-
client2.
|
|
3768
|
-
|
|
3798
|
+
const createDM = async (oppositeUserDid) => {
|
|
3799
|
+
const chat = await client2.createDM(oppositeUserDid);
|
|
3800
|
+
addChat(chat);
|
|
3801
|
+
return chat;
|
|
3769
3802
|
};
|
|
3770
3803
|
useEffect(() => {
|
|
3771
3804
|
if (currentUser == null ? void 0 : currentUser.did) {
|
|
@@ -3796,14 +3829,17 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3796
3829
|
const cancels = [
|
|
3797
3830
|
client2.onMessage(({ chatId, message }) => {
|
|
3798
3831
|
addMessage(chatId, message);
|
|
3799
|
-
if (
|
|
3832
|
+
if (message.sender.did === (currentUser == null ? void 0 : currentUser.did)) {
|
|
3833
|
+
updateLastAckTime(chatId, true);
|
|
3834
|
+
} else if (isActiveChat(chatId)) {
|
|
3800
3835
|
updateLastAckTime(chatId);
|
|
3801
3836
|
}
|
|
3802
3837
|
}),
|
|
3803
3838
|
client2.onCreateChat(({ chat }) => addChat(chat)),
|
|
3804
3839
|
client2.onJoinChannel(({ chatId, participant }) => addParticipant(chatId, participant)),
|
|
3805
3840
|
client2.onLeaveChannel(({ chatId, participant }) => removeParticipant(chatId, participant)),
|
|
3806
|
-
client2.onDeleteChannel(({ chatId }) => deleteChat(chatId))
|
|
3841
|
+
client2.onDeleteChannel(({ chatId }) => deleteChat(chatId)),
|
|
3842
|
+
client2.onUpdateLastAckTime(({ chatId }) => updateLastAckTime(chatId, true))
|
|
3807
3843
|
];
|
|
3808
3844
|
return () => {
|
|
3809
3845
|
cancels.forEach((cancel) => cancel == null ? void 0 : cancel());
|
|
@@ -3819,6 +3855,7 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3819
3855
|
...state,
|
|
3820
3856
|
client: client2,
|
|
3821
3857
|
setActiveChat,
|
|
3858
|
+
setActiveChatInWallet,
|
|
3822
3859
|
isActiveChat,
|
|
3823
3860
|
getOppositeUser: (chat) => {
|
|
3824
3861
|
if (chat.type === "dm") {
|
|
@@ -3835,9 +3872,10 @@ function ChatProvider({ client: client2, activeChatId, children }) {
|
|
|
3835
3872
|
deleteChannel,
|
|
3836
3873
|
deleteMessage,
|
|
3837
3874
|
hasUnreadMessages,
|
|
3838
|
-
refresh,
|
|
3839
3875
|
orderedChats,
|
|
3840
|
-
getLastMessageText
|
|
3876
|
+
getLastMessageText,
|
|
3877
|
+
isInWallet,
|
|
3878
|
+
createDM
|
|
3841
3879
|
};
|
|
3842
3880
|
}, [state, client2, currentUser == null ? void 0 : currentUser.did]);
|
|
3843
3881
|
return /* @__PURE__ */ jsx(ChatContext.Provider, { value, children });
|
|
@@ -3870,7 +3908,7 @@ function ChannelGroup({ size = "normal", chat, children, ...rest }) {
|
|
|
3870
3908
|
] })
|
|
3871
3909
|
] });
|
|
3872
3910
|
}
|
|
3873
|
-
function ChatList(
|
|
3911
|
+
function ChatList({ inWallet, ...rest }) {
|
|
3874
3912
|
const { t } = useLocaleContext();
|
|
3875
3913
|
const { orderedChats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages, getLastMessageText } = useChatContext();
|
|
3876
3914
|
const renderItem = (chat) => {
|
|
@@ -3896,14 +3934,24 @@ function ChatList(props) {
|
|
|
3896
3934
|
);
|
|
3897
3935
|
if (chat.type === "dm") {
|
|
3898
3936
|
const oppositeUser = getOppositeUser(chat);
|
|
3899
|
-
return /* @__PURE__ */ jsx(
|
|
3937
|
+
return /* @__PURE__ */ jsx(
|
|
3938
|
+
AuthorInfo,
|
|
3939
|
+
{
|
|
3940
|
+
user: oppositeUser,
|
|
3941
|
+
showProfileCard: false,
|
|
3942
|
+
showBadge: false,
|
|
3943
|
+
showDID: false,
|
|
3944
|
+
linkToProfile: !inWallet,
|
|
3945
|
+
children: latestMessageTextContent
|
|
3946
|
+
}
|
|
3947
|
+
);
|
|
3900
3948
|
}
|
|
3901
3949
|
if (chat.type === "channel") {
|
|
3902
3950
|
return /* @__PURE__ */ jsx(ChannelGroup, { chat, children: latestMessageTextContent });
|
|
3903
3951
|
}
|
|
3904
3952
|
return null;
|
|
3905
3953
|
};
|
|
3906
|
-
return /* @__PURE__ */ jsx(Box, { ...
|
|
3954
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, children: /* @__PURE__ */ jsx(Flipper, { flipKey: orderedChats.map((x) => x.id).join(""), children: orderedChats.map((chat) => {
|
|
3907
3955
|
const isActiveChat = activeChatId === chat.id;
|
|
3908
3956
|
const _hasUnreadMessages = hasUnreadMessages(chat) && (chat.type !== "channel" || chat.hasJoined);
|
|
3909
3957
|
return /* @__PURE__ */ jsx(Flipped, { flipId: chat.id, children: /* @__PURE__ */ jsxs(
|
|
@@ -3924,7 +3972,29 @@ function ChatList(props) {
|
|
|
3924
3972
|
".message-content-text": { color: `${grey$1[500]}` }
|
|
3925
3973
|
}
|
|
3926
3974
|
},
|
|
3927
|
-
onClick: () =>
|
|
3975
|
+
onClick: () => {
|
|
3976
|
+
if (inWallet) {
|
|
3977
|
+
const webTitleMap = {
|
|
3978
|
+
dm: () => {
|
|
3979
|
+
var _a2;
|
|
3980
|
+
return ((_a2 = getOppositeUser(chat)) == null ? void 0 : _a2.fullName) || t("chat.unknown");
|
|
3981
|
+
},
|
|
3982
|
+
notification: () => t("chat.notification"),
|
|
3983
|
+
channel: () => (chat == null ? void 0 : chat.type) === "channel" ? `# ${chat.name}` : t("chat.unknownChannel"),
|
|
3984
|
+
default: () => t("chat.chats")
|
|
3985
|
+
};
|
|
3986
|
+
const getWebTitle = () => {
|
|
3987
|
+
if (!chat) {
|
|
3988
|
+
return t("chat.chats");
|
|
3989
|
+
}
|
|
3990
|
+
const getTitle = webTitleMap[chat.type] || webTitleMap.default;
|
|
3991
|
+
return getTitle();
|
|
3992
|
+
};
|
|
3993
|
+
bridge.call("clickChat", { id: chat.id, title: getWebTitle() });
|
|
3994
|
+
} else {
|
|
3995
|
+
setActiveChat(chat);
|
|
3996
|
+
}
|
|
3997
|
+
},
|
|
3928
3998
|
children: [
|
|
3929
3999
|
renderItem(chat),
|
|
3930
4000
|
_hasUnreadMessages && /* @__PURE__ */ jsx(
|
|
@@ -4588,7 +4658,7 @@ function getLineClamp(count) {
|
|
|
4588
4658
|
function RoomTitle({ title }) {
|
|
4589
4659
|
return /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: "medium" }, children: title });
|
|
4590
4660
|
}
|
|
4591
|
-
function ChatRoom({ chat, ...rest }) {
|
|
4661
|
+
function ChatRoom({ chat, inWallet, ...rest }) {
|
|
4592
4662
|
var _a2;
|
|
4593
4663
|
const { t } = useLocaleContext();
|
|
4594
4664
|
const theme = useTheme();
|
|
@@ -4660,7 +4730,7 @@ function ChatRoom({ chat, ...rest }) {
|
|
|
4660
4730
|
return /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: 1 }, children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
4661
4731
|
}
|
|
4662
4732
|
return /* @__PURE__ */ jsxs(Box, { ...rest, sx: { display: isActive ? "flex" : "none", flexDirection: "column", height: "100%" }, children: [
|
|
4663
|
-
/* @__PURE__ */ jsxs(
|
|
4733
|
+
!inWallet && /* @__PURE__ */ jsxs(
|
|
4664
4734
|
Box,
|
|
4665
4735
|
{
|
|
4666
4736
|
sx: {
|
|
@@ -4825,7 +4895,138 @@ function NewChannelDialog({ open, onSubmit, onClose, ...rest }) {
|
|
|
4825
4895
|
}
|
|
4826
4896
|
);
|
|
4827
4897
|
}
|
|
4828
|
-
|
|
4898
|
+
const tablerSearch = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m18 11l-6-6" }) });
|
|
4899
|
+
function UserSearch({ sx, ...rest }) {
|
|
4900
|
+
var _a2;
|
|
4901
|
+
const { session } = useSessionContext();
|
|
4902
|
+
const navigate = useNavigate();
|
|
4903
|
+
const { client: client2, isInWallet, chats, setActiveChat, createDM } = useChatContext();
|
|
4904
|
+
const [inputValue, setInputValue] = useState("");
|
|
4905
|
+
const [open, setOpen] = useState(false);
|
|
4906
|
+
const { data, loading } = useRequest(
|
|
4907
|
+
async () => {
|
|
4908
|
+
if (!open) {
|
|
4909
|
+
return Promise.resolve([]);
|
|
4910
|
+
}
|
|
4911
|
+
const results = await client2.searchUsers({ search: inputValue });
|
|
4912
|
+
if (!(results == null ? void 0 : results.length)) {
|
|
4913
|
+
return [];
|
|
4914
|
+
}
|
|
4915
|
+
return results.filter((x) => {
|
|
4916
|
+
var _a3;
|
|
4917
|
+
return x.did !== ((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did);
|
|
4918
|
+
});
|
|
4919
|
+
},
|
|
4920
|
+
{
|
|
4921
|
+
throttleWait: 500,
|
|
4922
|
+
throttleLeading: false,
|
|
4923
|
+
refreshDeps: [open, inputValue, (_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did]
|
|
4924
|
+
}
|
|
4925
|
+
);
|
|
4926
|
+
const mergedSx = mergeSx({}, sx);
|
|
4927
|
+
return /* @__PURE__ */ jsxs(Box$1, { sx: mergedSx, ...rest, children: [
|
|
4928
|
+
/* @__PURE__ */ jsx(
|
|
4929
|
+
Autocomplete,
|
|
4930
|
+
{
|
|
4931
|
+
open,
|
|
4932
|
+
onOpen: () => setOpen(true),
|
|
4933
|
+
onClose: () => {
|
|
4934
|
+
setInputValue("");
|
|
4935
|
+
setOpen(false);
|
|
4936
|
+
},
|
|
4937
|
+
disableClearable: true,
|
|
4938
|
+
filterOptions: (x) => x,
|
|
4939
|
+
options: data || [],
|
|
4940
|
+
getOptionLabel: () => "",
|
|
4941
|
+
renderOption: (props, option) => /* @__PURE__ */ createElement(Box$1, { component: "li", ...props, key: option.did, sx: { px: "8px!important" } }, /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", alignItems: "center", width: 1 }, children: [
|
|
4942
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { mt: 0.25, lineHeight: 1 }, children: /* @__PURE__ */ jsx(Avatar, { did: option.did, src: option.avatar, size: 28, shape: "circle", variant: "circle" }) }),
|
|
4943
|
+
/* @__PURE__ */ jsxs(
|
|
4944
|
+
Box$1,
|
|
4945
|
+
{
|
|
4946
|
+
sx: {
|
|
4947
|
+
flex: 1,
|
|
4948
|
+
display: "flex",
|
|
4949
|
+
flexDirection: "column",
|
|
4950
|
+
overflow: "hidden",
|
|
4951
|
+
ml: 1
|
|
4952
|
+
},
|
|
4953
|
+
children: [
|
|
4954
|
+
/* @__PURE__ */ jsx(
|
|
4955
|
+
Typography$1,
|
|
4956
|
+
{
|
|
4957
|
+
variant: "body2",
|
|
4958
|
+
sx: {
|
|
4959
|
+
fontSize: 12,
|
|
4960
|
+
fontWeight: "bold",
|
|
4961
|
+
overflow: "hidden",
|
|
4962
|
+
whiteSpace: "nowrap",
|
|
4963
|
+
textOverflow: "ellipsis"
|
|
4964
|
+
},
|
|
4965
|
+
children: option.fullName
|
|
4966
|
+
}
|
|
4967
|
+
),
|
|
4968
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { ".span": { lineHeight: 1 } }, children: /* @__PURE__ */ jsx(DID, { did: option.did, copyable: false, compact: true, responsive: false, size: 12 }) })
|
|
4969
|
+
]
|
|
4970
|
+
}
|
|
4971
|
+
)
|
|
4972
|
+
] })),
|
|
4973
|
+
onChange: async (event, newValue, reason) => {
|
|
4974
|
+
var _a3;
|
|
4975
|
+
if (event.type === "keydown" && event.key === "Backspace" && reason === "removeOption") {
|
|
4976
|
+
return;
|
|
4977
|
+
}
|
|
4978
|
+
const chatId = [newValue.did, (_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did].sort().join("-");
|
|
4979
|
+
const chat = chats.find((x) => x.id === chatId);
|
|
4980
|
+
if (isInWallet) {
|
|
4981
|
+
if (chat) {
|
|
4982
|
+
bridge.call("clickChat", { id: chat.id, title: newValue.fullName });
|
|
4983
|
+
} else {
|
|
4984
|
+
const dm = await createDM(newValue.did);
|
|
4985
|
+
bridge.call("clickChat", { id: dm.id, title: newValue.fullName });
|
|
4986
|
+
}
|
|
4987
|
+
} else if (chat) {
|
|
4988
|
+
setActiveChat(chat);
|
|
4989
|
+
} else {
|
|
4990
|
+
navigate(`/chat/dm/${newValue.did}`);
|
|
4991
|
+
}
|
|
4992
|
+
},
|
|
4993
|
+
loading,
|
|
4994
|
+
onInputChange: (_, newInputValue, reason) => {
|
|
4995
|
+
if (reason === "reset") {
|
|
4996
|
+
return;
|
|
4997
|
+
}
|
|
4998
|
+
setInputValue(newInputValue);
|
|
4999
|
+
},
|
|
5000
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
5001
|
+
TextField$1,
|
|
5002
|
+
{
|
|
5003
|
+
...params,
|
|
5004
|
+
placeholder: "Search user",
|
|
5005
|
+
variant: "outlined",
|
|
5006
|
+
InputProps: {
|
|
5007
|
+
...params.InputProps,
|
|
5008
|
+
type: "search",
|
|
5009
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(Box$1, { component: tablerSearch, sx: { fontSize: 14 } }) })
|
|
5010
|
+
},
|
|
5011
|
+
sx: {
|
|
5012
|
+
fontSize: 12,
|
|
5013
|
+
".MuiInputBase-root": { pr: "8px!important" },
|
|
5014
|
+
".MuiInputBase-input": { py: "0!important" },
|
|
5015
|
+
fieldset: { borderColor: "#eee!important" }
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
),
|
|
5019
|
+
isOptionEqualToValue: (option, value) => option.did === value.did,
|
|
5020
|
+
sx: { ".MuiAutocomplete-endAdornment": { display: "none" } }
|
|
5021
|
+
}
|
|
5022
|
+
),
|
|
5023
|
+
ReactDOM.createPortal(
|
|
5024
|
+
/* @__PURE__ */ jsx(Backdrop, { open, sx: { zIndex: "modal", bgcolor: "transparent" } }),
|
|
5025
|
+
window.document.body
|
|
5026
|
+
)
|
|
5027
|
+
] });
|
|
5028
|
+
}
|
|
5029
|
+
function Empty$2({ sx }) {
|
|
4829
5030
|
const { t } = useLocaleContext();
|
|
4830
5031
|
const mergedSx = [
|
|
4831
5032
|
{
|
|
@@ -4845,7 +5046,7 @@ function Empty({ sx }) {
|
|
|
4845
5046
|
}
|
|
4846
5047
|
function Chat({ sx, ...rest }) {
|
|
4847
5048
|
var _a2;
|
|
4848
|
-
const { client: client2, initialized, chats, activeChatId, addChat, setActiveChat,
|
|
5049
|
+
const { client: client2, initialized, chats, activeChatId, addChat, setActiveChat, getOppositeUser } = useChatContext();
|
|
4849
5050
|
const [newChannelVisible, setNewChannelVisible] = useState(false);
|
|
4850
5051
|
const downMd = useMediaQuery((theme) => theme.breakpoints.down("sm"));
|
|
4851
5052
|
const { t } = useLocaleContext();
|
|
@@ -4866,9 +5067,6 @@ function Chat({ sx, ...rest }) {
|
|
|
4866
5067
|
const getTitle = webTitleMap[activeChat.type] || webTitleMap.default;
|
|
4867
5068
|
return getTitle();
|
|
4868
5069
|
};
|
|
4869
|
-
useEffect(() => {
|
|
4870
|
-
refresh();
|
|
4871
|
-
}, []);
|
|
4872
5070
|
const show = useMemo(() => {
|
|
4873
5071
|
if (downMd) {
|
|
4874
5072
|
return {
|
|
@@ -4911,12 +5109,13 @@ function Chat({ sx, ...rest }) {
|
|
|
4911
5109
|
display: "flex",
|
|
4912
5110
|
justifyContent: "space-between",
|
|
4913
5111
|
alignItems: "center",
|
|
5112
|
+
gap: 1,
|
|
4914
5113
|
height: 52,
|
|
4915
|
-
px:
|
|
5114
|
+
px: 3,
|
|
4916
5115
|
borderBottom: "1px solid #e5e5e5"
|
|
4917
5116
|
},
|
|
4918
5117
|
children: [
|
|
4919
|
-
/* @__PURE__ */ jsx(
|
|
5118
|
+
/* @__PURE__ */ jsx(UserSearch, { sx: { flex: 1 } }),
|
|
4920
5119
|
/* @__PURE__ */ jsx(AccessControl, { roles: ["owner", "admin"], children: /* @__PURE__ */ jsx(
|
|
4921
5120
|
IconButton$1,
|
|
4922
5121
|
{
|
|
@@ -4928,16 +5127,16 @@ function Chat({ sx, ...rest }) {
|
|
|
4928
5127
|
]
|
|
4929
5128
|
}
|
|
4930
5129
|
),
|
|
4931
|
-
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" } }),
|
|
4932
|
-
!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(Empty, { sx: { flex: 1 } })
|
|
5130
|
+
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: false }),
|
|
5131
|
+
!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(Empty$2, { sx: { flex: 1 } })
|
|
4933
5132
|
]
|
|
4934
5133
|
}
|
|
4935
5134
|
),
|
|
4936
5135
|
show.right && /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
4937
5136
|
chats.map((chat) => {
|
|
4938
|
-
return /* @__PURE__ */ jsx(ChatRoom, { chat }, chat.id);
|
|
5137
|
+
return /* @__PURE__ */ jsx(ChatRoom, { chat, inWallet: false }, chat.id);
|
|
4939
5138
|
}),
|
|
4940
|
-
!activeChatId && /* @__PURE__ */ jsx(Empty, { sx: { height: 1 } })
|
|
5139
|
+
!activeChatId && /* @__PURE__ */ jsx(Empty$2, { sx: { height: 1 } })
|
|
4941
5140
|
] }),
|
|
4942
5141
|
/* @__PURE__ */ jsx(
|
|
4943
5142
|
NewChannelDialog,
|
|
@@ -4950,6 +5149,106 @@ function Chat({ sx, ...rest }) {
|
|
|
4950
5149
|
)
|
|
4951
5150
|
] });
|
|
4952
5151
|
}
|
|
5152
|
+
function Empty$1({ sx }) {
|
|
5153
|
+
const { t } = useLocaleContext();
|
|
5154
|
+
const mergedSx = [
|
|
5155
|
+
{
|
|
5156
|
+
display: "flex",
|
|
5157
|
+
flexDirection: "column",
|
|
5158
|
+
justifyContent: "center",
|
|
5159
|
+
alignItems: "center",
|
|
5160
|
+
gap: 1,
|
|
5161
|
+
color: "grey.600"
|
|
5162
|
+
},
|
|
5163
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
5164
|
+
];
|
|
5165
|
+
return /* @__PURE__ */ jsxs(Box, { sx: mergedSx, children: [
|
|
5166
|
+
/* @__PURE__ */ jsx(iconoirChatBubbleEmpty, { style: { fontSize: 32 } }),
|
|
5167
|
+
/* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
|
|
5168
|
+
] });
|
|
5169
|
+
}
|
|
5170
|
+
function ChatInWallet({ sx, ...rest }) {
|
|
5171
|
+
var _a2;
|
|
5172
|
+
const { chatId: activeChatId } = useParams();
|
|
5173
|
+
const { initialized, chats } = useChatContext();
|
|
5174
|
+
const downMd = useMediaQuery((theme) => theme.breakpoints.down("sm"));
|
|
5175
|
+
const activeChat = (_a2 = chats == null ? void 0 : chats.filter((chat) => (chat == null ? void 0 : chat.id) === activeChatId)) == null ? void 0 : _a2[0];
|
|
5176
|
+
const show = useMemo(() => {
|
|
5177
|
+
if (downMd) {
|
|
5178
|
+
return {
|
|
5179
|
+
left: !activeChatId,
|
|
5180
|
+
right: !!activeChatId
|
|
5181
|
+
};
|
|
5182
|
+
}
|
|
5183
|
+
return {
|
|
5184
|
+
left: true,
|
|
5185
|
+
right: true
|
|
5186
|
+
};
|
|
5187
|
+
}, [downMd, activeChatId]);
|
|
5188
|
+
if (!initialized) {
|
|
5189
|
+
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
5190
|
+
}
|
|
5191
|
+
const mergedSx = [{ display: "flex", height: "100%", bgcolor: "#fff" }, ...Array.isArray(sx) ? sx : [sx]];
|
|
5192
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, sx: mergedSx, children: show.right && /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
5193
|
+
/* @__PURE__ */ jsx(ChatRoom, { chat: activeChat, inWallet: true }),
|
|
5194
|
+
!activeChatId && /* @__PURE__ */ jsx(Empty$1, { sx: { height: 1 } })
|
|
5195
|
+
] }) });
|
|
5196
|
+
}
|
|
5197
|
+
function Empty({ sx }) {
|
|
5198
|
+
const { t } = useLocaleContext();
|
|
5199
|
+
const mergedSx = [
|
|
5200
|
+
{
|
|
5201
|
+
display: "flex",
|
|
5202
|
+
flexDirection: "column",
|
|
5203
|
+
justifyContent: "center",
|
|
5204
|
+
alignItems: "center",
|
|
5205
|
+
gap: 1,
|
|
5206
|
+
color: "grey.600"
|
|
5207
|
+
},
|
|
5208
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
5209
|
+
];
|
|
5210
|
+
return /* @__PURE__ */ jsxs(Box, { sx: mergedSx, children: [
|
|
5211
|
+
/* @__PURE__ */ jsx(iconoirChatBubbleEmpty, { style: { fontSize: 32 } }),
|
|
5212
|
+
/* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
|
|
5213
|
+
] });
|
|
5214
|
+
}
|
|
5215
|
+
function ChatListInWallet({ sx, ...rest }) {
|
|
5216
|
+
const { initialized, chats, activeChatId } = useChatContext();
|
|
5217
|
+
const downMd = useMediaQuery((theme) => theme.breakpoints.down("sm"));
|
|
5218
|
+
const show = useMemo(() => {
|
|
5219
|
+
if (downMd) {
|
|
5220
|
+
return {
|
|
5221
|
+
left: !activeChatId,
|
|
5222
|
+
right: !!activeChatId
|
|
5223
|
+
};
|
|
5224
|
+
}
|
|
5225
|
+
return {
|
|
5226
|
+
left: true,
|
|
5227
|
+
right: true
|
|
5228
|
+
};
|
|
5229
|
+
}, [downMd, activeChatId]);
|
|
5230
|
+
if (!initialized) {
|
|
5231
|
+
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
5232
|
+
}
|
|
5233
|
+
const mergedSx = [{ display: "flex", height: "100%", bgcolor: "#fff" }, ...Array.isArray(sx) ? sx : [sx]];
|
|
5234
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, sx: mergedSx, children: show.left && /* @__PURE__ */ jsxs(
|
|
5235
|
+
Box,
|
|
5236
|
+
{
|
|
5237
|
+
sx: {
|
|
5238
|
+
display: "flex",
|
|
5239
|
+
flexDirection: "column",
|
|
5240
|
+
width: { sm: 320, xs: "100%" },
|
|
5241
|
+
borderRight: { sm: "1px solid #e5e5e5" }
|
|
5242
|
+
},
|
|
5243
|
+
children: [
|
|
5244
|
+
/* @__PURE__ */ jsx(UserSearch, { sx: { flex: "0 0 auto", py: 1, px: 3 } }),
|
|
5245
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
5246
|
+
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
|
5247
|
+
!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(Empty, { sx: { flex: 1 } })
|
|
5248
|
+
]
|
|
5249
|
+
}
|
|
5250
|
+
) });
|
|
5251
|
+
}
|
|
4953
5252
|
const iconoirMessageText = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: 1.5, children: [
|
|
4954
5253
|
/* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 12h10M7 8h6" }),
|
|
4955
5254
|
/* @__PURE__ */ jsx("path", { d: "M3 20.29V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7.961a2 2 0 0 0-1.561.75l-2.331 2.914A.6.6 0 0 1 3 20.29Z" })
|
|
@@ -5279,7 +5578,7 @@ function Pagination({
|
|
|
5279
5578
|
}
|
|
5280
5579
|
);
|
|
5281
5580
|
}
|
|
5282
|
-
const Editor = lazy(() => import("./editor-
|
|
5581
|
+
const Editor = lazy(() => import("./editor-xw6iQCuH.mjs"));
|
|
5283
5582
|
function LazyEditor(props) {
|
|
5284
5583
|
const fallback = /* @__PURE__ */ jsxs(Box$1, { sx: { px: 3 }, children: [
|
|
5285
5584
|
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
@@ -11445,7 +11744,7 @@ function SegmentedControl({ value, options, onChange, sx, ...rest }) {
|
|
|
11445
11744
|
) });
|
|
11446
11745
|
}
|
|
11447
11746
|
export {
|
|
11448
|
-
|
|
11747
|
+
useChatContext as $,
|
|
11449
11748
|
Avatar as A,
|
|
11450
11749
|
Badge as B,
|
|
11451
11750
|
CommentInput as C,
|
|
@@ -11470,38 +11769,40 @@ export {
|
|
|
11470
11769
|
VideoPathFixerPlugin as V,
|
|
11471
11770
|
ChatClient as W,
|
|
11472
11771
|
Chat as X,
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11772
|
+
ChatInWallet as Y,
|
|
11773
|
+
ChatListInWallet as Z,
|
|
11774
|
+
ChatHeaderAddon as _,
|
|
11476
11775
|
isEmptyContent as a,
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11776
|
+
ChatProvider as a0,
|
|
11777
|
+
UnreadNotificationContext as a1,
|
|
11778
|
+
useUnreadNotification as a2,
|
|
11779
|
+
UnreadNotificationProvider as a3,
|
|
11780
|
+
Confirm as a4,
|
|
11781
|
+
ConfirmContext as a5,
|
|
11782
|
+
useConfirm as a6,
|
|
11783
|
+
ConfirmProvider as a7,
|
|
11784
|
+
SecureLabelPicker as a8,
|
|
11785
|
+
useApiErrorHandler as a9,
|
|
11786
|
+
useDefaultApiErrorHandler as aa,
|
|
11787
|
+
DefaultApiErrorHandler as ab,
|
|
11788
|
+
PreviousLocationRecorder as ac,
|
|
11789
|
+
Back as ad,
|
|
11790
|
+
LazyEditor as ae,
|
|
11791
|
+
EditorPreview as af,
|
|
11792
|
+
DirtyPromptContainer as ag,
|
|
11793
|
+
ConfirmNavigation as ah,
|
|
11794
|
+
UploaderContext as ai,
|
|
11795
|
+
useUploader as aj,
|
|
11796
|
+
UploaderTrigger as ak,
|
|
11797
|
+
UploaderProvider as al,
|
|
11798
|
+
composeImageUrl as am,
|
|
11799
|
+
usePointUpContext as an,
|
|
11800
|
+
PointUpProvider as ao,
|
|
11801
|
+
ButtonGroup as ap,
|
|
11802
|
+
SegmentedControl as aq,
|
|
11803
|
+
create as ar,
|
|
11804
|
+
getWsClient as as,
|
|
11805
|
+
useSubscription as at,
|
|
11505
11806
|
Input as b,
|
|
11506
11807
|
useChanged as c,
|
|
11507
11808
|
useSessionContext as d,
|