@streamplace/components 0.7.30 → 0.7.32
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/chat/mod-view.js +7 -1
- package/dist/livestream-store/chat.js +6 -6
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/package.json +2 -2
- package/src/components/chat/mod-view.tsx +12 -5
- package/src/livestream-store/chat.tsx +6 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -89,6 +89,7 @@ var DeleteState;
|
|
|
89
89
|
function DeleteButton({ message, deleteChatMessage, }) {
|
|
90
90
|
const [confirming, setConfirming] = (0, react_1.useState)(DeleteState.None);
|
|
91
91
|
const { onOpenChange } = (0, dropdown_menu_1.useRootContext)();
|
|
92
|
+
const toast = (0, ui_1.useToast)();
|
|
92
93
|
return ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenuItem, { onPress: () => {
|
|
93
94
|
if (!message)
|
|
94
95
|
return;
|
|
@@ -99,10 +100,15 @@ function DeleteButton({ message, deleteChatMessage, }) {
|
|
|
99
100
|
if (confirming === DeleteState.Confirmed) {
|
|
100
101
|
setConfirming(DeleteState.Deleting);
|
|
101
102
|
}
|
|
102
|
-
deleteChatMessage(message.uri)
|
|
103
|
+
deleteChatMessage(message.uri)
|
|
104
|
+
.then(() => {
|
|
103
105
|
// wait ~a second before resetting state to allow deletion to take effect
|
|
104
106
|
setTimeout(() => setConfirming(DeleteState.None), 1000);
|
|
105
107
|
onOpenChange?.(false);
|
|
108
|
+
})
|
|
109
|
+
.catch((e) => {
|
|
110
|
+
toast.show("Couldn't delete the message", e);
|
|
111
|
+
setConfirming(DeleteState.None);
|
|
106
112
|
});
|
|
107
113
|
}, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { color: "destructive", children: confirming === DeleteState.Confirmed
|
|
108
114
|
? "Are you sure? Click again to confirm."
|
|
@@ -102,14 +102,14 @@ const useCreateChatMessage = () => {
|
|
|
102
102
|
exports.useCreateChatMessage = useCreateChatMessage;
|
|
103
103
|
const useDeleteChatMessage = () => {
|
|
104
104
|
const pdsAgent = (0, xrpc_1.usePDSAgent)();
|
|
105
|
-
if (!pdsAgent) {
|
|
106
|
-
throw new Error("No PDS agent found");
|
|
107
|
-
}
|
|
108
105
|
const userDID = (0, streamplace_store_1.useDID)();
|
|
109
|
-
if (!userDID) {
|
|
110
|
-
throw new Error("No user DID found");
|
|
111
|
-
}
|
|
112
106
|
return async (uri) => {
|
|
107
|
+
if (!pdsAgent) {
|
|
108
|
+
throw new Error("No PDS agent found");
|
|
109
|
+
}
|
|
110
|
+
if (!userDID) {
|
|
111
|
+
throw new Error("No user DID found");
|
|
112
|
+
}
|
|
113
113
|
const rkey = uri.split("/").pop();
|
|
114
114
|
if (!rkey) {
|
|
115
115
|
throw new Error("No rkey found");
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamplace/components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.32",
|
|
4
4
|
"description": "Streamplace React (Native) Components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/index.tsx",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"start": "tsc --watch --preserveWatchOutput",
|
|
55
55
|
"prepare": "tsc"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "8c9f6186d1e718bcc4dfe84fe8c681680dddcf0e"
|
|
58
58
|
}
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
layout,
|
|
22
22
|
ResponsiveDropdownMenuContent,
|
|
23
23
|
Text,
|
|
24
|
+
useToast,
|
|
24
25
|
View,
|
|
25
26
|
} from "../ui";
|
|
26
27
|
|
|
@@ -210,6 +211,7 @@ export function DeleteButton({
|
|
|
210
211
|
}) {
|
|
211
212
|
const [confirming, setConfirming] = useState<DeleteState>(DeleteState.None);
|
|
212
213
|
const { onOpenChange } = useRootContext();
|
|
214
|
+
const toast = useToast();
|
|
213
215
|
return (
|
|
214
216
|
<DropdownMenuItem
|
|
215
217
|
onPress={() => {
|
|
@@ -221,11 +223,16 @@ export function DeleteButton({
|
|
|
221
223
|
if (confirming === DeleteState.Confirmed) {
|
|
222
224
|
setConfirming(DeleteState.Deleting);
|
|
223
225
|
}
|
|
224
|
-
deleteChatMessage(message.uri)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
deleteChatMessage(message.uri)
|
|
227
|
+
.then(() => {
|
|
228
|
+
// wait ~a second before resetting state to allow deletion to take effect
|
|
229
|
+
setTimeout(() => setConfirming(DeleteState.None), 1000);
|
|
230
|
+
onOpenChange?.(false);
|
|
231
|
+
})
|
|
232
|
+
.catch((e) => {
|
|
233
|
+
toast.show("Couldn't delete the message", e);
|
|
234
|
+
setConfirming(DeleteState.None);
|
|
235
|
+
});
|
|
229
236
|
}}
|
|
230
237
|
>
|
|
231
238
|
<Text color="destructive">
|
|
@@ -135,14 +135,14 @@ export const useCreateChatMessage = () => {
|
|
|
135
135
|
|
|
136
136
|
export const useDeleteChatMessage = () => {
|
|
137
137
|
const pdsAgent = usePDSAgent();
|
|
138
|
-
if (!pdsAgent) {
|
|
139
|
-
throw new Error("No PDS agent found");
|
|
140
|
-
}
|
|
141
138
|
const userDID = useDID();
|
|
142
|
-
if (!userDID) {
|
|
143
|
-
throw new Error("No user DID found");
|
|
144
|
-
}
|
|
145
139
|
return async (uri: string) => {
|
|
140
|
+
if (!pdsAgent) {
|
|
141
|
+
throw new Error("No PDS agent found");
|
|
142
|
+
}
|
|
143
|
+
if (!userDID) {
|
|
144
|
+
throw new Error("No user DID found");
|
|
145
|
+
}
|
|
146
146
|
const rkey = uri.split("/").pop();
|
|
147
147
|
if (!rkey) {
|
|
148
148
|
throw new Error("No rkey found");
|