mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: dont show error alert when user user mouse overs votes
if they dont have permission to view votes
This commit is contained in:
@@ -382,6 +382,8 @@ get:
|
|||||||
type: number
|
type: number
|
||||||
downvote:disabled:
|
downvote:disabled:
|
||||||
type: number
|
type: number
|
||||||
|
voteVisibility:
|
||||||
|
type: string
|
||||||
feeds:disableRSS:
|
feeds:disableRSS:
|
||||||
type: number
|
type: number
|
||||||
signatures:hideDuplicates:
|
signatures:hideDuplicates:
|
||||||
|
|||||||
@@ -9,10 +9,19 @@ define('forum/topic/votes', [
|
|||||||
|
|
||||||
Votes.addVoteHandler = function () {
|
Votes.addVoteHandler = function () {
|
||||||
_showTooltip = {};
|
_showTooltip = {};
|
||||||
components.get('topic').on('mouseenter', '[data-pid] [component="post/vote-count"]', loadDataAndCreateTooltip);
|
if (canSeeVotes()) {
|
||||||
components.get('topic').on('mouseleave', '[data-pid] [component="post/vote-count"]', destroyTooltip);
|
components.get('topic').on('mouseenter', '[data-pid] [component="post/vote-count"]', loadDataAndCreateTooltip);
|
||||||
|
components.get('topic').on('mouseleave', '[data-pid] [component="post/vote-count"]', destroyTooltip);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function canSeeVotes() {
|
||||||
|
const { voteVisibility, privileges } = ajaxify.data;
|
||||||
|
return privileges.isAdminOrMod ||
|
||||||
|
voteVisibility === 'all' ||
|
||||||
|
(voteVisibility === 'loggedin' && config.loggedIn);
|
||||||
|
}
|
||||||
|
|
||||||
function destroyTooltip() {
|
function destroyTooltip() {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
const pid = $this.parents('[data-pid]').attr('data-pid');
|
const pid = $this.parents('[data-pid]').attr('data-pid');
|
||||||
@@ -37,9 +46,6 @@ define('forum/topic/votes', [
|
|||||||
|
|
||||||
api.get(`/posts/${pid}/upvoters`, {}, function (err, data) {
|
api.get(`/posts/${pid}/upvoters`, {}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message === '[[error:no-privileges]]') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return alerts.error(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (_showTooltip[pid] && data) {
|
if (_showTooltip[pid] && data) {
|
||||||
@@ -101,13 +107,11 @@ define('forum/topic/votes', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
Votes.showVotes = function (pid) {
|
Votes.showVotes = function (pid) {
|
||||||
|
if (!canSeeVotes()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
api.get(`/posts/${pid}/voters`, {}, function (err, data) {
|
api.get(`/posts/${pid}/voters`, {}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message === '[[error:no-privileges]]') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only show error if it's an unexpected error.
|
|
||||||
return alerts.error(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ topicsController.get = async function getTopic(req, res, next) {
|
|||||||
topicData.topicStaleDays = meta.config.topicStaleDays;
|
topicData.topicStaleDays = meta.config.topicStaleDays;
|
||||||
topicData['reputation:disabled'] = meta.config['reputation:disabled'];
|
topicData['reputation:disabled'] = meta.config['reputation:disabled'];
|
||||||
topicData['downvote:disabled'] = meta.config['downvote:disabled'];
|
topicData['downvote:disabled'] = meta.config['downvote:disabled'];
|
||||||
|
topicData.voteVisibility = meta.config.voteVisibility;
|
||||||
topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
|
topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
|
||||||
topicData['signatures:hideDuplicates'] = meta.config['signatures:hideDuplicates'];
|
topicData['signatures:hideDuplicates'] = meta.config['signatures:hideDuplicates'];
|
||||||
topicData.bookmarkThreshold = meta.config.bookmarkThreshold;
|
topicData.bookmarkThreshold = meta.config.bookmarkThreshold;
|
||||||
|
|||||||
Reference in New Issue
Block a user