@dubsdotapp/expo 0.5.21 → 0.5.23
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/index.d.mts +59 -6
- package/dist/index.d.ts +59 -6
- package/dist/index.js +68 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/hooks.ts +44 -0
- package/src/chat/index.ts +3 -0
- package/src/chat/provider.tsx +33 -6
- package/src/chat/socket.ts +3 -0
- package/src/chat/types.ts +10 -0
- package/src/client.ts +10 -0
- package/src/hooks/usePushNotifications.ts +22 -3
- package/src/index.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -719,6 +719,14 @@ var DubsClient = class {
|
|
|
719
719
|
async getPendingFriendRequests() {
|
|
720
720
|
return this.request("GET", "/social/friend-requests");
|
|
721
721
|
}
|
|
722
|
+
/** Get pending friend requests this user has sent (still awaiting response) */
|
|
723
|
+
async getSentFriendRequests() {
|
|
724
|
+
return this.request("GET", "/social/friend-requests/sent");
|
|
725
|
+
}
|
|
726
|
+
/** Cancel a pending friend request the user previously sent */
|
|
727
|
+
async cancelFriendRequest(requestId) {
|
|
728
|
+
await this.request("DELETE", `/social/friend-request/${requestId}`);
|
|
729
|
+
}
|
|
722
730
|
/** Accept a friend request */
|
|
723
731
|
async acceptFriendRequest(requestId) {
|
|
724
732
|
await this.request("POST", `/social/request/${requestId}/accept`);
|
|
@@ -2741,6 +2749,7 @@ function usePushNotifications() {
|
|
|
2741
2749
|
restoreIfGranted();
|
|
2742
2750
|
}, []);
|
|
2743
2751
|
return {
|
|
2752
|
+
isActive: pushEnabled && !!pushToken,
|
|
2744
2753
|
enabled: pushEnabled,
|
|
2745
2754
|
hasPermission,
|
|
2746
2755
|
pushToken,
|
|
@@ -8732,6 +8741,7 @@ var ChatSocket = class {
|
|
|
8732
8741
|
this.socket.on("dm:messages_read", (data) => this.listeners.onDMMessagesRead?.(data));
|
|
8733
8742
|
this.socket.on("friend_request_accepted", (data) => this.listeners.onFriendRequestAccepted?.(data));
|
|
8734
8743
|
this.socket.on("friend_request_declined", (data) => this.listeners.onFriendRequestDeclined?.(data));
|
|
8744
|
+
this.socket.on("friend_request_cancelled", (data) => this.listeners.onFriendRequestCancelled?.(data));
|
|
8735
8745
|
this.socket.on("friend_removed", (data) => this.listeners.onFriendRemoved?.(data));
|
|
8736
8746
|
this.socket.on("error", (err) => this.listeners.onError?.(err));
|
|
8737
8747
|
}
|
|
@@ -8798,6 +8808,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8798
8808
|
const [conversations, setConversations] = useState41([]);
|
|
8799
8809
|
const [friends, setFriends] = useState41([]);
|
|
8800
8810
|
const [pendingRequests, setPendingRequests] = useState41([]);
|
|
8811
|
+
const [sentFriendRequests, setSentFriendRequests] = useState41([]);
|
|
8801
8812
|
const refreshMessages = useCallback35(async () => {
|
|
8802
8813
|
try {
|
|
8803
8814
|
const res = await client.getChatMessages({ limit: 30 });
|
|
@@ -8827,6 +8838,13 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8827
8838
|
} catch (_) {
|
|
8828
8839
|
}
|
|
8829
8840
|
}, [client]);
|
|
8841
|
+
const refreshSentFriendRequests = useCallback35(async () => {
|
|
8842
|
+
try {
|
|
8843
|
+
const res = await client.getSentFriendRequests();
|
|
8844
|
+
setSentFriendRequests(res.requests);
|
|
8845
|
+
} catch (_) {
|
|
8846
|
+
}
|
|
8847
|
+
}, [client]);
|
|
8830
8848
|
useEffect29(() => {
|
|
8831
8849
|
const token = client.getToken();
|
|
8832
8850
|
if (!autoConnect || !token) return;
|
|
@@ -8852,9 +8870,18 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8852
8870
|
onNotification: (n) => {
|
|
8853
8871
|
setUnreadCount((prev) => prev + 1);
|
|
8854
8872
|
if (n.type === "friend_request") refreshPendingRequests();
|
|
8855
|
-
if (n.type === "friend_request_accepted")
|
|
8873
|
+
if (n.type === "friend_request_accepted") {
|
|
8874
|
+
refreshFriends();
|
|
8875
|
+
refreshSentFriendRequests();
|
|
8876
|
+
}
|
|
8877
|
+
if (n.type === "friend_request_declined") refreshSentFriendRequests();
|
|
8856
8878
|
},
|
|
8857
|
-
onFriendRequestAccepted: () =>
|
|
8879
|
+
onFriendRequestAccepted: () => {
|
|
8880
|
+
refreshFriends();
|
|
8881
|
+
refreshSentFriendRequests();
|
|
8882
|
+
},
|
|
8883
|
+
onFriendRequestDeclined: () => refreshSentFriendRequests(),
|
|
8884
|
+
onFriendRequestCancelled: () => refreshPendingRequests(),
|
|
8858
8885
|
onFriendRemoved: () => refreshFriends()
|
|
8859
8886
|
});
|
|
8860
8887
|
chatSocket.connect({ host, token });
|
|
@@ -8863,10 +8890,12 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8863
8890
|
});
|
|
8864
8891
|
refreshPendingRequests().catch(() => {
|
|
8865
8892
|
});
|
|
8893
|
+
refreshSentFriendRequests().catch(() => {
|
|
8894
|
+
});
|
|
8866
8895
|
return () => {
|
|
8867
8896
|
chatSocket.disconnect();
|
|
8868
8897
|
};
|
|
8869
|
-
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests]);
|
|
8898
|
+
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
|
|
8870
8899
|
useEffect29(() => {
|
|
8871
8900
|
const handleAppState = (nextState) => {
|
|
8872
8901
|
if (nextState === "active") {
|
|
@@ -8896,12 +8925,14 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8896
8925
|
conversations,
|
|
8897
8926
|
friends,
|
|
8898
8927
|
pendingRequests,
|
|
8928
|
+
sentFriendRequests,
|
|
8899
8929
|
refreshMessages,
|
|
8900
8930
|
refreshConversations,
|
|
8901
8931
|
refreshFriends,
|
|
8902
|
-
refreshPendingRequests
|
|
8932
|
+
refreshPendingRequests,
|
|
8933
|
+
refreshSentFriendRequests
|
|
8903
8934
|
}),
|
|
8904
|
-
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests]
|
|
8935
|
+
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]
|
|
8905
8936
|
);
|
|
8906
8937
|
return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
|
|
8907
8938
|
}
|
|
@@ -9051,6 +9082,34 @@ function useFriendRequests() {
|
|
|
9051
9082
|
}, [refreshPendingRequests]);
|
|
9052
9083
|
return { requests: pendingRequests, loading, refetch };
|
|
9053
9084
|
}
|
|
9085
|
+
function useSentFriendRequests() {
|
|
9086
|
+
const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
|
|
9087
|
+
const [loading, setLoading] = useState42(false);
|
|
9088
|
+
const refetch = useCallback36(async () => {
|
|
9089
|
+
setLoading(true);
|
|
9090
|
+
await refreshSentFriendRequests();
|
|
9091
|
+
setLoading(false);
|
|
9092
|
+
}, [refreshSentFriendRequests]);
|
|
9093
|
+
return { requests: sentFriendRequests, loading, refetch };
|
|
9094
|
+
}
|
|
9095
|
+
function useCancelFriendRequest() {
|
|
9096
|
+
const { client } = useDubs();
|
|
9097
|
+
const { refreshSentFriendRequests } = useChatContext();
|
|
9098
|
+
const [loading, setLoading] = useState42(false);
|
|
9099
|
+
const cancel = useCallback36(
|
|
9100
|
+
async (requestId) => {
|
|
9101
|
+
setLoading(true);
|
|
9102
|
+
try {
|
|
9103
|
+
await client.cancelFriendRequest(requestId);
|
|
9104
|
+
await refreshSentFriendRequests();
|
|
9105
|
+
} finally {
|
|
9106
|
+
setLoading(false);
|
|
9107
|
+
}
|
|
9108
|
+
},
|
|
9109
|
+
[client, refreshSentFriendRequests]
|
|
9110
|
+
);
|
|
9111
|
+
return { cancel, loading };
|
|
9112
|
+
}
|
|
9054
9113
|
function useSearchUsers() {
|
|
9055
9114
|
const { client } = useDubs();
|
|
9056
9115
|
const [results, setResults] = useState42([]);
|
|
@@ -9168,6 +9227,7 @@ export {
|
|
|
9168
9227
|
useArcadePool,
|
|
9169
9228
|
useArcadePools,
|
|
9170
9229
|
useAuth,
|
|
9230
|
+
useCancelFriendRequest,
|
|
9171
9231
|
useChatContext,
|
|
9172
9232
|
useChatMessages,
|
|
9173
9233
|
useChatStatus,
|
|
@@ -9197,6 +9257,7 @@ export {
|
|
|
9197
9257
|
useSearchUsers,
|
|
9198
9258
|
useSendFriendRequest,
|
|
9199
9259
|
useSendMessage,
|
|
9260
|
+
useSentFriendRequests,
|
|
9200
9261
|
useShorts,
|
|
9201
9262
|
useUFCFightCard,
|
|
9202
9263
|
useUFCFighterDetail,
|