new project modal & seperate playback and music likes
This commit is contained in:
@@ -14,6 +14,10 @@ import firebase, {
|
||||
usersRef,
|
||||
} from "../config/firebase";
|
||||
import { getUserPreferredArtistName } from "../utils/artistName";
|
||||
import { getLikeFieldPath, LIKE_TARGET } from "../utils/likes";
|
||||
|
||||
const SONG_LIKES_FIELD = getLikeFieldPath(LIKE_TARGET.SONG);
|
||||
const PLAYBACK_LIKES_FIELD = getLikeFieldPath(LIKE_TARGET.PLAYBACK);
|
||||
|
||||
export const UserDataContext = createContext();
|
||||
|
||||
@@ -63,7 +67,21 @@ export default ({ children }) => {
|
||||
} = useDataFromRef({
|
||||
ref: currentUID
|
||||
? projectsRef
|
||||
.where("likedBy", "array-contains", currentUID)
|
||||
.where(SONG_LIKES_FIELD, "array-contains", currentUID)
|
||||
.orderBy("updatedAt", "desc")
|
||||
: null,
|
||||
simpleRef: false,
|
||||
listener: true,
|
||||
condition: !!currentUID,
|
||||
refreshArray: [currentUID],
|
||||
});
|
||||
const {
|
||||
data: userLikedPlaybacks = [],
|
||||
loading: userLikedPlaybacksLoading = true,
|
||||
} = useDataFromRef({
|
||||
ref: currentUID
|
||||
? projectsRef
|
||||
.where(PLAYBACK_LIKES_FIELD, "array-contains", currentUID)
|
||||
.orderBy("updatedAt", "desc")
|
||||
: null,
|
||||
simpleRef: false,
|
||||
@@ -71,9 +89,6 @@ export default ({ children }) => {
|
||||
condition: !!currentUID,
|
||||
refreshArray: [currentUID],
|
||||
});
|
||||
const userLikedPlaybacks = Array.isArray(userLikedProjects)
|
||||
? userLikedProjects.filter((project) => project.playbackUrl)
|
||||
: [];
|
||||
// Subscribe to user's playlists
|
||||
const { data: userPlaylists = [] } = useDataFromRef({
|
||||
ref: currentUID ? playlistsRef.where("createdBy", "==", currentUID) : null,
|
||||
@@ -406,7 +421,7 @@ export default ({ children }) => {
|
||||
userLikedProjects,
|
||||
userLikedProjectsLoading,
|
||||
userLikedPlaybacks,
|
||||
userLikedPlaybacksLoading: userLikedProjectsLoading,
|
||||
userLikedPlaybacksLoading,
|
||||
userPlaylists,
|
||||
selectedProjectId,
|
||||
selectedProject,
|
||||
|
||||
Reference in New Issue
Block a user