Skip to content

Commit

Permalink
fix: speed toggle on/off on extension init (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani authored Aug 29, 2023
1 parent feb891c commit dd578f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions actions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ async function load() {
await store.populate()

const app = new App({ video, store })
const enabled = sessionStorage.getItem('enabled') == 'true'
video.active = enabled

document.addEventListener('app.enabled', async e => {
const { enabled } = e.detail

sessionStorage.setItem('enabled', enabled)
video.active = enabled

enabled ? await app.connect() : app.disconnect()
})
}
9 changes: 6 additions & 3 deletions models/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ import { currentData } from '../data/current.js'

export default class VideoElement {
#video
#active = false
#active = sessionStorage.getItem('enabled') == 'true'

constructor(video) {
this.#video = video
this.#listenForTrackChange()
this.#setPlaybackRateProtection()
}

set active(value) {
this.#active = value
}

async activate() {
this.#active = true
await this.#handleTrackChange()
}

reset() {
this.#active = false
this.clearCurrentSpeed()
this.playbackRate = 1
this.preservesPitch = true
}

Expand Down

0 comments on commit dd578f8

Please sign in to comment.