-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #759 from thelounge/yamanickill/condense-joins
Initial part/join condensing
- Loading branch information
Showing
16 changed files
with
281 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
|
||
const constants = require("./constants"); | ||
const templates = require("../views"); | ||
|
||
module.exports = { | ||
updateText | ||
}; | ||
|
||
function updateText(condensed, addedTypes) { | ||
const obj = {}; | ||
|
||
constants.condensedTypes.forEach((type) => { | ||
obj[type] = condensed.data(type) || 0; | ||
}); | ||
|
||
addedTypes.forEach((type) => { | ||
obj[type]++; | ||
condensed.data(type, obj[type]); | ||
}); | ||
|
||
const strings = []; | ||
constants.condensedTypes.forEach((type) => { | ||
if (obj[type]) { | ||
switch (type) { | ||
case "join": | ||
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel")); | ||
break; | ||
case "part": | ||
strings.push(obj[type] + (obj[type] > 1 ? " users have left the channel" : " user has left the channel")); | ||
break; | ||
case "quit": | ||
strings.push(obj[type] + (obj[type] > 1 ? " users have quit" : " user has quit")); | ||
break; | ||
case "nick": | ||
strings.push(obj[type] + (obj[type] > 1 ? " users have changed nick" : " user has changed nick")); | ||
break; | ||
case "kick": | ||
strings.push(obj[type] + (obj[type] > 1 ? " users were kicked" : " user was kicked")); | ||
break; | ||
case "mode": | ||
strings.push(obj[type] + (obj[type] > 1 ? " modes were set" : " mode was set")); | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
let text = strings.pop(); | ||
if (strings.length) { | ||
text = strings.join(", ") + ", and " + text; | ||
} | ||
|
||
condensed.find(".condensed-text") | ||
.html(text + templates.msg_condensed_toggle()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.