fix: filter undefined posts/topics

This commit is contained in:
Barış Soner Uşaklı
2024-11-13 18:38:36 -05:00
parent 20da71485f
commit db291ecde1

View File

@@ -111,7 +111,9 @@ async function sendNotifications(uids, topicsData) {
const userData = await user.getUsersData(uids);
const uidToUserData = Object.fromEntries(uids.map((uid, idx) => [uid, userData[idx]]));
const postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid));
let postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid));
topicsData = topicsData.filter((t, i) => t && postsData[i]);
postsData = postsData.filter(Boolean);
postsData.forEach((postData, idx) => {
if (postData) {
postData.user = uidToUserData[topicsData[idx].uid];