@dubsdotapp/expo 0.5.22 → 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.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`);
@@ -8733,6 +8741,7 @@ var ChatSocket = class {
8733
8741
  this.socket.on("dm:messages_read", (data) => this.listeners.onDMMessagesRead?.(data));
8734
8742
  this.socket.on("friend_request_accepted", (data) => this.listeners.onFriendRequestAccepted?.(data));
8735
8743
  this.socket.on("friend_request_declined", (data) => this.listeners.onFriendRequestDeclined?.(data));
8744
+ this.socket.on("friend_request_cancelled", (data) => this.listeners.onFriendRequestCancelled?.(data));
8736
8745
  this.socket.on("friend_removed", (data) => this.listeners.onFriendRemoved?.(data));
8737
8746
  this.socket.on("error", (err) => this.listeners.onError?.(err));
8738
8747
  }
@@ -8799,6 +8808,7 @@ function ChatProvider({ children, autoConnect = true }) {
8799
8808
  const [conversations, setConversations] = useState41([]);
8800
8809
  const [friends, setFriends] = useState41([]);
8801
8810
  const [pendingRequests, setPendingRequests] = useState41([]);
8811
+ const [sentFriendRequests, setSentFriendRequests] = useState41([]);
8802
8812
  const refreshMessages = useCallback35(async () => {
8803
8813
  try {
8804
8814
  const res = await client.getChatMessages({ limit: 30 });
@@ -8828,6 +8838,13 @@ function ChatProvider({ children, autoConnect = true }) {
8828
8838
  } catch (_) {
8829
8839
  }
8830
8840
  }, [client]);
8841
+ const refreshSentFriendRequests = useCallback35(async () => {
8842
+ try {
8843
+ const res = await client.getSentFriendRequests();
8844
+ setSentFriendRequests(res.requests);
8845
+ } catch (_) {
8846
+ }
8847
+ }, [client]);
8831
8848
  useEffect29(() => {
8832
8849
  const token = client.getToken();
8833
8850
  if (!autoConnect || !token) return;
@@ -8853,9 +8870,18 @@ function ChatProvider({ children, autoConnect = true }) {
8853
8870
  onNotification: (n) => {
8854
8871
  setUnreadCount((prev) => prev + 1);
8855
8872
  if (n.type === "friend_request") refreshPendingRequests();
8856
- if (n.type === "friend_request_accepted") refreshFriends();
8873
+ if (n.type === "friend_request_accepted") {
8874
+ refreshFriends();
8875
+ refreshSentFriendRequests();
8876
+ }
8877
+ if (n.type === "friend_request_declined") refreshSentFriendRequests();
8857
8878
  },
8858
- onFriendRequestAccepted: () => refreshFriends(),
8879
+ onFriendRequestAccepted: () => {
8880
+ refreshFriends();
8881
+ refreshSentFriendRequests();
8882
+ },
8883
+ onFriendRequestDeclined: () => refreshSentFriendRequests(),
8884
+ onFriendRequestCancelled: () => refreshPendingRequests(),
8859
8885
  onFriendRemoved: () => refreshFriends()
8860
8886
  });
8861
8887
  chatSocket.connect({ host, token });
@@ -8864,10 +8890,12 @@ function ChatProvider({ children, autoConnect = true }) {
8864
8890
  });
8865
8891
  refreshPendingRequests().catch(() => {
8866
8892
  });
8893
+ refreshSentFriendRequests().catch(() => {
8894
+ });
8867
8895
  return () => {
8868
8896
  chatSocket.disconnect();
8869
8897
  };
8870
- }, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests]);
8898
+ }, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
8871
8899
  useEffect29(() => {
8872
8900
  const handleAppState = (nextState) => {
8873
8901
  if (nextState === "active") {
@@ -8897,12 +8925,14 @@ function ChatProvider({ children, autoConnect = true }) {
8897
8925
  conversations,
8898
8926
  friends,
8899
8927
  pendingRequests,
8928
+ sentFriendRequests,
8900
8929
  refreshMessages,
8901
8930
  refreshConversations,
8902
8931
  refreshFriends,
8903
- refreshPendingRequests
8932
+ refreshPendingRequests,
8933
+ refreshSentFriendRequests
8904
8934
  }),
8905
- [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]
8906
8936
  );
8907
8937
  return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
8908
8938
  }
@@ -9052,6 +9082,34 @@ function useFriendRequests() {
9052
9082
  }, [refreshPendingRequests]);
9053
9083
  return { requests: pendingRequests, loading, refetch };
9054
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
+ }
9055
9113
  function useSearchUsers() {
9056
9114
  const { client } = useDubs();
9057
9115
  const [results, setResults] = useState42([]);
@@ -9169,6 +9227,7 @@ export {
9169
9227
  useArcadePool,
9170
9228
  useArcadePools,
9171
9229
  useAuth,
9230
+ useCancelFriendRequest,
9172
9231
  useChatContext,
9173
9232
  useChatMessages,
9174
9233
  useChatStatus,
@@ -9198,6 +9257,7 @@ export {
9198
9257
  useSearchUsers,
9199
9258
  useSendFriendRequest,
9200
9259
  useSendMessage,
9260
+ useSentFriendRequests,
9201
9261
  useShorts,
9202
9262
  useUFCFightCard,
9203
9263
  useUFCFighterDetail,