MCPcopy Index your code
hub / github.com/spicetify/cli / componentDidMount

Method componentDidMount

Extensions/fullAppDisplay.js:608–647  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

606 }
607
608 componentDidMount() {
609 this.updateInfo = this.fetchInfo.bind(this);
610 Spicetify.Player.addEventListener("songchange", this.updateInfo);
611 this.updateInfo();
612
613 updateVisual = () => {
614 updateStyle();
615 this.fetchInfo();
616 };
617
618 this.onQueueChange = async (queueData) => {
619 const queue = queueData.data;
620 let nextTrack;
621 if (queue.queued.length) {
622 nextTrack = queue.queued[0];
623 } else {
624 nextTrack = queue.nextUp[0];
625 }
626 this.nextTrackImg.src = nextTrack.metadata.image_xlarge_url;
627 };
628
629 const scaleLimit = { min: 0.1, max: 4, step: 0.05 };
630 this.onScaleChange = (event) => {
631 if (!event.ctrlKey) return;
632 const dir = event.deltaY < 0 ? 1 : -1;
633 let temp = (CONFIG.scale || 1) + dir * scaleLimit.step;
634 if (temp < scaleLimit.min) {
635 temp = scaleLimit.min;
636 } else if (temp > scaleLimit.max) {
637 temp = scaleLimit.max;
638 }
639 CONFIG.scale = temp;
640 saveConfig();
641 updateVisual();
642 };
643
644 Spicetify.Platform.PlayerAPI._events.addListener("queue_update", this.onQueueChange);
645 this.mousetrap.bind("esc", deactivate);
646 window.dispatchEvent(new Event("fad-request"));
647 }
648
649 componentWillUnmount() {
650 Spicetify.Player.removeEventListener("songchange", this.updateInfo);

Callers

nothing calls this directly

Calls 3

fetchInfoMethod · 0.95
updateStyleFunction · 0.85
saveConfigFunction · 0.70

Tested by

no test coverage detected