import { Component, OnInit, Input } from '@angular/core';
import { Info, StickerEventJson } from '@ucap-webmessenger/protocol-event';
import { NGXLogger } from 'ngx-logger';
import { StickerInfo } from '../../models/sticker-info.json';

@Component({
  selector: 'ucap-chat-message-box-sticker',
  templateUrl: './sticker.component.html',
  styleUrls: ['./sticker.component.scss']
})
export class StickerComponent implements OnInit {
  @Input()
  message: Info<StickerEventJson>;

  contentJson?: StickerInfo;
  stickerUrl?: string;
  constructor(private logger: NGXLogger) {}

  ngOnInit() {
    try {
      if (!!this.message.sentMessageJson.file) {
        this.stickerUrl = `assets/sticker/sticker_s_${this.message.sentMessageJson.file}.png`;
      }
    } catch (e) {
      this.logger.error(e);
    }
  }
}
