Skip to content

Commit

Permalink
Re-enable notable donations
Browse files Browse the repository at this point in the history
  • Loading branch information
zoton2 committed Feb 19, 2024
1 parent f2cc900 commit 1842491
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
13 changes: 10 additions & 3 deletions src/extension/omnibar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,18 @@ mq.evt.on('newScreenedCheer', (data) => {
const overriddenTypes = data as unknown as never;
omnibar.value.miniCredits.runCheers.push(clone(overriddenTypes));
});
// DISABLED FOR NOW (ESAW24).
/* mq.evt.on('donationFullyProcessed', (data) => {
mq.evt.on('donationFullyProcessedStream', (data) => {
const overriddenTypes = data as unknown as never;
omnibar.value.miniCredits.runDonations.push(clone(overriddenTypes));
}); */
});
// Fully processed donations for donations targeted towards the main campaign.
// We only listen for this on stream 1.
if (config.event.thisEvent === 1) {
mq.evt.on('donationFullyProcessedTeam', (data) => {
const overriddenTypes = data as unknown as never;
omnibar.value.miniCredits.runDonations.push(clone(overriddenTypes));
});
}

// Pushes our "mini credits" to the alert queue.
sc.on('timerStopped', () => {
Expand Down
25 changes: 10 additions & 15 deletions src/extension/tracker/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Configschema } from '@esa-layouts/types/schemas';
import type { Tracker } from '@shared/types';
import clone from 'clone';
import { round } from 'lodash';
import type { NeedleResponse } from 'needle';
import needle from 'needle';
import type { DeepWritable } from 'ts-essentials';
import { get as nodecg } from '../util/nodecg';
import { mq } from '../util/rabbitmq';
import { donationTotal } from '../util/replicants';
import { donationTotal, notableDonations } from '../util/replicants';

export const eventInfo: Tracker.EventInfo[] = [];
const eventConfig = nodecg().bundleConfig.event;
Expand Down Expand Up @@ -141,6 +142,10 @@ mq.evt.on('donationFullyProcessedStream', (data) => {
seenDonationIds.push(id);
nodecg().log.debug('[Tracker] Received new donation with ID %s', id);
nodecg().sendMessage('newDonation', { amount: data.amount });
if (data.amount >= 20) { // Notable donations are over $20
notableDonations.value.unshift(clone(data));
notableDonations.value.length = Math.min(notableDonations.value.length, 20);
}
}
});
// Fully processed donations for donations targeted towards the main campaign.
Expand All @@ -153,6 +158,10 @@ if (eventConfig.thisEvent === 1) {
seenDonationIds.push(id);
nodecg().log.debug('[Tracker] Received new donation with ID %s', id);
nodecg().sendMessage('newDonation', { amount: data.amount });
if (data.amount >= 20) { // Notable donations are over $20
notableDonations.value.unshift(clone(data));
notableDonations.value.length = Math.min(notableDonations.value.length, 20);
}
}
});
}
Expand All @@ -162,20 +171,6 @@ nodecg().listenFor('donationAlertsLogging', (msg) => {
nodecg().log.debug('[Tracker] %s', msg);
});

// DISABLED FOR NOW (ESAW24)
// Triggered when a new donation is fully processed on the tracker.
/* mq.evt.on('donationFullyProcessed', (data) => {
if (data.comment_state === 'APPROVED') {
// eslint-disable-next-line no-underscore-dangle
nodecg().log.debug('[Tracker] Received new donation with ID %s', data._id);
nodecg().sendMessage('newDonation', data);
if (data.amount >= 20) { // Notable donations are over $20
notableDonations.value.unshift(clone(data));
notableDonations.value.length = Math.min(notableDonations.value.length, 20);
}
}
}); */

let isFirstLogin = true;
async function loginToTracker(): Promise<void> {
if (isFirstLogin) nodecg().log.info('[Tracker] Logging in');
Expand Down

0 comments on commit 1842491

Please sign in to comment.