@dubsdotapp/expo 0.5.23 → 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 +97 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -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 +38 -4
- 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") {
|
|
@@ -8909,11 +8944,21 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8909
8944
|
}
|
|
8910
8945
|
}
|
|
8911
8946
|
refreshMessages();
|
|
8947
|
+
refreshConversations().catch(() => {
|
|
8948
|
+
});
|
|
8949
|
+
refreshFriends().catch(() => {
|
|
8950
|
+
});
|
|
8951
|
+
refreshPendingRequests().catch(() => {
|
|
8952
|
+
});
|
|
8953
|
+
refreshSentFriendRequests().catch(() => {
|
|
8954
|
+
});
|
|
8955
|
+
refreshWhatsNew().catch(() => {
|
|
8956
|
+
});
|
|
8912
8957
|
}
|
|
8913
8958
|
};
|
|
8914
8959
|
const sub = AppState.addEventListener("change", handleAppState);
|
|
8915
8960
|
return () => sub.remove();
|
|
8916
|
-
}, [client, refreshMessages, refreshConversations]);
|
|
8961
|
+
}, [client, refreshMessages, refreshConversations, refreshFriends, refreshPendingRequests, refreshSentFriendRequests, refreshWhatsNew]);
|
|
8917
8962
|
const value = useMemo11(
|
|
8918
8963
|
() => ({
|
|
8919
8964
|
socket: socketRef.current,
|
|
@@ -8926,13 +8971,16 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8926
8971
|
friends,
|
|
8927
8972
|
pendingRequests,
|
|
8928
8973
|
sentFriendRequests,
|
|
8974
|
+
whatsNewPosts,
|
|
8975
|
+
whatsNewUnreadCount,
|
|
8929
8976
|
refreshMessages,
|
|
8930
8977
|
refreshConversations,
|
|
8931
8978
|
refreshFriends,
|
|
8932
8979
|
refreshPendingRequests,
|
|
8933
|
-
refreshSentFriendRequests
|
|
8980
|
+
refreshSentFriendRequests,
|
|
8981
|
+
refreshWhatsNew
|
|
8934
8982
|
}),
|
|
8935
|
-
[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]
|
|
8936
8984
|
);
|
|
8937
8985
|
return /* @__PURE__ */ jsx27(ChatContext.Provider, { value, children });
|
|
8938
8986
|
}
|
|
@@ -9178,6 +9226,47 @@ function useRespondToFriendRequest() {
|
|
|
9178
9226
|
);
|
|
9179
9227
|
return { accept, reject, loading };
|
|
9180
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
|
+
}
|
|
9181
9270
|
export {
|
|
9182
9271
|
ArcadeLeaderboardSheet,
|
|
9183
9272
|
AuthGate,
|
|
@@ -9261,6 +9350,7 @@ export {
|
|
|
9261
9350
|
useShorts,
|
|
9262
9351
|
useUFCFightCard,
|
|
9263
9352
|
useUFCFighterDetail,
|
|
9264
|
-
useUnreadCount
|
|
9353
|
+
useUnreadCount,
|
|
9354
|
+
useWhatsNew
|
|
9265
9355
|
};
|
|
9266
9356
|
//# sourceMappingURL=index.mjs.map
|