Fixed "voted" text.

This commit is contained in:
Ajay Ramachandran
2020-05-20 23:47:13 -04:00
parent 9ef3ef03a4
commit 0f82c16940

View File

@@ -41,6 +41,7 @@ export interface SkipNoticeState {
downvoting: boolean; downvoting: boolean;
choosingCategory: boolean; choosingCategory: boolean;
thanksForVotingText: boolean; //null until the voting buttons should be hidden
actionState: SkipNoticeAction; actionState: SkipNoticeAction;
} }
@@ -114,6 +115,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
downvoting: false, downvoting: false,
choosingCategory: false, choosingCategory: false,
thanksForVotingText: null,
actionState: SkipNoticeAction.None actionState: SkipNoticeAction.None
} }
@@ -161,29 +163,39 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
<tr id={"sponsorSkipNoticeSecondRow" + this.idSuffix}> <tr id={"sponsorSkipNoticeSecondRow" + this.idSuffix}>
{/* Vote Button Container */} {/* Vote Button Container */}
<td id={"sponsorTimesVoteButtonsContainer" + this.idSuffix} {!this.state.thanksForVotingText ?
className="sponsorTimesVoteButtonsContainer"> <td id={"sponsorTimesVoteButtonsContainer" + this.idSuffix}
className="sponsorTimesVoteButtonsContainer">
{/* Upvote Button */} {/* Upvote Button */}
<img id={"sponsorTimesDownvoteButtonsContainer" + this.idSuffix} <img id={"sponsorTimesDownvoteButtonsContainer" + this.idSuffix}
className="sponsorSkipObject voteButton" className="sponsorSkipObject voteButton"
style={{marginRight: "10px"}} style={{marginRight: "10px"}}
src={chrome.extension.getURL("icons/thumbs_up.svg")} src={chrome.extension.getURL("icons/thumbs_up.svg")}
title={chrome.i18n.getMessage("upvoteButtonInfo")} title={chrome.i18n.getMessage("upvoteButtonInfo")}
onClick={() => this.prepAction(SkipNoticeAction.Upvote)}> onClick={() => this.prepAction(SkipNoticeAction.Upvote)}>
</img> </img>
{/* Report Button */} {/* Report Button */}
<img id={"sponsorTimesDownvoteButtonsContainer" + this.idSuffix} <img id={"sponsorTimesDownvoteButtonsContainer" + this.idSuffix}
className="sponsorSkipObject voteButton" className="sponsorSkipObject voteButton"
src={chrome.extension.getURL("icons/thumbs_down.svg")} src={chrome.extension.getURL("icons/thumbs_down.svg")}
title={chrome.i18n.getMessage("reportButtonInfo")} title={chrome.i18n.getMessage("reportButtonInfo")}
onClick={() => this.adjustDownvotingState(true)}> onClick={() => this.adjustDownvotingState(true)}>
</img> </img>
</td> </td>
:
<td id={"sponsorTimesVoteButtonInfoMessage" + this.idSuffix}
className="sponsorTimesInfoMessage sponsorTimesVoteButtonMessage"
style={{marginRight: "10px"}}>
{this.state.thanksForVotingText}
</td>
}
{/* Unskip Button */} {/* Unskip Button */}
<td className="sponsorSkipNoticeUnskipSection"> <td className="sponsorSkipNoticeUnskipSection">
@@ -499,37 +511,15 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
} }
addVoteButtonInfo(message) { addVoteButtonInfo(message) {
this.resetVoteButtonInfo(); this.setState({
thanksForVotingText: message
//hide report button and text for it });
let downvoteButton = document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix);
if (downvoteButton != null) {
downvoteButton.style.display = "none";
}
let downvoteButtonText = document.getElementById("sponsorTimesReportText" + this.idSuffix);
if (downvoteButtonText != null) {
downvoteButtonText.style.display = "none";
}
//add info
let thanksForVotingText = document.createElement("td");
thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix;
thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
thanksForVotingText.innerText = message;
//add element to div
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText);
} }
resetVoteButtonInfo() { resetVoteButtonInfo() {
let previousInfoMessage = document.getElementById("sponsorTimesVoteButtonInfoMessage" + this.idSuffix); this.setState({
if (previousInfoMessage != null) { thanksForVotingText: null
//remove it });
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage);
}
//show button again
document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display");
} }
closeListener() { closeListener() {