Moving settings to be user specific, adding playbackRate setting, update playbackRate picker to go up to 3x

This commit is contained in:
Mark Cooper 2021-08-23 18:31:04 -05:00
parent 2548aba840
commit f83c5dd440
22 changed files with 247 additions and 103 deletions

View file

@ -1,5 +1,6 @@
const express = require('express')
const Logger = require('./Logger')
const { isObject } = require('./utils/index')
class ApiController {
constructor(db, scanner, auth, streamManager, rssFeeds, emitter) {
@ -32,6 +33,7 @@ class ApiController {
this.router.get('/users', this.getUsers.bind(this))
this.router.delete('/user/audiobook/:id', this.resetUserAudiobookProgress.bind(this))
this.router.patch('/user/password', this.userChangePassword.bind(this))
this.router.patch('/user/settings', this.userUpdateSettings.bind(this))
this.router.post('/authorize', this.authorize.bind(this))
@ -185,6 +187,21 @@ class ApiController {
res.json(feed)
}
async userUpdateSettings(req, res) {
var settingsUpdate = req.body
if (!settingsUpdate || !isObject(settingsUpdate)) {
return res.sendStatus(500)
}
var madeUpdates = req.user.updateSettings(settingsUpdate)
if (madeUpdates) {
await this.db.updateEntity('user', req.user)
}
return res.json({
success: true,
settings: req.user.settings
})
}
getGenres(req, res) {
res.json({
genres: this.db.getGenres()