Exemplo n.º 1
0
 handleAddPath = (dir) => {
   api('POST', `/?dir=${encodeURIComponent(dir)}`)
     .then(res => {
       this.props.receivePrefs(res)
       this.setState({ isChoosing: false })
     }).catch(err => {
       alert(err)
     })
 }
Exemplo n.º 2
0
  handleRemovePath = (pathId) => {
    const { path } = this.props.paths.entities[pathId]

    if (!confirm(`Remove folder from library?\n\n${path}`)) {
      return
    }

    api('DELETE', `/${pathId}`)
      .then(res => {
        this.props.receivePrefs(res)
      }).catch(err => {
        alert(err)
      })
  }
Exemplo n.º 3
0
  return (dispatch, getState) => {
    // informational
    dispatch({
      type: PREFS_REQUEST_SCAN,
    })

    return api('GET', `/scan`)
      .catch(err => {
        dispatch({
          type: PREFS_REQUEST_SCAN + '_ERROR',
          error: err.message,
        })
      })
  }
Exemplo n.º 4
0
  return (dispatch, getState) => {
    // informational
    dispatch({
      type: PREFS_SET,
      payload: { domain, data },
    })

    return api('PUT', `?domain=${encodeURIComponent(domain)}`, {
      body: data
    })
      .then(prefs => {
        dispatch(receivePrefs(prefs))
      })
      .catch(err => {
        dispatch({
          type: PREFS_SET + _ERROR,
          error: err.message,
        })
      })
  }
Exemplo n.º 5
0
  return (dispatch, getState) => {
    // informational
    dispatch({
      type: PREFS_REQUEST,
    })

    return api('GET', '')
      .then(prefs => {
        dispatch(receivePrefs(prefs))

        // sign out if we see isFirstRun flag
        if (prefs.isFirstRun && getState().user.userId !== null) {
          dispatch(logout())
        }
      })
      .catch(err => {
        dispatch({
          type: PREFS_REQUEST + _ERROR,
          error: err.message,
        })
      })
  }