Skip to content

Commit

Permalink
Merge pull request #192 from cabal-club/hidden-users
Browse files Browse the repository at this point in the history
Sort hidden users to bottom of user pane, prefix their names with minus sign
cblgh authored Jun 10, 2020

Unverified

This user has not yet uploaded their public signing key.
2 parents a5c76ff + 6a5074c commit 30332e9
Showing 5 changed files with 108 additions and 22 deletions.
20 changes: 18 additions & 2 deletions neat-screen.js
Original file line number Diff line number Diff line change
@@ -506,9 +506,9 @@ NeatScreen.prototype.formatMessage = function (msg) {

var timestamp = `${chalk.dim(formatTime(msg.value.timestamp, this.config.messageTimeformat))}`
let authorText
if (msg.value.type === 'status') {
if (msg.value.type === 'status' || msg.value.type === 'chat/moderation') {
highlight = false // never highlight from status
authorText = `${chalk.dim('-')}${highlight ? chalk.whiteBright(author) : chalk.cyan('status')}${chalk.dim('-')}`
authorText = `${chalk.dim('-')}${chalk.cyan('status')}${chalk.dim('-')}`
} else {
/* a user wrote a message, not the !status virtual message */

@@ -531,6 +531,22 @@ NeatScreen.prototype.formatMessage = function (msg) {

if (msg.value.type === 'chat/topic') {
content = `${chalk.dim(`* sets the topic to ${chalk.cyan(msgtxt)}`)}`
} else if (msg.value.type === 'chat/moderation') {
const { role, type, issuerid, receiverid } = msg.value.content
const issuer = this.client.getUsers()[issuerid]
const receiver = this.client.getUsers()[receiverid]
let text, action
const reason = msg.value.content.reason ? `(${chalk.cyan('reason:')} ${msg.value.content.reason})` : ''
const issuerName = issuer && issuer.name ? issuer.name : issuerid.slice(0, 8)
const receiverName = receiver && receiver.name ? receiver.name : receiverid.slice(0, 8)
if (['admin', 'mod'].includes(role)) { action = (type === 'add' ? 'added' : 'removed') }
if (role === 'hide') { action = (type === 'add' ? 'hid' : 'unhid') }
if (role === 'hide') {
text = `${issuerName} ${chalk.cyan(action)} ${receiverName} ${reason}`
} else {
text = `${issuerName} ${chalk.cyan(action)} ${receiverName} as ${chalk.cyan(role)} ${reason}`
}
content = `${chalk.magenta('moderation')}: ${text}`
}

return {
105 changes: 86 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
},
"dependencies": {
"ansi-escapes": "^4.3.1",
"cabal-client": "^6.0.0",
"cabal-client": "^6.1.0",
"chalk": "^4.0.0",
"js-yaml": "^3.13.1",
"minimist": "^1.2.5",
2 changes: 2 additions & 0 deletions util.js
Original file line number Diff line number Diff line change
@@ -139,6 +139,8 @@ function wrapStatusMsg (m) {
}

function cmpUser (a, b) {
if (!a.isHidden() && b.isHidden()) return -1
if (!b.isHidden() && a.isHidden()) return 1
if (a.online && !b.online) return -1
if (b.online && !a.online) return 1
if (a.isAdmin() && !b.isAdmin()) return -1
1 change: 1 addition & 0 deletions views.js
Original file line number Diff line number Diff line change
@@ -147,6 +147,7 @@ function renderNicks (state, width, height) {
if (user.online) onlines[name] = name in onlines ? onlines[name] + 1 : 1
if (user.isAdmin()) name = chalk.green('@') + name
else if (user.isModerator()) name = chalk.green('%') + name
else if (user.isHidden()) name = chalk.green('-') + name
if (user.online) {
name = chalk.bold(name)
}

0 comments on commit 30332e9

Please sign in to comment.