@dubsdotapp/expo 0.5.22 → 0.5.24

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();
8878
+ },
8879
+ onFriendRequestAccepted: () => {
8880
+ refreshFriends();
8881
+ refreshSentFriendRequests();
8857
8882
  },
8858
- onFriendRequestAccepted: () => refreshFriends(),
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") {
@@ -8881,11 +8909,19 @@ function ChatProvider({ children, autoConnect = true }) {
8881
8909
  }
8882
8910
  }
8883
8911
  refreshMessages();
8912
+ refreshConversations().catch(() => {
8913
+ });
8914
+ refreshFriends().catch(() => {
8915
+ });
8916
+ refreshPendingRequests().catch(() => {
8917
+ });
8918
+ refreshSentFriendRequests().catch(() => {
8919
+ });
8884
8920
  }
8885
8921
  };
8886
8922
  const sub = AppState.addEventListener("change", handleAppState);
8887
8923
  return () => sub.remove();
8888
- }, [client, refreshMessages, refreshConversations]);
8924
+ }, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
8889
8925
  const value = useMemo11(
8890
8926
  () => ({
8891
8927
  socket: socketRef.current,
@@ -8897,12 +8933,14 @@ function ChatProvider({ children, autoConnect = true }) {
8897
8933
  conversations,
8898
8934
  friends,
8899
8935
  pendingRequests,
8936
+ sentFriendRequests,
8900
8937
  refreshMessages,
8901
8938
  refreshConversations,
8902
8939
  refreshFriends,
8903
- refreshPendingRequests
8940
+ refreshPendingRequests,
8941
+ refreshSentFriendRequests
8904
8942
  }),
8905
- [status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests]
8943
+ [status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]
8906
8944
  );
8907
8945
  return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
8908
8946
  }
@@ -9052,6 +9090,34 @@ function useFriendRequests() {
9052
9090
  }, [refreshPendingRequests]);
9053
9091
  return { requests: pendingRequests, loading, refetch };
9054
9092
  }
9093
+ function useSentFriendRequests() {
9094
+ const { sentFriendRequests, refreshSentFriendRequests } = useChatContext();
9095
+ const [loading, setLoading] = useState42(false);
9096
+ const refetch = useCallback36(async () => {
9097
+ setLoading(true);
9098
+ await refreshSentFriendRequests();
9099
+ setLoading(false);
9100
+ }, [refreshSentFriendRequests]);
9101
+ return { requests: sentFriendRequests, loading, refetch };
9102
+ }
9103
+ function useCancelFriendRequest() {
9104
+ const { client } = useDubs();
9105
+ const { refreshSentFriendRequests } = useChatContext();
9106
+ const [loading, setLoading] = useState42(false);
9107
+ const cancel = useCallback36(
9108
+ async (requestId) => {
9109
+ setLoading(true);
9110
+ try {
9111
+ await client.cancelFriendRequest(requestId);
9112
+ await refreshSentFriendRequests();
9113
+ } finally {
9114
+ setLoading(false);
9115
+ }
9116
+ },
9117
+ [client, refreshSentFriendRequests]
9118
+ );
9119
+ return { cancel, loading };
9120
+ }
9055
9121
  function useSearchUsers() {
9056
9122
  const { client } = useDubs();
9057
9123
  const [results, setResults] = useState42([]);
@@ -9169,6 +9235,7 @@ export {
9169
9235
  useArcadePool,
9170
9236
  useArcadePools,
9171
9237
  useAuth,
9238
+ useCancelFriendRequest,
9172
9239
  useChatContext,
9173
9240
  useChatMessages,
9174
9241
  useChatStatus,
@@ -9198,6 +9265,7 @@ export {
9198
9265
  useSearchUsers,
9199
9266
  useSendFriendRequest,
9200
9267
  useSendMessage,
9268
+ useSentFriendRequests,
9201
9269
  useShorts,
9202
9270
  useUFCFightCard,
9203
9271
  useUFCFighterDetail,