-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/home #71
base: master
Are you sure you want to change the base?
Refactor/home #71
Conversation
@@ -61,6 +61,7 @@ export default function VoteStatusButton(props){ | |||
} | |||
setVoteYesTotalState(voteYesTotal); | |||
setVoteNoTotalState(voteNoTotal); | |||
console.log(tsrcPRStatusComponent, "tsrcPRStatusComponent"); |
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.
Remove
@@ -80,6 +81,7 @@ export default function VoteStatusButton(props){ | |||
if(!tsrcPRStatus.mergeableCodeHost) { | |||
tsrcPRStatus.state = 'conflict'; | |||
} | |||
console.log(tsrcPRStatus, "tsrcPRStatus"); |
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.
Remove
setSelectedPullRequestChildDefaultHash(pullRequest.childDefaultHash); | ||
setSelectedPullRequestIssueID(pullRequest.issue_id); | ||
setSelectedPullRequest({ ...pullRequest }); | ||
console.log(selectedPullRequest, "selected pull req") |
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.
Remove
src/hooks/useRepoData.js
Outdated
const fetchRepoData = async () => { | ||
try { | ||
const response = await postGetRepoData(`${owner}/${repo}`, ethereumAddress); | ||
console.log("this is the response", response); |
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.
Remove
setTextType('No'); | ||
} | ||
|
||
console.log("this is the text type", voted, chosenSide, disabled); | ||
console.log("this is the text type", voted, side, disabled); |
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.
Remove
setDisabled(true); | ||
} | ||
}, [state]); | ||
console.log(votePower, "vote power"); |
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.
Remove
</BoldText> | ||
</OwnerRepo> | ||
{onTurboSrc ? ( | ||
<VotePower>{votePowerAmount === 0 ? '0 votepower' : `${votePowerAmount} votepower`}</VotePower> |
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.
Capital V and P - VotePower
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.
Also the font weight seems to change from Home to Single PR view in the Top Bar
</div> | ||
</> | ||
)} | ||
{onTurboSrc ? null : loading ? ( |
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 conditional is confusing
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 think we can take out the onTurboSrc ? null : and just have the loading ? etc
export default function Home() { | ||
const user = useSelector(state => state.auth.user); | ||
const repo = useSelector(state => state.repo.name); | ||
const owner = useSelector(state => state.repo.owner.login); | ||
const oldVersion = false; | ||
const [pullRequests, setPullRequests] = useState([]); | ||
const [tokenized, setTokenized] = useState(false); | ||
const [loading, setLoading] = useState(true); | ||
const [seeModal, setSeeModal] = useState(false); |
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.
Please change seeModal to [seeSinglePR, setSeeSinglePR]
export default function Home() { | ||
const user = useSelector(state => state.auth.user); | ||
const repo = useSelector(state => state.repo.name); | ||
const owner = useSelector(state => state.repo.owner.login); | ||
const oldVersion = false; | ||
const [pullRequests, setPullRequests] = useState([]); | ||
const [tokenized, setTokenized] = useState(false); | ||
const [loading, setLoading] = useState(true); |
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.
Please declare the loading variable in the useGetRepoData hook and return it
It should be dependent on the response from useGetRepoData, so when the res is ready, set it to false
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.
There could also be a variable called errorText in useGetRepoData which would set an error message to display in Home.js
.catch(error => if(error.status >= 400) {setErrorText('There was an error fetching the data')}
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.
Update - this could be a stretch goal. We could do it later on
</> | ||
)} | ||
{onTurboSrc ? null : loading ? ( | ||
<SkeletonModal /> |
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.
Remove Modal wording, SkeletonHome or something like that would be better
@@ -63,7 +63,6 @@ export default function VoteStatusButton(props){ | |||
setVoteNoTotalState(voteNoTotal); | |||
setTsrcPRStatus(tsrcPRStatusComponent); | |||
} catch (error) { | |||
console.log('fetchVoteStatus error:', error) |
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 believe VoteStatusButton is outside of the scope of refactoring the extension Home page, also the console log is fine if it is console logging an error in a trycatch
setDisabled(true); | ||
} | ||
}, [state]); | ||
const SinglePullRequestView = ({ selectedPullRequest, user, repo, githubToken, owner }) => { |
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.
option + shift + f
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.
opt + shift + f
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.
opt + shift + f
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.
opt + shift + f
src/hooks/useRepoData.js
Outdated
} | ||
}; | ||
fetchRepoData(); | ||
}, 500); |
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.
Can you experiment with taking out the setTimeout? It should work just with owner and repo as dependencies
|
||
socket.on('vote received', function(ownerFromServer, repoFromServer, issueIDFromServer) { | ||
if (owner === ownerFromServer && repo === repoFromServer) { | ||
getRepoDataHandler(); | ||
const { onTurboSrc, pullRequests, votePowerAmount } = useRepoData(owner, repo, ethereumAddress); |
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 think change the declarations above to be let instead of const
then just reassign them here
}, 500); | ||
setPullRequestsLoaded(false); | ||
}, [owner, repo]); | ||
const { onTurboSrc, pullRequests, votePowerAmount } = useRepoData(owner, repo, user.ethereumAddress); |
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.
let
|
||
let [tokenAmount, setTokenAmount] = useState(''); | ||
|
||
let avatar = user?.avatar_url || null; | ||
|
||
useEffect(() => { | ||
//Set current logged in contributor/id to chrome storage for inject to verify user for voting | ||
chrome.storage.local.set({ contributor_name: user.login }); | ||
chrome.storage.local.set({ contributor_id: user.ethereumAddress }); | ||
setTimeout(() => setLoading(false), 1500); |
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'd like to remove this setTimeout and have the loading be dependent on the res inside useGetRepoData
<TopInfoBar owner={owner} repo={repo} votePowerAmount={votePowerAmount} onTurboSrc={onTurboSrc} /> | ||
{onTurboSrc && ( | ||
<TopInfoBar owner={owner} repo={repo} votePowerAmount={useCommas(votePowerAmount)} onTurboSrc={onTurboSrc} /> | ||
{onTurboSrc ? ( |
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.
The logic here is showing the loader forever if the repo is not on turbosrc
The order for the conditional logic should be more intuitive.
- If loading should be first as a switch case
- if on turbosrc should be second
- and if not on turbosrc should be last
No description provided.