Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused replicants #17

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions schemas/commentators.json

This file was deleted.

12 changes: 0 additions & 12 deletions schemas/donationReader.json

This file was deleted.

33 changes: 0 additions & 33 deletions schemas/taskmasterTimestamps.json

This file was deleted.

36 changes: 28 additions & 8 deletions src/browser_shared/replicant_store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
import type { AdditionalDonations, Bids, BigbuttonPlayerMap, LowerThird, Commentators, CommentatorsNew, Countdown, CurrentRunDelay, DonationAlerts, DonationReader, DonationReaderNew, DonationTotal, DonationTotalMilestones, DonationsToRead, GameLayouts, IntermissionSlides, MusicData, ObsData, Omnibar, OtherStreamData, Prizes, ReaderIntroduction, ServerTimestamp, StreamDeckData, TtsVoices, UpcomingRunID, VideoPlayer } from '@esa-layouts/types/schemas';
import type {
AdditionalDonations,
Bids,
BigbuttonPlayerMap,
CommentatorsNew,
Countdown,
CurrentRunDelay,
DonationAlerts,
DonationReaderNew,
DonationsToRead,
DonationTotal,
DonationTotalMilestones,
GameLayouts,
IntermissionSlides,
LowerThird,
MusicData,
ObsData,
Omnibar,
OtherStreamData,
Prizes,
ReaderIntroduction,
ServerTimestamp,
StreamDeckData,
TtsVoices,
UpcomingRunID,
VideoPlayer,
} from '@esa-layouts/types/schemas';
import type NodeCGTypes from '@nodecg/types';
import clone from 'clone';
import { SpeedcontrolUtilBrowser } from 'speedcontrol-util';
Expand All @@ -7,7 +33,7 @@ import { RunDataActiveRunSurrounding } from 'speedcontrol-util/types/schemas';
import Vue from 'vue';
import type { Store } from 'vuex';
import { namespace } from 'vuex-class';
import { Module, Mutation, VuexModule, getModule } from 'vuex-module-decorators';
import { getModule, Module, Mutation, VuexModule } from 'vuex-module-decorators';

const sc = new SpeedcontrolUtilBrowser(nodecg);

Expand All @@ -19,12 +45,10 @@ export const reps: {
assetsReaderIntroductionImages: NodeCGTypes.ClientReplicant<NodeCGTypes.AssetFile[]>;
bids: NodeCGTypes.ClientReplicant<Bids>;
bigbuttonPlayerMap: NodeCGTypes.ClientReplicant<BigbuttonPlayerMap>;
commentators: NodeCGTypes.ClientReplicant<Commentators>;
commentatorsNew: NodeCGTypes.ClientReplicant<CommentatorsNew>;
countdown: NodeCGTypes.ClientReplicant<Countdown>;
currentRunDelay: NodeCGTypes.ClientReplicant<CurrentRunDelay>;
donationAlerts: NodeCGTypes.ClientReplicant<DonationAlerts>;
donationReader: NodeCGTypes.ClientReplicant<DonationReader>;
donationReaderNew: NodeCGTypes.ClientReplicant<DonationReaderNew>;
donationsToRead: NodeCGTypes.ClientReplicant<DonationsToRead>;
donationTotal: NodeCGTypes.ClientReplicant<DonationTotal>;
Expand Down Expand Up @@ -55,12 +79,10 @@ export const reps: {
assetsReaderIntroductionImages: nodecg.Replicant('assets:reader-introduction-images'),
bids: nodecg.Replicant('bids'),
bigbuttonPlayerMap: nodecg.Replicant('bigbuttonPlayerMap'),
commentators: nodecg.Replicant('commentators'),
commentatorsNew: nodecg.Replicant('commentatorsNew'),
countdown: nodecg.Replicant('countdown'),
currentRunDelay: nodecg.Replicant('currentRunDelay'),
donationAlerts: nodecg.Replicant('donationAlerts'),
donationReader: nodecg.Replicant('donationReader'),
donationReaderNew: nodecg.Replicant('donationReaderNew'),
donationsToRead: nodecg.Replicant('donationsToRead'),
donationTotal: nodecg.Replicant('donationTotal'),
Expand Down Expand Up @@ -93,12 +115,10 @@ export interface ReplicantTypes {
assetsReaderIntroductionImages: NodeCGTypes.AssetFile[];
bids: Bids;
bigbuttonPlayerMap: BigbuttonPlayerMap;
commentators: Commentators;
commentatorsNew: CommentatorsNew;
countdown: Countdown;
currentRunDelay: CurrentRunDelay;
donationAlerts: DonationAlerts;
donationReader: DonationReader;
donationReaderNew: DonationReaderNew;
donationsToRead: DonationsToRead;
donationTotal: DonationTotal;
Expand Down
5 changes: 1 addition & 4 deletions src/dashboard/commentators/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { replicantModule, ReplicantModule, ReplicantTypes } from '@esa-layouts/browser_shared/replicant_store';
import { Commentators, CommentatorsNew } from '@esa-layouts/types/schemas';
import { CommentatorsNew } from '@esa-layouts/types/schemas';
import Vue from 'vue';
import Vuex, { Store } from 'vuex';
import { getModule, Module, Mutation, VuexModule } from 'vuex-module-decorators';
Expand All @@ -18,9 +18,6 @@ class OurModule extends VuexModule {
replicantModule.setReplicant<CommentatorsNew>({
name: 'commentatorsNew', val: [],
});
replicantModule.setReplicant<Commentators>({
name: 'commentators', val: [],
});
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/extension/flagcarrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { lookupUserByID, lookupUsersByStr } from './server';
import { logError } from './util/helpers';
import { get as nodecg } from './util/nodecg';
import { mq } from './util/rabbitmq';
import { bigbuttonPlayerMap, donationReader } from './util/replicants';
import { bigbuttonPlayerMap } from './util/replicants';
import { sc } from './util/speedcontrol';

const router = nodecg().Router();
Expand Down Expand Up @@ -259,7 +259,6 @@ function setup(): void {
// Unfortunately currently flagcarrier's "clear" command is for an entire group,
// but because we only serve donation reader here, we're OK.
if (action.endsWith('clear')) {
donationReader.value = null;
nodecg().log.info('[FlagCarrier] Donation reader was cleared (DeviceID: %s)', device);
// If not also a login command, will respond with this message.
if (action !== 'login_clear') {
Expand Down
35 changes: 2 additions & 33 deletions src/extension/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import { get as nodecg } from './util/nodecg';
import obs from './util/obs';
import { mq } from './util/rabbitmq';
import {
additionalDonations, bigbuttonPlayerMap,
commentators,
additionalDonations,
bigbuttonPlayerMap,
commentatorsNew,
lowerThird,
donationReader,
donationReaderNew,
donationTotal,
horaroImportStatus,
Expand Down Expand Up @@ -76,7 +75,6 @@ sc.runDataActiveRun.on('change', (newVal, oldVal) => {
// imported from an external schedule. This stops manually added runs (like bonus runs)
// having things erased.
if (sc.runDataActiveRun.value && newVal && newVal.scheduled) {
if (config.event.shorts !== 'swcf') commentators.value.length = 0;
// If not online and flagcarrier is enabled,
// we also clear the teams and big button player map.
if (!config.event.online && config.flagcarrier.enabled) {
Expand Down Expand Up @@ -249,33 +247,10 @@ async function searchName(val: string, currentVal: CommentatorsNew): Promise<voi
}
}

async function searchNameOld(val: string, currentVal: string[]): Promise<void> {
if (config.server.enabled) {
const res = await searchPronounsOnEsByStr(val);

if (res && !currentVal.includes(res.name)) {
currentVal.push(res.name);
}
} else if (config.useOengusInsteadOfSrdc) {
const res = await searchOengusPronouns(val);

if (res && !currentVal.includes(res.name)) {
currentVal.push(res.name);
}
} else {
const res = await searchSrcomPronouns(val);

if (res && !currentVal.includes(res.name)) {
currentVal.push(res.name);
}
}
}

// Processes adding commentators from the dashboard panel.
nodecg().listenFor('commentatorAdd', async (val: string | null | undefined, ack) => {
if (val) {
await searchName(val, commentatorsNew.value);
await searchNameOld(val, commentators.value);
}

if (ack && !ack.handled) {
Expand All @@ -295,7 +270,6 @@ nodecg().listenFor('lower-third:add-name', (val: string | null | undefined, ack)

nodecg().listenFor('commentatorRemove', (val: number, ack) => {
commentatorsNew.value.splice(val, 1);
commentators.value.splice(val, 1);
if (ack && !ack.handled) {
ack(null);
}
Expand All @@ -306,17 +280,12 @@ nodecg().listenFor('readerModify', async (val: string | null | undefined, ack) =
// TODO: pronouns from ESA server.
if (!val) {
donationReaderNew.value = null;
donationReader.value = null;
} else if (config.useOengusInsteadOfSrdc) {
donationReaderNew.value = await searchOengusPronouns(val);
} else {
donationReaderNew.value = await searchSrcomPronouns(val);
}

if (donationReaderNew.value) {
donationReader.value = objToSimpleDisplay(donationReaderNew.value);
}

if (ack && !ack.handled) {
ack(null);
}
Expand Down
15 changes: 1 addition & 14 deletions src/extension/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as mqLogging from './util/mq-logging';
import { get as nodecg } from './util/nodecg';
import obs from './util/obs';
import { mq } from './util/rabbitmq';
import { bigbuttonPlayerMap, currentRunDelay, delayedTimer, taskmasterTimestamps } from './util/replicants';
import { bigbuttonPlayerMap, currentRunDelay, delayedTimer } from './util/replicants';
import { sc } from './util/speedcontrol';

const config = nodecg().bundleConfig;
Expand Down Expand Up @@ -65,19 +65,6 @@ mq.evt.on('bigbuttonPressed', async (data) => {
}

const run = sc.getCurrentRun();

// Hardcoded different timer for Taskmaster.
if (run?.game?.toLowerCase() === 'taskmaster') {
if (taskmasterTimestamps.value.start === null) { // Start
taskmasterTimestamps.value.start = Date.now();
} else if (taskmasterTimestamps.value.end === null) { // End
taskmasterTimestamps.value.end = Date.now();
} else {
taskmasterTimestamps.value = { start: null, end: null }; // Reset
}
return;
}

let id = 0;

// If more than 1 team, uses the big button player mapping to find out what team to stop.
Expand Down
8 changes: 2 additions & 6 deletions src/extension/util/replicants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import {
AdditionalDonations, Bids,
BigbuttonPlayerMap,
CapturePositions,
Commentators,
CommentatorsNew, Countdown,
CurrentRunDelay,
DelayedTimer,
DonationAlerts, DonationReader,
DonationAlerts,
DonationReaderNew, DonationsToRead,
DonationTotal,
DonationTotalMilestones,
Expand All @@ -25,7 +24,7 @@ import {
ReaderIntroduction,
ServerTimestamp,
StreamDeckData,
TaskmasterTimestamps, TtsVoices,
TtsVoices,
UpcomingRunID,
VideoPlayer,
} from '@esa-layouts/types/schemas';
Expand All @@ -46,13 +45,11 @@ export const assetsVideos = nodecg().Replicant<NodeCGTypes.AssetFile[]>('assets:
export const bids = nodecg().Replicant<Bids>('bids', { persistent: false }) as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<Bids>;
export const bigbuttonPlayerMap = nodecg().Replicant<BigbuttonPlayerMap>('bigbuttonPlayerMap') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<BigbuttonPlayerMap>;
export const capturePositions = nodecg().Replicant<CapturePositions>('capturePositions') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<CapturePositions>;
export const commentators = nodecg().Replicant<Commentators>('commentators') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<Commentators>;
export const commentatorsNew = nodecg().Replicant<CommentatorsNew>('commentatorsNew') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<CommentatorsNew>;
export const countdown = nodecg().Replicant<Countdown>('countdown') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<Countdown>;
export const currentRunDelay = nodecg().Replicant<CurrentRunDelay>('currentRunDelay') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<CurrentRunDelay>;
export const delayedTimer = nodecg().Replicant<DelayedTimer>('delayedTimer') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DelayedTimer>;
export const donationAlerts = nodecg().Replicant<DonationAlerts>('donationAlerts') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DonationAlerts>;
export const donationReader = nodecg().Replicant<DonationReader>('donationReader') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DonationReader>;
export const donationReaderNew = nodecg().Replicant<DonationReaderNew>('donationReaderNew') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DonationReaderNew>;
export const donationsToRead = nodecg().Replicant<DonationsToRead>('donationsToRead', { persistent: false }) as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DonationsToRead>;
export const donationTotal = nodecg().Replicant<DonationTotal>('donationTotal') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<DonationTotal>;
Expand All @@ -72,7 +69,6 @@ export const prizes = nodecg().Replicant<Prizes>('prizes', { persistent: false }
export const readerIntroduction = nodecg().Replicant<ReaderIntroduction>('readerIntroduction') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<ReaderIntroduction>;
export const serverTimestamp = nodecg().Replicant<ServerTimestamp>('serverTimestamp') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<ServerTimestamp>;
export const streamDeckData = nodecg().Replicant<StreamDeckData>('streamDeckData') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<StreamDeckData>;
export const taskmasterTimestamps = nodecg().Replicant<TaskmasterTimestamps>('taskmasterTimestamps') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<TaskmasterTimestamps>;
export const ttsVoices = nodecg().Replicant<TtsVoices>('ttsVoices') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<TtsVoices>;
export const twitchAPIData = nodecg().Replicant<TwitchAPIData>('twitchAPIData', 'nodecg-speedcontrol') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<TwitchAPIData>;
export const twitchChannelInfo = nodecg().Replicant<TwitchChannelInfo>('twitchChannelInfo', 'nodecg-speedcontrol') as unknown as NodeCGTypes.ServerReplicantWithSchemaDefault<TwitchChannelInfo>;
Expand Down
5 changes: 4 additions & 1 deletion src/graphics/game-layout/4x3-4p.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
height: '308px',
}"
>
<comm-and-reader />
<commentators-reader />
<commentators-reader show-reader />

<!-- Run Game Info/Timer -->
<div
Expand Down Expand Up @@ -156,9 +157,11 @@ import CommAndReader from './components/CommAndReader.vue';
import RunInfo from './components/RunInfo.vue';
import Timer from './components/Timer.vue';
import DonationBar from './components/DonationBar.vue';
import CommentatorsReader from '@esa-layouts/game-layout/components/CommentatorsReader.vue';

@Component({
components: {
CommentatorsReader,
GameCapture,
Player,
CommAndReader,
Expand Down
Loading