Poll plugin refinement and bug fix (4.14 and 4.15)#160
Conversation
Poll plugin refinement and bug fix targeted 4.14 and 4.15
| 'use strict'; | ||
|
|
||
| const meta = nodebb.require('./src/meta'); | ||
| const meta = require.main.require('./src/meta'); |
There was a problem hiding this comment.
nodebb.require is the future proof way, so that should be used
| { | ||
| // Option details | ||
| register: function (view) { | ||
| if (!app.user.uid) { |
There was a problem hiding this comment.
isn't this gonna break guests from viewing results if allowed in the admin page?
There was a problem hiding this comment.
The guest switch is working
-
Sockets.get (sockets.js:26-28): Returns poll data to guests if allowAnon is true.
-
View.prototype.load (view.js:191): if (!app.user.uid || self.pollData.hasVoted) → calls showResultsPanel() — guests see results.
-
results.tpl (lines 9-12): For guests ({{{ if config.loggedIn }}} → false), renders votecount as a non-clickable — guests see the vote count numbers.
-
The early return at view.js:132: Only skips registering the option details click handler (the "who voted" popup). Guests never see clickable votecount links, so there's nothing to click anyway.
-
Server-side guard: Sockets.getOptionDetails (sockets.js:148) checks if (!socket.uid || ...) and throws — so even if the handler were registered, the server would reject it.
| const translator = await app.require('translator'); | ||
| await Promise.all(details.votes.map(async (voter) => { | ||
| if (voter.displayname && voter.displayname.includes('[[')) { | ||
| voter.displayname = await translator.translate(voter.displayname); |
There was a problem hiding this comment.
I don't think we want to translate usernames
Fix for guest translate
Poll plugin refinement and bug fix targeted 4.14 and 4.15