Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Bring in library work from protocol repo to deploy to RC #4069

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/common/src/api/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const fetchLibraryCollections = async ({
offset,
limit,
category,
query = '',
query,
sortMethod = 'added_date',
sortDirection = 'desc'
} = args
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/models/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export enum RepostSource {
TRACK_PAGE = 'page',
COLLECTION_PAGE = 'collection page',
HISTORY_PAGE = 'history page',
FAVORITES_PAGE = 'favorites page',
LIBRARY_PAGE = 'library page',
OVERFLOW = 'overflow',
TRACK_LIST = 'track list'
}
Expand All @@ -597,7 +597,7 @@ export enum FavoriteSource {
TRACK_PAGE = 'page',
COLLECTION_PAGE = 'collection page',
HISTORY_PAGE = 'history page',
FAVORITES_PAGE = 'favorites page',
LIBRARY_PAGE = 'library page',
OVERFLOW = 'overflow',
TRACK_LIST = 'track list',
SIGN_UP = 'sign up',
Expand Down Expand Up @@ -685,7 +685,7 @@ export enum CreatePlaylistSource {
NAV = 'nav',
CREATE_PAGE = 'create page',
FROM_TRACK = 'from track',
FAVORITES_PAGE = 'favorites page',
LIBRARY_PAGE = 'library page',
PROFILE_PAGE = 'profile page'
}

Expand Down Expand Up @@ -1025,7 +1025,7 @@ export enum PlaybackSource {
PLAYLIST_TRACK = 'playlist page track list',
PLAYLIST_TILE_TRACK = 'playlist track tile',
HISTORY_PAGE = 'history page',
FAVORITES_PAGE = 'favorites page',
LIBRARY_PAGE = 'library page',
PASSIVE = 'passive',
EMBED_PLAYER = 'embed player',
CHAT_TRACK = 'chat_track',
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/store/cache/collections/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const getTracksFromCollection = (
.filter(Boolean) as EnhancedCollectionTrack[]
}

type EnhancedCollection = Collection & { user: User }
export type EnhancedCollection = Collection & { user: User }
export const getCollectionWithUser = (
state: CommonState,
props: { id?: ID }
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/store/cache/collections/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Migrate utils from packages/web/common/store/cache/collections/utils to here
// TODO: Finish common migration - migrate utils from packages/web/common/store/cache/collections/utils to here:
// https://linear.app/audius/issue/C-1280/migrate-remaining-webcommon-to-common

export * from './reformatCollection'
1 change: 1 addition & 0 deletions packages/common/src/store/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export { tracksActions as savedPageTracksLineupActions } from './saved-page/line
export * as savedPageActions from './saved-page/actions'
export * as savedPageSelectors from './saved-page/selectors'
export * from './saved-page/types'
export * from './saved-page/utils'
export { default as savedPageReducer } from './saved-page/reducer'

export {
Expand Down
112 changes: 99 additions & 13 deletions packages/common/src/store/pages/saved-page/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-nocheck
// TODO(nkang) - convert to TS
import { Favorite } from 'models/Favorite'

import { LibraryCategory, LibraryCategoryType, SavedPageTabs } from './types'

export const FETCH_SAVES = 'SAVED/FETCH_SAVES'
export const FETCH_SAVES_REQUESTED = 'SAVED/FETCH_SAVES_REQUESTED'
export const FETCH_SAVES_SUCCEEDED = 'SAVED/FETCH_SAVES_SUCCEEDED'
Expand All @@ -13,12 +15,21 @@ export const FETCH_MORE_SAVES_FAILED = 'SAVED/FETCH_MORE_SAVES_FAILED'
// Usually when filtering
export const END_FETCHING = 'SAVED/END_FETCHING'

export const ADD_LOCAL_SAVE = 'SAVED/ADD_LOCAL_SAVE'
export const REMOVE_LOCAL_SAVE = 'SAVED/REMOVE_LOCAL_SAVE'
export const ADD_LOCAL_TRACK = 'SAVED/ADD_LOCAL_TRACK'
export const REMOVE_LOCAL_TRACK = 'SAVED/REMOVE_LOCAL_TRACK'
export const ADD_LOCAL_COLLECTION = 'SAVED/ADD_LOCAL_COLLECTION'
export const REMOVE_LOCAL_COLLECTION = 'SAVED/REMOVE_LOCAL_COLLECTION'

export const SET_SELECTED_CATEGORY = 'SAVED/SET_SELECTED_CATEGORY'
export const INIT_COLLECTIONS_CATEGORY_FROM_LOCAL_STORAGE =
'SAVED/INIT_COLLECTIONS_CATEGORY_FROM_LOCAL_STORAGE'
export const INIT_TRACKS_CATEGORY_FROM_LOCAL_STORAGE =
'SAVED/INIT_TRACKS_CATEGORY_FROM_LOCAL_STORAGE'

export const fetchSaves = (
// the filter query for the "get tracks" query
query = '',
category: LibraryCategoryType = LibraryCategory.Favorite,
// the sort method for the "get tracks" query
sortMethod = '',
// the sort direction for the "get tracks" query
Expand All @@ -29,6 +40,7 @@ export const fetchSaves = (
limit = 50
) => ({
type: FETCH_SAVES,
category,
offset,
limit,
query,
Expand All @@ -39,6 +51,7 @@ export const fetchSaves = (
export const fetchMoreSaves = (
// the filter query for the "get tracks" query
query = '',
category: LibraryCategoryType = LibraryCategory.Favorite,
// the sort method for the "get tracks" query
sortMethod = '',
// the sort direction for the "get tracks" query
Expand All @@ -49,6 +62,7 @@ export const fetchMoreSaves = (
limit = 50
) => ({
type: FETCH_MORE_SAVES,
category,
offset,
limit,
query,
Expand All @@ -60,7 +74,7 @@ export const fetchSavesRequested = () => ({
type: FETCH_SAVES_REQUESTED
})

export const fetchSavesSucceeded = (saves) => ({
export const fetchSavesSucceeded = (saves: Favorite[]) => ({
type: FETCH_SAVES_SUCCEEDED,
saves
})
Expand All @@ -69,7 +83,7 @@ export const fetchSavesFailed = () => ({
type: FETCH_SAVES_FAILED
})

export const fetchMoreSavesSucceeded = (saves, offset) => ({
export const fetchMoreSavesSucceeded = (saves: Favorite[], offset: number) => ({
type: FETCH_MORE_SAVES_SUCCEEDED,
saves,
offset
Expand All @@ -79,18 +93,90 @@ export const fetchMoreSavesFailed = () => ({
type: FETCH_MORE_SAVES_FAILED
})

export const endFetching = (endIndex) => ({
export const endFetching = (endIndex: number) => ({
type: END_FETCHING,
endIndex
})

export const addLocalSave = (trackId, uid) => ({
type: ADD_LOCAL_SAVE,
export const addLocalTrack = ({
trackId,
uid
uid,
category
}: {
trackId: number
uid: string
category: LibraryCategoryType
}) => ({
type: ADD_LOCAL_TRACK,
trackId,
uid,
category
})

export const removeLocalTrack = ({
trackId,
category
}: {
trackId: number
category: LibraryCategoryType
}) => ({
type: REMOVE_LOCAL_TRACK,
trackId,
category
})

export const addLocalCollection = ({
collectionId,
isAlbum,
category
}: {
collectionId: number
isAlbum: boolean
category: LibraryCategoryType
}) => ({
type: ADD_LOCAL_COLLECTION,
collectionId,
isAlbum,
category
})

export const removeLocalCollection = ({
collectionId,
isAlbum,
category
}: {
collectionId: number
isAlbum: boolean
category: LibraryCategoryType
}) => ({
type: REMOVE_LOCAL_COLLECTION,
collectionId,
isAlbum,
category
})

export const initializeTracksCategoryFromLocalStorage = (
category: LibraryCategoryType
) => ({
type: INIT_TRACKS_CATEGORY_FROM_LOCAL_STORAGE,
category
})

export const initializeCollectionsCategoryFromLocalStorage = (
category: LibraryCategoryType
) => ({
type: INIT_COLLECTIONS_CATEGORY_FROM_LOCAL_STORAGE,
category
})

export const removeLocalSave = (trackId) => ({
type: REMOVE_LOCAL_SAVE,
trackId
export const setSelectedCategory = ({
category,
currentTab
}: {
category: LibraryCategoryType
currentTab: SavedPageTabs
}) => ({
type: SET_SELECTED_CATEGORY,
category,
currentTab
})
Loading