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
|
||||
downvote:disabled:
|
||||
type: number
|
||||
voteVisibility:
|
||||
type: string
|
||||
feeds:disableRSS:
|
||||
type: number
|
||||
signatures:hideDuplicates:
|
||||
|
||||
@@ -9,10 +9,19 @@ define('forum/topic/votes', [
|
||||
|
||||
Votes.addVoteHandler = function () {
|
||||
_showTooltip = {};
|
||||
components.get('topic').on('mouseenter', '[data-pid] [component="post/vote-count"]', loadDataAndCreateTooltip);
|
||||
components.get('topic').on('mouseleave', '[data-pid] [component="post/vote-count"]', destroyTooltip);
|
||||
if (canSeeVotes()) {
|
||||
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() {
|
||||
const $this = $(this);
|
||||
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) {
|
||||
if (err) {
|
||||
if (err.message === '[[error:no-privileges]]') {
|
||||
return;
|
||||
}
|
||||
return alerts.error(err);
|
||||
}
|
||||
if (_showTooltip[pid] && data) {
|
||||
@@ -101,13 +107,11 @@ define('forum/topic/votes', [
|
||||
};
|
||||
|
||||
Votes.showVotes = function (pid) {
|
||||
if (!canSeeVotes()) {
|
||||
return;
|
||||
}
|
||||
api.get(`/posts/${pid}/voters`, {}, function (err, data) {
|
||||
if (err) {
|
||||
if (err.message === '[[error:no-privileges]]') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only show error if it's an unexpected error.
|
||||
return alerts.error(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ topicsController.get = async function getTopic(req, res, next) {
|
||||
topicData.topicStaleDays = meta.config.topicStaleDays;
|
||||
topicData['reputation:disabled'] = meta.config['reputation:disabled'];
|
||||
topicData['downvote:disabled'] = meta.config['downvote:disabled'];
|
||||
topicData.voteVisibility = meta.config.voteVisibility;
|
||||
topicData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
|
||||
topicData['signatures:hideDuplicates'] = meta.config['signatures:hideDuplicates'];
|
||||
topicData.bookmarkThreshold = meta.config.bookmarkThreshold;
|
||||
|
||||
Reference in New Issue
Block a user