Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Refactor/home #71

wants to merge 11 commits into from

Conversation

ramirc5
Copy link

@ramirc5 ramirc5 commented Jul 24, 2023

No description provided.

@ramirc5 ramirc5 requested a review from jex441 July 24, 2023 19:59
@@ -61,6 +61,7 @@ export default function VoteStatusButton(props){
}
setVoteYesTotalState(voteYesTotal);
setVoteNoTotalState(voteNoTotal);
console.log(tsrcPRStatusComponent, "tsrcPRStatusComponent");
Copy link

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");
Copy link

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")
Copy link

Choose a reason for hiding this comment

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

Remove

const fetchRepoData = async () => {
try {
const response = await postGetRepoData(`${owner}/${repo}`, ethereumAddress);
console.log("this is the response", response);
Copy link

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);
Copy link

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");
Copy link

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>
Copy link

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

Copy link

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 ? (
Copy link

Choose a reason for hiding this comment

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

This conditional is confusing

Copy link

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);
Copy link

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);
Copy link

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

Copy link

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')}

Copy link

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 />
Copy link

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)
Copy link

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 }) => {
Copy link

Choose a reason for hiding this comment

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

option + shift + f

Copy link

Choose a reason for hiding this comment

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

opt + shift + f

Copy link

Choose a reason for hiding this comment

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

opt + shift + f

Copy link

Choose a reason for hiding this comment

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

opt + shift + f

}
};
fetchRepoData();
}, 500);
Copy link

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);
Copy link

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);
Copy link

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);
Copy link

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 ? (
Copy link

@jex441 jex441 Jul 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants