diff --git a/src/App.vue b/src/App.vue index 09f3a78..502ea0b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,8 +4,11 @@ import TheWelcome from './components/TheWelcome.vue' import LoginModal from './components/LoginModal.vue'; import ExplicitOpenModal from './components/ExplicitOpenModal.vue'; import ReportModal from './components/ReportModal.vue'; +import MessageBox from './components/MessageBox.vue'; +import WhoListRow from './components/WhoListRow.vue'; import LocalStorage from './lib/LocalStorage'; +import VideoFlag from './lib/VideoFlag'; import { SoundEffects, DefaultSounds } from './lib/sounds'; import { isAppleWebkit } from './lib/browsers'; @@ -33,6 +36,8 @@ export default { LoginModal, ExplicitOpenModal, ReportModal, + MessageBox, + WhoListRow, }, data() { return { @@ -77,14 +82,6 @@ export default { audioContext: null, audioTracks: {}, }, - reactions: [ - ['â¤ī¸', 'đ', 'đ', 'đ', 'đĸ', 'đĄ', 'đĨ°'], - ['đ', 'đ', 'âšī¸', 'đ', 'đ¤', 'đ', 'đ¤Š'], - ['đ', 'đĨ', 'đ', 'đ', 'đ', 'đĻ', 'đ'], - ['đ', 'â', 'đ', 'đ´', 'đą', 'đ', 'đ'], - ['đ¤Ž', 'đĨŗ', 'đ', 'đ¤Ļ', 'đŠ', 'đ¤¯', 'đ¯'], - ['đ', 'đ', 'đ', 'đ', 'âī¸', 'đ', 'đ'], - ], // Cached blocklist for the current user sent by your website. CachedBlocklist: CachedBlocklist, @@ -175,15 +172,7 @@ export default { }, // Video flag constants (sync with values in messages.go) - VideoFlag: { - Active: 1 << 0, - NSFW: 1 << 1, - Muted: 1 << 2, - IsTalking: 1 << 3, - MutualRequired: 1 << 4, - MutualOpen: 1 << 5, - VipOnly: 1 << 6, - }, + VideoFlag: VideoFlag, // WebRTC sessions with other users. WebRTC: { @@ -571,6 +560,63 @@ export default { result = result.reverse(); } + // Default ordering from ChatServer = a-z + return result; + }, + sortedWatchingList() { + let result = []; + for (let username of Object.keys(this.webcam.watching)) { + let user = this.getUser(username); + result.push(user); + } + + switch (this.whoSort) { + case "broadcasting": + result.sort((a, b) => { + return (b.video & this.VideoFlag.Active) - (a.video & this.VideoFlag.Active); + }); + break; + case "nsfw": + result.sort((a, b) => { + let left = (a.video & (this.VideoFlag.Active | this.VideoFlag.NSFW)), + right = (b.video & (this.VideoFlag.Active | this.VideoFlag.NSFW)); + return right - left; + }); + break; + case "status": + result.sort((a, b) => { + if (a.status === b.status) return 0; + return b.status < a.status ? -1 : 1; + }); + break; + case "op": + result.sort((a, b) => { + return b.op - a.op; + }); + break; + case "emoji": + result.sort((a, b) => { + if (a.emoji === b.emoji) return 0; + return a.emoji < b.emoji ? -1 : 1; + }) + break; + case "login": + result.sort((a, b) => { + return b.loginAt - a.loginAt; + }); + break; + case "gender": + result.sort((a, b) => { + if (a.gender === b.gender) return 0; + let left = a.gender || 'z', + right = b.gender || 'z'; + return left < right ? -1 : 1; + }) + break; + case "z-a": + result = result.reverse(); + } + // Default ordering from ChatServer = a-z return result; }, @@ -817,7 +863,6 @@ export default { // WhoList updates. onWho(msg) { this.whoList = msg.whoList; - this.whoMap = {}; if (this.whoList == undefined) { this.whoList = []; @@ -1460,6 +1505,16 @@ export default { isUsernameOnline(username) { return this.whoMap[username] != undefined; }, + getUser(username) { + // Return the full User object from the Who List, or a dummy placeholder if not online. + if (this.whoMap[username] != undefined) { + return this.whoMap[username]; + } + + return { + username: username, + }; + }, avatarForUsername(username) { if (this.whoMap[username] != undefined && this.whoMap[username].avatar) { return this.avatarURL(this.whoMap[username]); @@ -2050,6 +2105,9 @@ export default { this.closeVideo(username, "answerer"); } + // Remove them from our list. + delete(this.webcam.watching[username]); + this.ChatClient( `You have booted ${username} off your camera. They will no longer be able ` + `to connect to your camera, or even see that your camera is active at all -- ` + @@ -3428,169 +3486,25 @@ export default { -