Skip to content

Commit

Permalink
Moved mute-character modifications to frameInstance level so it doesn…
Browse files Browse the repository at this point in the history
…'t affect recordings
  • Loading branch information
adamantii committed Jun 8, 2022
1 parent dacc999 commit ff0e3d1
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions hold-it-lol/inject/vue-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function main() {

const socket = document.querySelector('.v-main__wrap > div').__vue__.$socket;
const roomInstance = document.querySelector('div.mx-auto.v-card--flat.v-sheet').parentElement.__vue__;
const toolbarInstance = document.querySelector('.mx-auto.v-card header').__vue__.$parent;
const characterInstance = document.querySelector('.v-main__wrap > div > div.row > div:nth-child(1) > div').__vue__;
const characterListInstance = document.querySelector('div.v-main__wrap > div > div.text-center').__vue__;
const userInstance = document.querySelector('.v-main__wrap > div').__vue__;
Expand Down Expand Up @@ -95,7 +96,9 @@ function main() {
let muteCharacter;
if (frameInstance.customCharacters[charId]) {
muteCharacter = muteCharacters[frameInstance.customCharacters[charId].side];
} else if (charId === null || charId < 1000) {
} else if (charId < 1000) {
muteCharacter = muteCharacters[characterListInstance.allCharacters[charId].side];
} else if (charId === null) {
muteCharacter = muteCharacters[getPresetCharacterFromPose(poseId).side];
} else {
muteCharacter = muteCharacters.fallback;
Expand Down Expand Up @@ -384,24 +387,27 @@ function main() {

if (socketStates.options['tts'] && socketStates['tts-enabled']) data.frame.frameActions.push({ "actionId": 5 });
if (socketStates.options['list-moderation'] && socketStates.options['mute-character']) {
if (data.userId in socketStates['mutedCharUsers']) {
const muteCharacter = getMuteCharacter(data.frame.characterId, data.frame.poseId);
data.frame.characterId = muteCharacter.characterId;
data.frame.poseId = muteCharacter.poseId;
}
const unwatch = frameInstance.$watch('frame', function(frame) {
if (!compareShallow(frame, data.frame, ['text', 'poseId', 'bubbleType', 'username', 'mergeNext', 'doNotTalk', 'goNext', 'poseAnimation', 'flipped', 'backgroundId', 'characterId', 'popupId'])) return;
unwatch();

if (data.userId in socketStates['mutedCharUsers']) {
const muteCharacter = getMuteCharacter(frameInstance.character.id, frame.poseId);
if (frameInstance.pairConfig?.characterId === frameInstance.character.id) frameInstance.pairConfig.characterId = muteCharacter.characterId;
else if (frameInstance.pairConfig?.characterId2 === frameInstance.character.id) frameInstance.pairConfig.characterId2 = muteCharacter.characterId;
frame.characterId = muteCharacter.characterId;
frame.poseId = muteCharacter.poseId;
}

if (Object.values(muteCharacters).map(character => character.poseId).includes(frame.pairPoseId)) return;
const pairedUser = roomInstance.pairs.find(pair => pair.userId1 === data.userId)?.userId2 || roomInstance.pairs.find(pair => pair.userId2 === data.userId)?.userId1;
if (!(pairedUser in socketStates['mutedCharUsers'])) return;

const pairIs1 = frame.characterId === frameInstance.pairConfig.characterId;
const muteCharacter = getMuteCharacter(pairIs1 ? frameInstance.pairConfig.characterId : frameInstance.pairConfig.characterId2, frame.pairPoseId);
const pairIs2 = frameInstance.character.id === frameInstance.pairConfig.characterId;
const muteCharacter = getMuteCharacter(pairIs2 ? frameInstance.pairConfig.characterId2 : frameInstance.pairConfig.characterId, frame.pairPoseId);
frameInstance.frame.pairPoseId = muteCharacter.poseId;
if (pairIs1) frameInstance.pairConfig.characterId = muteCharacter.characterId;
else frameInstance.pairConfig.characterId2 = muteCharacter.characterId;
if (pairIs2) frameInstance.pairConfig.characterId2 = muteCharacter.characterId;
else frameInstance.pairConfig.characterId = muteCharacter.characterId;
});
}
if (socketStates.options['now-playing']) {
Expand Down

0 comments on commit ff0e3d1

Please sign in to comment.