@dubsdotapp/expo 0.5.24 → 0.5.26
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 +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +101 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/hooks.ts +62 -0
- package/src/chat/index.ts +1 -0
- package/src/chat/provider.tsx +43 -5
- package/src/client.ts +28 -0
- package/src/index.ts +3 -0
- package/src/types.ts +20 -0
package/dist/index.mjs
CHANGED
|
@@ -747,6 +747,27 @@ var DubsClient = class {
|
|
|
747
747
|
async getBlockedUsers() {
|
|
748
748
|
return this.request("GET", "/social/blocked");
|
|
749
749
|
}
|
|
750
|
+
// ── What's New ──
|
|
751
|
+
/** List published What's New posts for this app, with is_read for the current user. */
|
|
752
|
+
async getWhatsNewPosts() {
|
|
753
|
+
return this.request("GET", "/whats-new/posts");
|
|
754
|
+
}
|
|
755
|
+
/** Fetch a single What's New post by id. */
|
|
756
|
+
async getWhatsNewPost(postId) {
|
|
757
|
+
return this.request("GET", `/whats-new/posts/${postId}`);
|
|
758
|
+
}
|
|
759
|
+
/** Number of unread What's New posts for the current user (this app). */
|
|
760
|
+
async getWhatsNewUnreadCount() {
|
|
761
|
+
return this.request("GET", "/whats-new/unread-count");
|
|
762
|
+
}
|
|
763
|
+
/** Mark specific posts as read. */
|
|
764
|
+
async markWhatsNewRead(postIds) {
|
|
765
|
+
await this.request("POST", "/whats-new/mark-read", { postIds });
|
|
766
|
+
}
|
|
767
|
+
/** Mark every unread post as read. */
|
|
768
|
+
async markAllWhatsNewRead() {
|
|
769
|
+
return this.request("POST", "/whats-new/mark-all-read");
|
|
770
|
+
}
|
|
750
771
|
// ── App Config ──
|
|
751
772
|
/** Fetch the app's UI customization config (accent color, icon, tagline, environment) */
|
|
752
773
|
async getAppConfig() {
|
|
@@ -8809,6 +8830,8 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8809
8830
|
const [friends, setFriends] = useState41([]);
|
|
8810
8831
|
const [pendingRequests, setPendingRequests] = useState41([]);
|
|
8811
8832
|
const [sentFriendRequests, setSentFriendRequests] = useState41([]);
|
|
8833
|
+
const [whatsNewPosts, setWhatsNewPosts] = useState41([]);
|
|
8834
|
+
const [whatsNewUnreadCount, setWhatsNewUnreadCount] = useState41(0);
|
|
8812
8835
|
const refreshMessages = useCallback35(async () => {
|
|
8813
8836
|
try {
|
|
8814
8837
|
const res = await client.getChatMessages({ limit: 30 });
|
|
@@ -8845,6 +8868,15 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8845
8868
|
} catch (_) {
|
|
8846
8869
|
}
|
|
8847
8870
|
}, [client]);
|
|
8871
|
+
const refreshWhatsNew = useCallback35(async () => {
|
|
8872
|
+
try {
|
|
8873
|
+
const res = await client.getWhatsNewPosts();
|
|
8874
|
+
setWhatsNewPosts(res.posts);
|
|
8875
|
+
const unread = res.posts.filter((p) => !p.is_read).length;
|
|
8876
|
+
setWhatsNewUnreadCount(unread);
|
|
8877
|
+
} catch (_) {
|
|
8878
|
+
}
|
|
8879
|
+
}, [client]);
|
|
8848
8880
|
useEffect29(() => {
|
|
8849
8881
|
const token = client.getToken();
|
|
8850
8882
|
if (!autoConnect || !token) return;
|
|
@@ -8875,13 +8907,24 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8875
8907
|
refreshSentFriendRequests();
|
|
8876
8908
|
}
|
|
8877
8909
|
if (n.type === "friend_request_declined") refreshSentFriendRequests();
|
|
8910
|
+
if (n.type === "whats_new") refreshWhatsNew();
|
|
8878
8911
|
},
|
|
8912
|
+
// These events now fan out to BOTH parties (server emits to actor's
|
|
8913
|
+
// own room as well), so each handler refreshes every list that could
|
|
8914
|
+
// be affected — works whether this client is the actor or the target.
|
|
8879
8915
|
onFriendRequestAccepted: () => {
|
|
8880
8916
|
refreshFriends();
|
|
8917
|
+
refreshPendingRequests();
|
|
8918
|
+
refreshSentFriendRequests();
|
|
8919
|
+
},
|
|
8920
|
+
onFriendRequestDeclined: () => {
|
|
8921
|
+
refreshPendingRequests();
|
|
8922
|
+
refreshSentFriendRequests();
|
|
8923
|
+
},
|
|
8924
|
+
onFriendRequestCancelled: () => {
|
|
8925
|
+
refreshPendingRequests();
|
|
8881
8926
|
refreshSentFriendRequests();
|
|
8882
8927
|
},
|
|
8883
|
-
onFriendRequestDeclined: () => refreshSentFriendRequests(),
|
|
8884
|
-
onFriendRequestCancelled: () => refreshPendingRequests(),
|
|
8885
8928
|
onFriendRemoved: () => refreshFriends()
|
|
8886
8929
|
});
|
|
8887
8930
|
chatSocket.connect({ host, token });
|
|
@@ -8892,10 +8935,12 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8892
8935
|
});
|
|
8893
8936
|
refreshSentFriendRequests().catch(() => {
|
|
8894
8937
|
});
|
|
8938
|
+
refreshWhatsNew().catch(() => {
|
|
8939
|
+
});
|
|
8895
8940
|
return () => {
|
|
8896
8941
|
chatSocket.disconnect();
|
|
8897
8942
|
};
|
|
8898
|
-
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
|
|
8943
|
+
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8899
8944
|
useEffect29(() => {
|
|
8900
8945
|
const handleAppState = (nextState) => {
|
|
8901
8946
|
if (nextState === "active") {
|
|
@@ -8917,11 +8962,13 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8917
8962
|
});
|
|
8918
8963
|
refreshSentFriendRequests().catch(() => {
|
|
8919
8964
|
});
|
|
8965
|
+
refreshWhatsNew().catch(() => {
|
|
8966
|
+
});
|
|
8920
8967
|
}
|
|
8921
8968
|
};
|
|
8922
8969
|
const sub = AppState.addEventListener("change", handleAppState);
|
|
8923
8970
|
return () => sub.remove();
|
|
8924
|
-
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
|
|
8971
|
+
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8925
8972
|
const value = useMemo11(
|
|
8926
8973
|
() => ({
|
|
8927
8974
|
socket: socketRef.current,
|
|
@@ -8934,13 +8981,16 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8934
8981
|
friends,
|
|
8935
8982
|
pendingRequests,
|
|
8936
8983
|
sentFriendRequests,
|
|
8984
|
+
whatsNewPosts,
|
|
8985
|
+
whatsNewUnreadCount,
|
|
8937
8986
|
refreshMessages,
|
|
8938
8987
|
refreshConversations,
|
|
8939
8988
|
refreshFriends,
|
|
8940
8989
|
refreshPendingRequests,
|
|
8941
|
-
refreshSentFriendRequests
|
|
8990
|
+
refreshSentFriendRequests,
|
|
8991
|
+
refreshWhatsNew
|
|
8942
8992
|
}),
|
|
8943
|
-
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]
|
|
8993
|
+
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, whatsNewPosts, whatsNewUnreadCount, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]
|
|
8944
8994
|
);
|
|
8945
8995
|
return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
|
|
8946
8996
|
}
|
|
@@ -9186,6 +9236,47 @@ function useRespondToFriendRequest() {
|
|
|
9186
9236
|
);
|
|
9187
9237
|
return { accept, reject, loading };
|
|
9188
9238
|
}
|
|
9239
|
+
function useWhatsNew() {
|
|
9240
|
+
const { client } = useDubs();
|
|
9241
|
+
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9242
|
+
const [loading, setLoading] = useState42(false);
|
|
9243
|
+
const refetch = useCallback36(async () => {
|
|
9244
|
+
setLoading(true);
|
|
9245
|
+
try {
|
|
9246
|
+
await refreshWhatsNew();
|
|
9247
|
+
} finally {
|
|
9248
|
+
setLoading(false);
|
|
9249
|
+
}
|
|
9250
|
+
}, [refreshWhatsNew]);
|
|
9251
|
+
const markRead = useCallback36(
|
|
9252
|
+
async (postIds) => {
|
|
9253
|
+
if (postIds.length === 0) return;
|
|
9254
|
+
try {
|
|
9255
|
+
await client.markWhatsNewRead(postIds);
|
|
9256
|
+
await refreshWhatsNew();
|
|
9257
|
+
} catch (err) {
|
|
9258
|
+
console.error("[Dubs:useWhatsNew] markRead error:", err);
|
|
9259
|
+
}
|
|
9260
|
+
},
|
|
9261
|
+
[client, refreshWhatsNew]
|
|
9262
|
+
);
|
|
9263
|
+
const markAllRead = useCallback36(async () => {
|
|
9264
|
+
try {
|
|
9265
|
+
await client.markAllWhatsNewRead();
|
|
9266
|
+
await refreshWhatsNew();
|
|
9267
|
+
} catch (err) {
|
|
9268
|
+
console.error("[Dubs:useWhatsNew] markAllRead error:", err);
|
|
9269
|
+
}
|
|
9270
|
+
}, [client, refreshWhatsNew]);
|
|
9271
|
+
return {
|
|
9272
|
+
posts: whatsNewPosts,
|
|
9273
|
+
unreadCount: whatsNewUnreadCount,
|
|
9274
|
+
loading,
|
|
9275
|
+
refetch,
|
|
9276
|
+
markRead,
|
|
9277
|
+
markAllRead
|
|
9278
|
+
};
|
|
9279
|
+
}
|
|
9189
9280
|
export {
|
|
9190
9281
|
ArcadeLeaderboardSheet,
|
|
9191
9282
|
AuthGate,
|
|
@@ -9269,6 +9360,7 @@ export {
|
|
|
9269
9360
|
useShorts,
|
|
9270
9361
|
useUFCFightCard,
|
|
9271
9362
|
useUFCFighterDetail,
|
|
9272
|
-
useUnreadCount
|
|
9363
|
+
useUnreadCount,
|
|
9364
|
+
useWhatsNew
|
|
9273
9365
|
};
|
|
9274
9366
|
//# sourceMappingURL=index.mjs.map
|