Add setting that ignores follow invites

This commit is contained in:
PizZaKatZe 2021-12-15 19:47:14 +01:00
parent e3e7fba539
commit d3297a448e
3 changed files with 28 additions and 6 deletions

View File

@ -8,6 +8,7 @@
let fullscreen: boolean = localUserStore.getFullscreen();
let notification: boolean = localUserStore.getNotification() === "granted";
let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger();
let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests();
let valueGame: number = localUserStore.getGameQualityValue();
let valueVideo: number = localUserStore.getVideoQualityValue();
let previewValueGame = valueGame;
@ -59,6 +60,10 @@
localUserStore.setForceCowebsiteTrigger(forceCowebsiteTrigger);
}
function changeIgnoreFollowRequests() {
localUserStore.setIgnoreFollowRequests(ignoreFollowRequests);
}
function closeMenu() {
menuVisiblilityStore.set(false);
}
@ -123,6 +128,15 @@
/>
<span>Always ask before opening websites and Jitsi Meet rooms</span>
</label>
<label>
<input
type="checkbox"
class="nes-checkbox is-dark"
bind:checked={ignoreFollowRequests}
on:change={changeIgnoreFollowRequests}
/>
<span>Ignore requests to follow other users</span>
</label>
</section>
</div>

View File

@ -14,6 +14,7 @@ const audioPlayerMuteKey = "audioMute";
const helpCameraSettingsShown = "helpCameraSettingsShown";
const fullscreenKey = "fullscreen";
const forceCowebsiteTriggerKey = "forceCowebsiteTrigger";
const ignoreFollowRequests = "ignoreFollowRequests";
const lastRoomUrl = "lastRoomUrl";
const authToken = "authToken";
const state = "state";
@ -128,6 +129,13 @@ class LocalUserStore {
return localStorage.getItem(forceCowebsiteTriggerKey) === "true";
}
setIgnoreFollowRequests(value: boolean): void {
localStorage.setItem(ignoreFollowRequests, value.toString());
}
getIgnoreFollowRequests(): boolean {
return localStorage.getItem(ignoreFollowRequests) === "true";
}
setLastRoomUrl(roomUrl: string): void {
localStorage.setItem(lastRoomUrl, roomUrl.toString());
if ("caches" in window) {

View File

@ -63,6 +63,7 @@ import { emoteEventStream } from "./EmoteEventStream";
import { get } from "svelte/store";
import { warningContainerStore } from "../Stores/MenuStore";
import { followStateStore, followRoleStore, followUsersStore, followRoles, followStates } from "../Stores/FollowStore";
import { localUserStore } from "./LocalUserStore";
const manualPingDelay = 20000;
@ -264,17 +265,16 @@ export class RoomConnection implements RoomConnection {
//todo: implement a way to notify the user the room was refreshed.
} else if (message.hasFollowrequestmessage()) {
const requestMessage = message.getFollowrequestmessage() as FollowRequestMessage;
console.log("Got follow request from " + requestMessage.getLeader());
followStateStore.set(followStates.requesting);
followRoleStore.set(followRoles.follower);
followUsersStore.set([requestMessage.getLeader()]);
if (!localUserStore.getIgnoreFollowRequests()) {
followStateStore.set(followStates.requesting);
followRoleStore.set(followRoles.follower);
followUsersStore.set([requestMessage.getLeader()]);
}
} else if (message.hasFollowconfirmationmessage()) {
const responseMessage = message.getFollowconfirmationmessage() as FollowConfirmationMessage;
console.log("Got follow response from " + responseMessage.getFollower());
followUsersStore.set([...get(followUsersStore), responseMessage.getFollower()]);
} else if (message.hasFollowabortmessage()) {
const abortMessage = message.getFollowabortmessage() as FollowAbortMessage;
console.log("Got follow abort message");
if (get(followRoleStore) === followRoles.follower) {
followStateStore.set(followStates.off);
followRoleStore.set(followRoles.leader);