import {cancel} from "../system/icons.js" import {select} from "../toolbox/selects.js" import * as loading from "../toolbox/loading.js" import {mixinStyles} from "../framework/mixin-styles.js" import {styles} from "./styles/metal-liveshow-styles.js" import {LiveshowShare, PrivilegeLevel} from "../types.js" import {LiveshowViewModel} from "../models/liveshow-model.js" import {MetalshopComponent, property, html} from "../framework/metalshop-component.js" @mixinStyles(styles) export class MetalLiveshow extends MetalshopComponent { @property({type: String, reflect: true}) ["video-label"]: string private _viewModel: LiveshowViewModel private _viewModelDispose: () => void firstUpdated(props) { super.firstUpdated(props) const {["video-label"]: label} = this const {viewModel, dispose} = this.share.makeViewModel({label}) this._viewModel = viewModel this._viewModelDispose = () => { this._viewModel = null dispose() } } disconnectedCallback() { super.disconnectedCallback() if (this._viewModelDispose) this._viewModelDispose() } render() { const {authLoad} = this.share const privilege = this._viewModel?.privilege return html` ${this.renderPrivilegeBox(privilege)} ` } private renderPrivilegeBox(privilege: PrivilegeLevel) { const {validationMessage} = this._viewModel || {} switch (privilege) { case PrivilegeLevel.Unknown: return html`

Private video

You must be logged in to view this video

${cancel}
` case PrivilegeLevel.Unprivileged: return html`

Private video

Your account does not have privilege to watch this video

${cancel}
` case PrivilegeLevel.Privileged: return html` ${this._renderViewer()}
${validationMessage && html`

${validationMessage}

`}
` } } private _handleClickUpdateLivestream = () => { const input = select( "input[name=vimeostring]", this.shadowRoot ) this._viewModel.updateVideo(input.value) input.value = "" } private _renderViewer() { const {vimeoId} = loading.payload(this._viewModel.videoLoad) || {} const query = "?color=00a651&title=0&byline=0&portrait=0&badge=0" return vimeoId ? html`
` : html`

video missing

` } }