-
Notifications
You must be signed in to change notification settings - Fork 69
Move song status to store #99
Move song status to store #99
Conversation
Merging development changes, to master branch.
Merge development to master
Merging Development changes to master
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 after that run BTW, lovely done on App.js and AppBrowser.js for making whole app not render by redux constantly! |
src/utils/timeConversion.js
Outdated
@@ -0,0 +1,23 @@ | |||
export function getSecondsFromTimeFormated(time){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getSecondsFromTimeFormated = time =>
There was a problem hiding this comment.
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
src/store/store.js
Outdated
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', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/store/reducers/songReducer.js
Outdated
case 'SONG_CLEARED': | ||
return { | ||
downloadState: false, | ||
song: { | ||
url: null, | ||
name: null, | ||
blob: null | ||
} | ||
song: initialState.song |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already resolved!
src/pages/App/AppBrowser.js
Outdated
// const song = useSelector(state => state.song); | ||
const songUrl = useSelector(state => state.song.url); | ||
|
||
return ( | ||
<div> | ||
{uid ? ( | ||
<div>{songUrl ? <App /> : <UploadSong />}</div> | ||
) : ( | ||
<Redirect to="/" /> | ||
)} | ||
</div> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/pages/App/App.js
Outdated
const currentTime = getTimeFormated(e.target.currentTime); | ||
if(!songCurrentTime || songCurrentTime !== currentTime){ | ||
dispatch(setCurrentTimeFormated(currentTime)); | ||
} |
There was a problem hiding this comment.
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.
// 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) | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/pages/App/App.js
Outdated
// Local States | ||
const [playPressed, setPlayPressed] = useState(false); | ||
const [uploadedSong, setUploadedSong] = useState(null); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
whole server dir don't exist at your branch, |
Display Trello task link
Features/Libraries
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.