Added redemptions page. Fixed some issues. Removed some instances of console.log().

This commit is contained in:
Tom
2025-01-13 23:37:31 +00:00
parent 7a7fb832a0
commit 04a50f6db0
39 changed files with 2342 additions and 1564 deletions

View File

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { DatePipe } from '@angular/common';
import { HermesSocketService } from './hermes-socket.service';
import EventService from './shared/services/EventService';
import { Observable } from 'rxjs';
import { filter, map, Observable } from 'rxjs';
export interface Message {
d: object,
@ -48,7 +48,21 @@ export class HermesClientService {
this.events.emit('tts_logoff', null);
}
public first(predicate: (data: any) => boolean): Observable<any> | null {
public filter(predicate: (data: any) => boolean): Observable<any>|undefined {
return this.socket.get$()?.pipe(
filter(predicate),
map(d => d.d)
);
}
public filterByRequestType(requestName: string): Observable<any>|undefined {
return this.socket.get$()?.pipe(
filter(d => d.op == 4 && d.d.request.type === requestName),
map(d => d.d)
);
}
public first(predicate: (data: any) => boolean): Observable<any> {
return this.socket.first(predicate);
}
@ -101,6 +115,18 @@ export class HermesClientService {
});
}
public createRedemption(twitchRedemptionId: string, actionName: string, order: number) {
if (!this.logged_in)
return;
this.send(3, {
request_id: null,
type: "create_redemption",
data: { redemption: twitchRedemptionId, action: actionName, order },
nounce: this.session_id,
});
}
public createTTSFilter(search: string, replace: string) {
if (!this.logged_in)
return;
@ -135,6 +161,18 @@ export class HermesClientService {
});
}
public deleteRedemption(id: string) {
if (!this.logged_in)
return;
this.send(3, {
request_id: null,
type: "delete_redemption",
data: { id },
nounce: this.session_id,
});
}
public deleteTTSFilter(id: string) {
if (!this.logged_in)
return;
@ -191,6 +229,17 @@ export class HermesClientService {
});
}
public fetchRedemptions() {
if (!this.logged_in)
return;
this.send(3, {
request_id: null,
type: "get_redemptions",
data: null,
});
}
public heartbeat() {
const date = new Date()
this.send(0, {
@ -240,6 +289,18 @@ export class HermesClientService {
});
}
public updateRedemption(id: string, twitchRedemptionId: string, actionName: string, order: number) {
if (!this.logged_in)
return;
this.send(3, {
request_id: null,
type: "update_redemption",
data: { id, redemption: twitchRedemptionId, action: actionName, order, state: true },
nounce: this.session_id,
});
}
public updateTTSFilter(id: string, search: string, replace: string) {
if (!this.logged_in)
return;