import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';

@Injectable()
export class FlashService {
    private displaying = false
    constructor(@Inject(DOCUMENT) private document: Document) { }

    show(durationMs = 250) {
        if (this.displaying) return
        this.displaying = true
        this.document.getElementById('glowbox').classList.toggle('glowing');
        this.document.getElementById('glowbox').classList.toggle('not-glowing');

        setTimeout(() => {
            this.displaying = false
            this.document.getElementById('glowbox').classList.toggle('glowing');
            this.document.getElementById('glowbox').classList.toggle('not-glowing');
        }, durationMs)
    }
}