Skip to content

Commit

Permalink
fix: few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Sep 21, 2023
1 parent ceb57b3 commit cbf8be9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 42 deletions.
4 changes: 2 additions & 2 deletions packages/context/MediaPlayerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ export const MediaPlayerContextProvider: React.FC = ({ children }) => {
const onChangeTimerPosition = (value: number) =>
sound?.setPositionAsync(value);

const onChangeVolume = async (value: number) =>
await sound?.setVolumeAsync(value);
const onChangeVolume = (value: number) =>
sound?.setVolumeAsync(isNaN(value) ? 0 : value); // value is NaN in local dev env sometimes

const onToggleLoop = () => {
sound?.setIsLoopingAsync(!playbackStatus?.isLooping);
Expand Down
7 changes: 5 additions & 2 deletions packages/screens/Music/components/MusicHomeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const MusicHomeContent: React.FC<MusicPlayerProps> = ({
idList,
}) => {
const [openUploadModal, setOpenUploadModal] = useState<boolean>(false);
const { data, isFetching, hasNextPage, fetchNextPage, isLoading } =
const { data, isFetching, hasNextPage, fetchNextPage, isLoading, refetch } =
useFetchAlbums(req);

const isLoadingValue = useSharedValue(false);
Expand Down Expand Up @@ -109,7 +109,10 @@ export const MusicHomeContent: React.FC<MusicPlayerProps> = ({
</View>
<UploadAlbumModal
isVisible={openUploadModal}
onClose={() => setOpenUploadModal(false)}
onClose={() => {
setOpenUploadModal(false);
refetch();
}}
/>
</View>
);
Expand Down
9 changes: 7 additions & 2 deletions packages/screens/Music/components/MusicMyLibraryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const MusicMyLibraryContent: React.FC<{ idList: string[] }> = ({
const userId = getUserId(selectedNetworkId, wallet?.address);

const [flatListContentOffsetY, setFlatListContentOffsetY] = useState(0);
const { data, isFetching, hasNextPage, fetchNextPage, isLoading } =
const { data, isFetching, hasNextPage, fetchNextPage, isLoading, refetch } =
useUserFetchAlbum({
limit: 10,
offset: 0,
Expand All @@ -59,6 +59,7 @@ export const MusicMyLibraryContent: React.FC<{ idList: string[] }> = ({
hasNextPage: hasNextPageOther,
fetchNextPage: fetchNextPageOther,
isLoading: isLoadingOther,
refetch: refetchOther,
} = useOtherFetchAlbum({
limit: 10,
offset: 0,
Expand Down Expand Up @@ -192,7 +193,11 @@ export const MusicMyLibraryContent: React.FC<{ idList: string[] }> = ({
</View>
<UploadAlbumModal
isVisible={openUploadModal}
onClose={() => setOpenUploadModal(false)}
onClose={() => {
setOpenUploadModal(false);
refetch();
refetchOther();
}}
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const TrackHoverMenu: React.FC<TrackHoverMenuProps> = ({
>
<View style={oneLineStyle}>
<SVG source={RemoveLibrary} width={16} height={16} />
<SpacerRow size={1} />
<BrandText style={text}>Remove from library</BrandText>
</View>
</HoverView>
Expand All @@ -139,6 +140,7 @@ export const TrackHoverMenu: React.FC<TrackHoverMenuProps> = ({
width={layout.spacing_x2}
height={layout.spacing_x2}
/>
<SpacerRow size={1} />
<BrandText style={text}>Tip this track</BrandText>
</View>
</HoverView>
Expand All @@ -160,6 +162,7 @@ export const TrackHoverMenu: React.FC<TrackHoverMenuProps> = ({
width={layout.spacing_x2}
height={layout.spacing_x2}
/>
<SpacerRow size={1} />
<BrandText style={text}>Copy track's URL</BrandText>
</View>
</HoverView>
Expand Down
83 changes: 47 additions & 36 deletions packages/screens/MusicAlbum/components/UploadAlbumModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ export const UploadAlbumModal: React.FC<UploadAlbumModalProps> = ({
width={UPLOAD_ALBUM_MODAL_WIDTH}
>
<View style={inputBoxStyle}>
<View style={imgBoxStyle}>
<View
style={[imgBoxStyle, (isUploading || isLoading) && { opacity: 0.5 }]}
>
<Image
source={
albumInfo.image === ""
Expand All @@ -236,7 +238,11 @@ export const UploadAlbumModal: React.FC<UploadAlbumModalProps> = ({
setIsLoading={setIsLoading}
>
{({ onPress }) => (
<TouchableOpacity style={uploadButtonStyle} onPress={onPress}>
<TouchableOpacity
style={uploadButtonStyle}
onPress={onPress}
disabled={isUploading || isLoading}
>
<SVG source={Img} width={16} height={16} />
<SpacerRow size={1} />
<BrandText style={fontSemibold14}>upload image</BrandText>
Expand Down Expand Up @@ -266,41 +272,39 @@ export const UploadAlbumModal: React.FC<UploadAlbumModalProps> = ({
/>
</View>
</View>

{!!audios.length && <SpacerColumn size={2.5} />}
<DraxProvider>
<View>
<DraxList
data={audios}
onItemReorder={({ fromIndex, toIndex }) => {
const newAudios = audios.slice();
newAudios.splice(toIndex, 0, newAudios.splice(fromIndex, 1)[0]);
setAudios(newAudios);
}}
renderItemContent={({ item, index }) => {
return (
<Fragment key={index}>
<SpacerColumn size={0.5} />
<View style={unitBoxStyle}>
<View style={oneLineStyle}>
<TouchableOpacity>
<SVG source={List} width={16} height={16} />
</TouchableOpacity>
<SpacerRow size={1.5} />
<BrandText style={fontSemibold14}>{item.name}</BrandText>
</View>
<View style={oneLineStyle}>
<TouchableOpacity onPress={() => onItemRemove(index)}>
<SVG source={TrashCircle} width={24} height={24} />
</TouchableOpacity>
</View>
<DraxList
data={audios}
onItemReorder={({ fromIndex, toIndex }) => {
const newAudios = audios.slice();
newAudios.splice(toIndex, 0, newAudios.splice(fromIndex, 1)[0]);
setAudios(newAudios);
}}
renderItemContent={({ item, index }) => {
return (
<Fragment key={index}>
<SpacerColumn size={0.5} />
<View style={unitBoxStyle}>
<View style={oneLineStyle}>
<TouchableOpacity>
<SVG source={List} width={16} height={16} />
</TouchableOpacity>
<SpacerRow size={1.5} />
<BrandText style={fontSemibold14}>{item.name}</BrandText>
</View>
<SpacerColumn size={0.5} />
</Fragment>
);
}}
keyExtractor={(item) => item.fileUrl}
/>
</View>
<View style={oneLineStyle}>
<TouchableOpacity onPress={() => onItemRemove(index)}>
<SVG source={TrashCircle} width={24} height={24} />
</TouchableOpacity>
</View>
</View>
<SpacerColumn size={0.5} />
</Fragment>
);
}}
keyExtractor={(item) => item.fileUrl}
/>
</DraxProvider>

<FileUploader
Expand All @@ -311,7 +315,14 @@ export const UploadAlbumModal: React.FC<UploadAlbumModalProps> = ({
setIsLoading={setIsLoading}
>
{({ onPress }) => (
<TouchableOpacity style={buttonContainerStyle} onPress={onPress}>
<TouchableOpacity
style={[
buttonContainerStyle,
(isUploading || isLoading) && { opacity: 0.5 },
]}
onPress={onPress}
disabled={isUploading || isLoading}
>
<SVG source={Add} width={20} height={20} />
<SpacerRow size={1} />
<BrandText style={buttonTextStyle}>Add songs</BrandText>
Expand Down

0 comments on commit cbf8be9

Please sign in to comment.