clear last tickets
This commit is contained in:
@@ -72,19 +72,46 @@ export default ({ children }) => {
|
||||
projects: userLikedProjects = [],
|
||||
loading: userLikedProjectsLoading = true,
|
||||
} = useUserLikedProjects();
|
||||
const toTimestamp = useCallback((value) => {
|
||||
if (!value) return 0;
|
||||
if (typeof value.toDate === "function") {
|
||||
return value.toDate().getTime();
|
||||
}
|
||||
if (typeof value.seconds === "number") {
|
||||
return value.seconds * 1000;
|
||||
}
|
||||
if (typeof value === "number") {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}, []);
|
||||
const sortByPlaybackLikeDate = useCallback(
|
||||
(list) => {
|
||||
if (!Array.isArray(list)) return [];
|
||||
const getLikeTimestamp = (project) => {
|
||||
const likedAt = project?.likes?.playbackLikedAt?.[currentUID];
|
||||
const likedAtTs = likedAt ? toTimestamp(likedAt) : 0;
|
||||
if (likedAtTs > 0) return likedAtTs;
|
||||
return toTimestamp(project?.updatedAt);
|
||||
};
|
||||
return [...list].sort(
|
||||
(a, b) => getLikeTimestamp(b) - getLikeTimestamp(a),
|
||||
);
|
||||
},
|
||||
[currentUID, toTimestamp],
|
||||
);
|
||||
const {
|
||||
data: userLikedPlaybacks = [],
|
||||
loading: userLikedPlaybacksLoading = true,
|
||||
} = useDataFromRef({
|
||||
ref: currentUID
|
||||
? projectsRef
|
||||
.where(PLAYBACK_LIKES_FIELD, "array-contains", currentUID)
|
||||
.orderBy("updatedAt", "desc")
|
||||
? projectsRef.where(PLAYBACK_LIKES_FIELD, "array-contains", currentUID)
|
||||
: null,
|
||||
simpleRef: false,
|
||||
listener: true,
|
||||
condition: !!currentUID,
|
||||
refreshArray: [currentUID],
|
||||
format: sortByPlaybackLikeDate,
|
||||
});
|
||||
// Subscribe to user's playlists
|
||||
const { data: userPlaylists = [] } = useDataFromRef({
|
||||
|
||||
Reference in New Issue
Block a user