Merge branch 'dev' of https://github.com/spicecat/qOverflow into dev
This commit is contained in:
commit
4efa8b2f65
2 changed files with 14 additions and 4 deletions
|
|
@ -60,6 +60,7 @@ export default function QuestionController() {
|
|||
? protect.splice(protect.indexOf(userData.username), 1)
|
||||
: protect.push(userData.username);
|
||||
ongoingVoteSet(protect, 'protect');
|
||||
window.location.reload(false);
|
||||
}
|
||||
|
||||
function changeClose() {
|
||||
|
|
@ -69,12 +70,14 @@ export default function QuestionController() {
|
|||
? close.splice(close.indexOf(userData.username), 1)
|
||||
: close.push(userData.username);
|
||||
ongoingVoteSet(close, 'close');
|
||||
window.location.reload(false);
|
||||
} else {
|
||||
openQuestion(question_id, userData);
|
||||
reopen.includes(userData.username)
|
||||
? reopen.splice(reopen.indexOf(userData.username), 1)
|
||||
: reopen.push(userData.username);
|
||||
ongoingVoteSet(reopen, 'reopen');
|
||||
window.location.reload(false);
|
||||
}
|
||||
}
|
||||
function handleBounty(amount) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
function getPermissions(questionData, userData, ongoingVote) {
|
||||
const { creator, status, hasAcceptedAnswer } = questionData;
|
||||
|
||||
const { creator, status, hasAcceptedAnswer, close, reopen, protect } = questionData;
|
||||
const { username } = userData;
|
||||
|
||||
var permissions = {
|
||||
|
|
@ -10,19 +12,24 @@ function getPermissions(questionData, userData, ongoingVote) {
|
|||
canAccept: false,
|
||||
};
|
||||
|
||||
|
||||
const level = userData.level || 0;
|
||||
const protection = status === 'protected' || status === 'closed';
|
||||
|
||||
if (username) {
|
||||
if (username && status) {
|
||||
const ongoingProtect = protect.length > 0;
|
||||
const ongoingClose = close.length > 0;
|
||||
const ongoingOpen= reopen.length > 0;
|
||||
|
||||
if (userData.username === creator && !hasAcceptedAnswer) {
|
||||
permissions.canAccept = true;
|
||||
}
|
||||
|
||||
if (level >= 7 && ongoingVote.type !== 'protect') {
|
||||
if (level >= 7 && ongoingVote.type !== 'protect' && !ongoingProtect) {
|
||||
permissions.canClose = true;
|
||||
}
|
||||
|
||||
if (level >= 6 && ongoingVote.type !== 'close' && !protection) {
|
||||
if (level >= 6 && ongoingVote.type !== 'close' && !protection && !ongoingClose) {
|
||||
permissions.canProtect = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue