load() {
    const serializedData = localStorage.getItem("cm_fireworks_data")
    if (serializedData) {
      const { schemaVersion, data } = JSON.parse(serializedData)

      const config = this.state.config
      switch (schemaVersion) {
        case "1.1":
          config.quality = data.quality
          config.size = data.size
          config.skyLighting = data.skyLighting
          config.hideControls = data.hideControls
          break
        default:
          console.error(
            "Version switch should be exhaustive. Falling back to default settings."
          )
      }
    }
    // Deprecated data format. Apply carefully (it's not namespaced).
    else if (localStorage.getItem("schemaVersion") === "1") {
      let size, hideControls
      // Attempt to parse data, ignoring if there is an error.
      try {
        const sizeRaw = localStorage.getItem("configSize")
        const hideControlsRaw = localStorage.getItem("hideControls")
        size = typeof sizeRaw === "string" && JSON.parse(sizeRaw)
        hideControls =
          typeof hideControlsRaw === "string" && JSON.parse(hideControlsRaw)
      } catch (e) {
        console.error(e)
        return
      }
      // Only restore validated values
      const sizeInt = parseInt(size, 10)
      if (sizeInt >= 0 && sizeInt <= 4) {
        this.state.config.size = String(sizeInt)
      }
      if (typeof hideControls == "boolean") {
        this.state.config.hideControls = hideControls
      }
    }
  }
// Mutates state because `store.load()` should only be called once immediately after store is created, before any subscriptions.
Mutates state because `store.load()` should only be called once immediately after store is created, before any subscriptions.
Mutates state because ` store . load () ` should only be called once immediately after store is created before any subscriptions .
load() {
    const serializedData = localStorage.getItem("cm_fireworks_data")
    if (serializedData) {
      const { schemaVersion, data } = JSON.parse(serializedData)
      const config = this.state.config
      switch (schemaVersion) {
        case "1.1":
          config.quality = data.quality
          config.size = data.size
          config.skyLighting = data.skyLighting
          config.hideControls = data.hideControls
          break
        default:
          console.error(
            "Version switch should be exhaustive. Falling back to default settings."
          )
      }
    }
    else if (localStorage.getItem("schemaVersion") === "1") {
      let size, hideControls
      try {
        const sizeRaw = localStorage.getItem("configSize")
        const hideControlsRaw = localStorage.getItem("hideControls")
        size = typeof sizeRaw === "string" && JSON.parse(sizeRaw)
        hideControls =
          typeof hideControlsRaw === "string" && JSON.parse(hideControlsRaw)
      } catch (e) {
        console.error(e)
        return
      }
      const sizeInt = parseInt(size, 10)
      if (sizeInt >= 0 && sizeInt <= 4) {
        this.state.config.size = String(sizeInt)
      }
      if (typeof hideControls == "boolean") {
        this.state.config.hideControls = hideControls
      }
    }
  }
load ( ) { const serializedData = localStorage . getItem ( "cm_fireworks_data" ) if ( serializedData ) { const { schemaVersion , data } = JSON . parse ( serializedData ) const config = this . state . config switch ( schemaVersion ) { case "1.1" : config . quality = data . quality config . size = data . size config . skyLighting = data . skyLighting config . hideControls = data . hideControls break default : console . error ( "Version switch should be exhaustive. Falling back to default settings." ) } } else if ( localStorage . getItem ( "schemaVersion" ) === "1" ) { let size , hideControls try { const sizeRaw = localStorage . getItem ( "configSize" ) const hideControlsRaw = localStorage . getItem ( "hideControls" ) size = typeof sizeRaw === "string" && JSON . parse ( sizeRaw ) hideControls = typeof hideControlsRaw === "string" && JSON . parse ( hideControlsRaw ) } catch ( e ) { console . error ( e ) return } const sizeInt = parseInt ( size , 10 ) if ( sizeInt >= 0 && sizeInt <= 4 ) { this . state . config . size = String ( sizeInt ) } if ( typeof hideControls == "boolean" ) { this . state . config . hideControls = hideControls } } }
Mutates state because `store.load()` should only be called once immediately after store is created, before any subscriptions.
Mutates state because ` store . load () ` should only be called once immediately after store is created before any subscriptions .
// Deprecated data format. Apply carefully (it's not namespaced). // Attempt to parse data, ignoring if there is an error. // Only restore validated values