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

Fix/modal view change #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Components/DOM/VoteStatusButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function VoteStatusButton({
issueID,
contributorID,
side,
clicked,
modalOpen,
toggleModal,
socketEvents
}) {
Expand All @@ -22,7 +22,7 @@ export default function VoteStatusButton({
});
const [voteTotals, setVoteTotals] = useState(0);

const { prData, loading } = useGetVotes(user, repoID, issueID, contributorID, side, socketEvents, clicked);
const { prData, loading } = useGetVotes(user, repoID, issueID, contributorID, side, socketEvents, modalOpen);

const buttonStyle = {
vote: ['lightgreen', 'vote'],
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useGetVotes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { postGetVotes } from '../requests';
const useGetVotes = (user, repoID, issueID, contributorID, side, socketEvents, clicked) => {
const useGetVotes = (user, repoID, issueID, contributorID, side, socketEvents, modalOpen) => {
const [prData, setPRData] = useState({});
const [loading, setLoading] = useState(true);
useEffect(() => {
Expand All @@ -17,7 +17,7 @@ const useGetVotes = (user, repoID, issueID, contributorID, side, socketEvents, c
};

fetchData();
}, [user, repoID, issueID, contributorID, side, socketEvents, clicked]);
}, [user, repoID, issueID, contributorID, side, socketEvents, modalOpen]);
return { prData, loading };
};

Expand Down
12 changes: 7 additions & 5 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ let getFromStorage = keys =>
let socketEvents = 0;
let getVotesRes;
let getVotes = async () => await postGetVotes(repoID, issue_id, contributor_id);
const clickedState = {
clicked: false
const modalState = {
modalOpen: false,
currentIssueID: issue_id
};

// Modal functionality below:
Expand All @@ -225,6 +226,7 @@ let getFromStorage = keys =>
modal.style.display = 'block';
const domContainerModal = myModalNode;
getVotesRes = await getVotes();
modalState.currentIssueID = issue_id;
render(
ce(ModalVote, {
user: user,
Expand Down Expand Up @@ -252,7 +254,7 @@ let getFromStorage = keys =>

// Update modal (if open) if its associated PR has been voted upon
const updateModalVotesTable = async issueID => {
if (issueID === issue_id && modal.style.display === 'block') {
if (issueID === modalState.currentIssueID && modal.style.display === 'block') {
const domContainerModal = myModalNode;
render(
ce(ModalVote, {
Expand Down Expand Up @@ -289,7 +291,7 @@ let getFromStorage = keys =>
issueID: issue_id,
contributorName: contributor_name,
contributorID: contributor_id,
clicked: clickedState.clicked,
modalOpen: modalState.modalOpen,
toggleModal: toggleModal
}),
domContainerTurboSrcButton
Expand All @@ -313,7 +315,7 @@ let getFromStorage = keys =>
contributorName: contributor_name,
contributorID: contributor_id,
repoData: repoData,
clicked: clickedState.clicked,
modalOpen: modalState.modalOpen,
toggleModal: toggleModal,
socketEvents: socketEvents
}),
Expand Down