@dubsdotapp/expo 0.5.24 → 0.5.25
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 +89 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -5
- 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 +31 -3
- 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,6 +8907,7 @@ 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
|
},
|
|
8879
8912
|
onFriendRequestAccepted: () => {
|
|
8880
8913
|
refreshFriends();
|
|
@@ -8892,10 +8925,12 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8892
8925
|
});
|
|
8893
8926
|
refreshSentFriendRequests().catch(() => {
|
|
8894
8927
|
});
|
|
8928
|
+
refreshWhatsNew().catch(() => {
|
|
8929
|
+
});
|
|
8895
8930
|
return () => {
|
|
8896
8931
|
chatSocket.disconnect();
|
|
8897
8932
|
};
|
|
8898
|
-
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
|
|
8933
|
+
}, [client, autoConnect, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8899
8934
|
useEffect29(() => {
|
|
8900
8935
|
const handleAppState = (nextState) => {
|
|
8901
8936
|
if (nextState === "active") {
|
|
@@ -8917,11 +8952,13 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8917
8952
|
});
|
|
8918
8953
|
refreshSentFriendRequests().catch(() => {
|
|
8919
8954
|
});
|
|
8955
|
+
refreshWhatsNew().catch(() => {
|
|
8956
|
+
});
|
|
8920
8957
|
}
|
|
8921
8958
|
};
|
|
8922
8959
|
const sub = AppState.addEventListener("change", handleAppState);
|
|
8923
8960
|
return () => sub.remove();
|
|
8924
|
-
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]);
|
|
8961
|
+
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8925
8962
|
const value = useMemo11(
|
|
8926
8963
|
() => ({
|
|
8927
8964
|
socket: socketRef.current,
|
|
@@ -8934,13 +8971,16 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8934
8971
|
friends,
|
|
8935
8972
|
pendingRequests,
|
|
8936
8973
|
sentFriendRequests,
|
|
8974
|
+
whatsNewPosts,
|
|
8975
|
+
whatsNewUnreadCount,
|
|
8937
8976
|
refreshMessages,
|
|
8938
8977
|
refreshConversations,
|
|
8939
8978
|
refreshFriends,
|
|
8940
8979
|
refreshPendingRequests,
|
|
8941
|
-
refreshSentFriendRequests
|
|
8980
|
+
refreshSentFriendRequests,
|
|
8981
|
+
refreshWhatsNew
|
|
8942
8982
|
}),
|
|
8943
|
-
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests]
|
|
8983
|
+
[status, messages, onlineUsers, onlineCount, unreadCount, conversations, friends, pendingRequests, sentFriendRequests, whatsNewPosts, whatsNewUnreadCount, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]
|
|
8944
8984
|
);
|
|
8945
8985
|
return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
|
|
8946
8986
|
}
|
|
@@ -9186,6 +9226,47 @@ function useRespondToFriendRequest() {
|
|
|
9186
9226
|
);
|
|
9187
9227
|
return { accept, reject, loading };
|
|
9188
9228
|
}
|
|
9229
|
+
function useWhatsNew() {
|
|
9230
|
+
const { client } = useDubs();
|
|
9231
|
+
const { whatsNewPosts, whatsNewUnreadCount, refreshWhatsNew } = useChatContext();
|
|
9232
|
+
const [loading, setLoading] = useState42(false);
|
|
9233
|
+
const refetch = useCallback36(async () => {
|
|
9234
|
+
setLoading(true);
|
|
9235
|
+
try {
|
|
9236
|
+
await refreshWhatsNew();
|
|
9237
|
+
} finally {
|
|
9238
|
+
setLoading(false);
|
|
9239
|
+
}
|
|
9240
|
+
}, [refreshWhatsNew]);
|
|
9241
|
+
const markRead = useCallback36(
|
|
9242
|
+
async (postIds) => {
|
|
9243
|
+
if (postIds.length === 0) return;
|
|
9244
|
+
try {
|
|
9245
|
+
await client.markWhatsNewRead(postIds);
|
|
9246
|
+
await refreshWhatsNew();
|
|
9247
|
+
} catch (err) {
|
|
9248
|
+
console.error("[Dubs:useWhatsNew] markRead error:", err);
|
|
9249
|
+
}
|
|
9250
|
+
},
|
|
9251
|
+
[client, refreshWhatsNew]
|
|
9252
|
+
);
|
|
9253
|
+
const markAllRead = useCallback36(async () => {
|
|
9254
|
+
try {
|
|
9255
|
+
await client.markAllWhatsNewRead();
|
|
9256
|
+
await refreshWhatsNew();
|
|
9257
|
+
} catch (err) {
|
|
9258
|
+
console.error("[Dubs:useWhatsNew] markAllRead error:", err);
|
|
9259
|
+
}
|
|
9260
|
+
}, [client, refreshWhatsNew]);
|
|
9261
|
+
return {
|
|
9262
|
+
posts: whatsNewPosts,
|
|
9263
|
+
unreadCount: whatsNewUnreadCount,
|
|
9264
|
+
loading,
|
|
9265
|
+
refetch,
|
|
9266
|
+
markRead,
|
|
9267
|
+
markAllRead
|
|
9268
|
+
};
|
|
9269
|
+
}
|
|
9189
9270
|
export {
|
|
9190
9271
|
ArcadeLeaderboardSheet,
|
|
9191
9272
|
AuthGate,
|
|
@@ -9269,6 +9350,7 @@ export {
|
|
|
9269
9350
|
useShorts,
|
|
9270
9351
|
useUFCFightCard,
|
|
9271
9352
|
useUFCFighterDetail,
|
|
9272
|
-
useUnreadCount
|
|
9353
|
+
useUnreadCount,
|
|
9354
|
+
useWhatsNew
|
|
9273
9355
|
};
|
|
9274
9356
|
//# sourceMappingURL=index.mjs.map
|