forked from external-repos/noisedash
Fix sporadic validation, fix preferences bug
This commit is contained in:
@@ -59,6 +59,7 @@ module.exports = function () {
|
||||
} else {
|
||||
const userVersion = row.user_version
|
||||
|
||||
db.serialize(() => {
|
||||
if (userVersion < 1) {
|
||||
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
|
||||
db.run('ALTER TABLE samples ADD COLUMN loop_points_enabled INTEGER DEFAULT 0')
|
||||
@@ -85,6 +86,29 @@ module.exports = function () {
|
||||
|
||||
db.run('PRAGMA user_version = 3')
|
||||
}
|
||||
|
||||
if (userVersion < 4) {
|
||||
db.all('SELECT preferences FROM users', (err, rows) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
} else {
|
||||
rows.forEach(row => {
|
||||
if (row.preferences === '{}') {
|
||||
db.run('UPDATE users SET preferences = ?',
|
||||
['{"accentColor":{"alpha":1,"hex":"#607D8B","hexa":"#607D8BFF","hsla":{"h":200,"s":18,"l":46,"a":1},"hsva":{"h":200,"s":31,"v":55,"a":1},"hue":200,"rgba":{"r":96,"g":125,"b":139,"a":1}}}'],
|
||||
(err) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
db.run('PRAGMA user_version = 4')
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -72,6 +72,8 @@ router.post('/users', (req, res) => {
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
const defaultPreferences = '{"accentColor":{"alpha":1,"hex":"#607D8B","hexa":"#607D8BFF","hsla":{"h":200,"s":18,"l":46,"a":1},"hsva":{"h":200,"s":31,"v":55,"a":1},"hue":200,"rgba":{"r":96,"g":125,"b":139,"a":1}}}'
|
||||
|
||||
if (row.count !== 0) {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401)
|
||||
@@ -94,15 +96,16 @@ router.post('/users', (req, res) => {
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
db.run(`INSERT INTO users (username, hashed_password, salt, name, is_admin, dark_mode, can_upload)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
||||
db.run(`INSERT INTO users (username, hashed_password, salt, name, is_admin, dark_mode, can_upload, preferences)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
|
||||
req.body.username,
|
||||
hashedPassword,
|
||||
salt,
|
||||
req.body.name,
|
||||
req.body.isAdmin,
|
||||
req.body.darkMode,
|
||||
req.body.canUpload
|
||||
req.body.canUpload,
|
||||
defaultPreferences
|
||||
], (err) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
@@ -125,15 +128,16 @@ router.post('/users', (req, res) => {
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
|
||||
db.run(`INSERT INTO users (username, hashed_password, salt, name, is_admin, dark_mode, can_upload)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
||||
db.run(`INSERT INTO users (username, hashed_password, salt, name, is_admin, dark_mode, can_upload, preferences)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
|
||||
req.body.username,
|
||||
hashedPassword,
|
||||
salt,
|
||||
req.body.name,
|
||||
req.body.isAdmin,
|
||||
req.body.darkMode,
|
||||
req.body.canUpload
|
||||
req.body.canUpload,
|
||||
defaultPreferences
|
||||
], function (err) {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<v-row justify="center">
|
||||
<v-btn
|
||||
:disabled="playDisabled || !isTimerValid || !isSporadicValid"
|
||||
:disabled="playDisabled || !isTimerValid || (loadedSamples.length != 0 && !isSporadicValid)"
|
||||
class="mx-3 mb-5"
|
||||
fab
|
||||
large
|
||||
@@ -640,7 +640,7 @@
|
||||
v-if="canUpload"
|
||||
cols="12"
|
||||
>
|
||||
<h2 class="display-1 font-weight-bold mb-7">
|
||||
<h2 class="display-1 font-weight-bold mb-5">
|
||||
Samples
|
||||
</h2>
|
||||
|
||||
@@ -776,7 +776,6 @@
|
||||
</v-row>
|
||||
|
||||
<v-row
|
||||
justify="center"
|
||||
class="mb-5"
|
||||
>
|
||||
<v-radio-group
|
||||
@@ -785,11 +784,11 @@
|
||||
mandatory
|
||||
>
|
||||
<v-radio
|
||||
label="Continuous"
|
||||
label="Continuous (Looped)"
|
||||
value="continuous"
|
||||
/>
|
||||
<v-radio
|
||||
label="Sporadic"
|
||||
label="Sporadic (Not Looped, Plays Randomly Within Interval"
|
||||
value="sporadic"
|
||||
/>
|
||||
</v-radio-group>
|
||||
@@ -807,7 +806,7 @@
|
||||
label="Sporadic Min"
|
||||
class="mx-3"
|
||||
:disabled="sample.playbackMode != 'sporadic' || playDisabled"
|
||||
:rules="[validateSporadicRange(sample)]"
|
||||
:rules="[rules.gt(-1)]"
|
||||
/>
|
||||
|
||||
<v-text-field
|
||||
@@ -816,30 +815,13 @@
|
||||
label="Sporadic Max"
|
||||
class="mx-3"
|
||||
:disabled="sample.playbackMode != 'sporadic' || playDisabled"
|
||||
:rules="[validateSporadicRange(sample)]"
|
||||
:rules="[rules.gt(0)]"
|
||||
/>
|
||||
</v-row>
|
||||
</v-form>
|
||||
|
||||
<v-row
|
||||
justify="center"
|
||||
class="my-7"
|
||||
>
|
||||
<p
|
||||
v-if="sample.playbackMode != 'sporadic'"
|
||||
class="text--disabled"
|
||||
>
|
||||
(Sample will play randomly, every {{ sample.sporadicMin }} to {{ sample.sporadicMax }} seconds)
|
||||
</p>
|
||||
<p
|
||||
v-else
|
||||
>
|
||||
(Sample will play randomly, every {{ sample.sporadicMin }} to {{ sample.sporadicMax }} seconds)
|
||||
</p>
|
||||
</v-row>
|
||||
|
||||
<v-divider
|
||||
class="mb-7"
|
||||
class="mt-7"
|
||||
/>
|
||||
</v-container>
|
||||
</v-row>
|
||||
|
||||
@@ -155,11 +155,13 @@ export default {
|
||||
this.stop()
|
||||
},
|
||||
methods: {
|
||||
play () {
|
||||
async play () {
|
||||
if (!this.players.loaded) {
|
||||
return
|
||||
}
|
||||
|
||||
await Tone.start()
|
||||
|
||||
this.playDisabled = true
|
||||
Tone.Transport.cancel()
|
||||
|
||||
@@ -226,9 +228,11 @@ export default {
|
||||
|
||||
const maxInt = parseInt(s.sporadicMax, 10)
|
||||
const minInt = parseInt(s.sporadicMin, 10)
|
||||
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||
|
||||
if (minInt <= maxInt) {
|
||||
const rand = Math.floor(Math.random() * (maxInt - minInt + 1) + minInt)
|
||||
s.initialSporadicPlayInterval = setInterval(() => this.playSporadicSample(s.id), rand * 1000)
|
||||
}
|
||||
} else {
|
||||
this.players.player(s.id).loop = true
|
||||
this.players.player(s.id).unsync().sync().start(0)
|
||||
@@ -902,15 +906,6 @@ export default {
|
||||
this.selectedProfile = this.profileItems.find(p => p.text === this.activeProfile.name)
|
||||
this.updateProfile()
|
||||
this.confirmSwitchProfileDialog = false
|
||||
},
|
||||
validateSporadicRange (sample) {
|
||||
const min = parseInt(sample.sporadicMin, 10)
|
||||
const max = parseInt(sample.sporadicMax, 10)
|
||||
if (isNaN(min) || isNaN(max) || max <= min || min <= 0 || max <= 0) {
|
||||
return 'Invalid'
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user