Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Move song status to store #99

Merged
merged 10 commits into from
Jan 18, 2020

Conversation

Andronikus
Copy link
Contributor

Display Trello task link

Features/Libraries

  • Redux Store updated
    Added to Song object in Redux Store the following attributes: duration, currentTime and isPlayPressed.

This state was managed internally in App.js and PlayBar.js. Now the state is in Redux Store and its is managed in App.js (dispatch actions) only.

@YogiHa
Copy link
Contributor

YogiHa commented Jan 11, 2020

Hi @Andronikus and thanks for your time and contribution :)

For me to be able to review your PR agianst the current project, I need you to fetch the upstream by -

git checkout development - visit development branch
git fetch upstream development - get the newest changes from the development branch.
git merge upstream/development - merge development branch to your own local branch.
git checkout moveSongStatusToStore - visit your current branch
git merge upstream/development - merge development branch changes with your current changes.

after that run
$ git status
for check files that both you and other members modified for manually adjustment.
( on the way, you can delete { route } at initialState.js that is useless code pls :) )
and then push again.

BTW, lovely done on App.js and AppBrowser.js for making whole app not render by redux constantly!

@@ -0,0 +1,23 @@
export function getSecondsFromTimeFormated(time){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const getSecondsFromTimeFormated = time =>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this function. With later developments it will not be needed anymore

Comment on lines 6 to 16
import { reduxFirestore, getFirestore } from 'redux-firestore';
import FBConfig from '../firebase/config';

const composeEnhancers = (process.env.NODE_ENV === 'development' ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : null) || compose;

export const store = createStore(
rootReducer,
compose(
composeEnhancers(
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
reactReduxFirebase(FBConfig, {
userProfile: 'users',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need to push this file to git

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its true! Will kept it in my local branch only

Comment on lines 13 to 16
case 'SONG_CLEARED':
return {
downloadState: false,
song: {
url: null,
name: null,
blob: null
}
song: initialState.song
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch for the conflict here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already resolved!

Comment on lines 17 to 27
// const song = useSelector(state => state.song);
const songUrl = useSelector(state => state.song.url);

return (
<div>
{uid ? (
<div>{songUrl ? <App /> : <UploadSong />}</div>
) : (
<Redirect to="/" />
)}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this file a first chat functionality added,
supposedly it don't affect the same changes you did at that file, but be careful not delete those

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already merged this too! Was careful not to delete changes already added

Comment on lines 87 to 90
const currentTime = getTimeFormated(e.target.currentTime);
if(!songCurrentTime || songCurrentTime !== currentTime){
dispatch(setCurrentTimeFormated(currentTime));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in later versions of this file, there was some other workaround regard song time, that implemented directly on { onTimeUpdate } method of the audio ref.
just change there the { setCurenntTIme } function in the end to go through redux and delete this function and I think it is gonna work fine.

Comment on lines 43 to 67
// Set formated duration
useEffect(() => {
setFormatedDuration(getTime(duration));
}, [duration]);

// Set formated current time
useEffect(() => {
setFormatedCurrentTime(getTime(currentTime));
}, [currentTime]);

// Format time (eg. 140 to 2:20)
const getTime = dur => {
return (
Math.floor(dur / 60) + ':' + ('0' + Math.floor(dur % 60)).slice(-2)
);
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you delete those and created a songUtil, at App.js { OnTimeUpdate } at the audio ref at later version of the code there is usage of parse.int that also can be refracted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

song duration & song current time will be in sec at redux store so I will keep the util file to convert the seconds in a string.

// Local States
const [playPressed, setPlayPressed] = useState(false);
const [uploadedSong, setUploadedSong] = useState(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece of state has been deleted because it is just a duplication of redux song state. Pls don't re-add it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

isPlaying={isPlaying}
uploadedSong={song}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for comment above,
You can go to PlayerBar.is and there change the reference of { uploaded song } prop to redux store state, and on the way delete few other props as { playPressed, onPlayPress} etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Already did some cleaning in PlayerBar.js and Visualizer.js and App.js

name: null,
blob: null
};
return initialState.song;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@YogiHa
Copy link
Contributor

YogiHa commented Jan 17, 2020

whole server dir don't exist at your branch,
please git add it to

@YogiHa YogiHa merged commit 78138b0 into zero-to-mastery:development Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants