Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort hidden users to bottom of user pane, prefix their names with minus sign #192

Merged
merged 6 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions neat-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 {
Expand Down
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
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions views.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down