import { Injectable } from '@angular/core'; import {AngularFireDatabase} from '@angular/fire/compat/database'; import {Session} from '../edit/session'; import {SpeechTimeService} from './speech-time.service'; @Injectable({ providedIn: 'root' }) export class SessionService { constructor(private database: AngularFireDatabase, private speechTimes: SpeechTimeService) { } public addSession(sessionNumber: string, date: string, body: string | undefined): void { if (body == null) { console.error("body should not be undefined"); return; } const sessionRef = this.database.list('sessions'); sessionRef.push({ number: +sessionNumber, date: date, body: body }); } public deleteSession(sessionKey: string | null): void { const sessionRef = this.database.list('sessions'); if (sessionKey != null) { sessionRef.remove(sessionKey); this.speechTimes.deleteSpeechTimes(sessionKey); } } }