From 3a7204178c79a96d2e9a229f9dad9ce4c51d02e6 Mon Sep 17 00:00:00 2001
From: Noah Petherbridge
Date: Sat, 21 Sep 2024 15:48:47 -0700
Subject: [PATCH] Various fixes regarding red cameras
* When an admin has marked your camera 'red' for you, the Explicit button at the
top of the page now will require *two* clicks if the user wants to set their
camera back to blue:
On first click, they will get a red ChatClient message explaining that their
cam was most-recently marked red due to a server action (such as a moderator
flagging their cam for them). If they really mean to mark their camera blue,
they are instructed to click it a second time to confirm.
* This behavior only occurs when the most recent NSFW setting was dictated by
the server (e.g. a 'me' event disagreed with the page's local NSFW setting).
The flag is cleared any time the user themself toggles the flag, or when the
first ChatClient warning after a server event is shown.
* The explicit camera settings in the broadcast modal have been rearranged and
reworded.
* Add an 'advanced' webcam feature to automatically broadcast in the future on
page load. The option is only available in the Chat Settings 'Camera' tab
after you are already broadcasting (or rather: when a list of video devices
have become available to the page, indicating the user has possibly granted
permission already).
---
src/App.vue | 114 ++++++++++++++++++++++++++++++----------
src/lib/ChatClient.js | 12 +++++
src/lib/LocalStorage.js | 1 +
3 files changed, 99 insertions(+), 28 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 7a6cc30..1eb7451 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -202,6 +202,9 @@ export default {
audioDevices: [],
audioDeviceID: null,
+ // Advanced: automatically share your webcam when the page loads.
+ autoshare: false,
+
// After we get a device selected, remember it (by name) so that we
// might hopefully re-select it by default IF we are able to enumerate
// devices before they go on camera the first time.
@@ -484,6 +487,7 @@ export default {
// Webcam preferences that the user can edit while live.
"webcam.nsfw": function () {
+ this.webcam.wasServerNSFW = false;
LocalStorage.set('videoExplicit', this.webcam.nsfw);
if (this.webcam.active) {
this.sendMe();
@@ -528,6 +532,9 @@ export default {
"webcam.autoMuteWebcams": function () {
LocalStorage.set('autoMuteWebcams', this.webcam.autoMuteWebcams);
},
+ "webcam.autoshare": function () {
+ LocalStorage.set('videoAutoShare', this.webcam.autoshare);
+ },
// Misc preference watches
"prefs.joinMessages": function () {
@@ -709,7 +716,7 @@ export default {
if (!this.webcam.active) return 0; // unset all flags if not active now
if (this.webcam.active) status |= this.VideoFlag.Active;
if (this.webcam.muted) status |= this.VideoFlag.Muted;
- if (this.webcam.nsfw) status |= this.VideoFlag.NSFW;
+ if (this.webcam.nsfw && this.config.permitNSFW) status |= this.VideoFlag.NSFW;
if (this.webcam.mutual) status |= this.VideoFlag.MutualRequired;
if (this.webcam.mutualOpen) status |= this.VideoFlag.MutualOpen;
if (this.webcam.nonExplicit) status |= this.VideoFlag.NonExplicit;
@@ -929,10 +936,13 @@ export default {
if (settings.videoAutoMute === true) {
this.webcam.autoMute = true;
}
+ if (settings.videoAutoShare === true) {
+ this.webcam.autoshare = true;
+ }
if (settings.videoVipOnly === true) {
this.webcam.vipOnly = true;
}
- if (settings.videoExplicit === true) {
+ if (settings.videoExplicit === true && this.config.permitNSFW) {
this.webcam.nsfw = true;
}
if (settings.videoNonExplicit === true) {
@@ -1229,6 +1239,9 @@ export default {
let theirNSFW = (msg.video & this.VideoFlag.NSFW) > 0;
if (this.webcam.active && myNSFW != theirNSFW && theirNSFW) {
this.webcam.nsfw = theirNSFW;
+ window.requestAnimationFrame(() => {
+ this.webcam.wasServerNSFW = true;
+ });
}
// Note: Me events only come when we join the server or a moderator has
@@ -1571,6 +1584,7 @@ export default {
jwt: this.jwt,
prefs: this.prefs,
+ onLoggedIn: this.onLoggedIn,
onWho: this.onWho,
onMe: this.onMe,
onMessage: this.onMessage,
@@ -1613,6 +1627,14 @@ export default {
}, 1000);
});
},
+ onLoggedIn() {
+ // Called after the first 'me' is received from the chat server, e.g. once per login.
+
+ // Do we auto-broadcast our camera?
+ if (this.webcam.autoshare) {
+ this.startVideo({ force: true });
+ }
+ },
/**
* WebRTC concerns.
@@ -2132,8 +2154,8 @@ export default {
this.getDevices();
}
- // If we are running in PermitNSFW mode, show the user the modal.
- if (this.config.permitNSFW && !force) {
+ // Show the broadcast settings modal the first time.
+ if (!force) {
this.nsfwModalCast.visible = true;
return;
}
@@ -2297,6 +2319,24 @@ export default {
LocalStorage.set('preferredDeviceNames', this.webcam.preferredDeviceNames);
},
+ // The 'Explicit' button at the top of the page: toggle the user's NSFW setting but
+ // with some smarts in case the user was just marked NSFW by an admin.
+ topNavExplicitButtonClicked() {
+ if (this.webcam.wasServerNSFW) {
+ this.webcam.wasServerNSFW = false;
+ this.ChatClient(
+ `Notice: your webcam was already marked as "Explicit" recently by the chat server.
` +
+ `If you were recently notified that a chat moderator has marked your camera as 'explicit' (red) for you, then ` +
+ `you do not need to do anything: your camera is marked Explicit already. Please leave it as Explicit if you are ` +
+ `being sexual on camera.
` +
+ `If you really mean to remove the Explicit label (and turn your camera 'blue'), then click on the ` +
+ `Explicit button at the top of the page one more time to confirm.`,
+ );
+ return;
+ }
+ this.webcam.nsfw = !this.webcam.nsfw;
+ },
+
// Replace your video/audio streams for your watchers (on camera changes)
updateWebRTCStreams() {
console.log("Re-negotiating video and audio channels to your watchers.");
@@ -4037,17 +4077,18 @@ export default {
-
+
-
+
+
+
+
+
+
+
+
+
+ Note: be sure that your web browser has remembered your webcam and mic
+ permission! This option can automatically share your webcam when you log onto chat again
+ from this device.
+
+
@@ -4283,23 +4340,35 @@ export default {
-
- If your camera will be featuring "Explicit" or sexual
- content, please
- mark it as such by clicking on the "
- Explicit"
- button at the top of the page, or check the box below to start with it enabled.
+
+
-
+
+
+ You can toggle this at any time by clicking on the ' Explicit'
+ button at the top of the page.
+
+
+
+
+
+
+ Close, and don't automatically open, other peoples' cameras when they toggle
+ to become explicit.
+
-
+
@@ -4316,17 +4385,6 @@ export default {
-
-
-
- Don't auto-open explicit cameras when they open mine; and automatically
- close a camera I am watching if it toggles to become explicit.
-