diff --git a/api/settings.js b/api/settings.js index 5b2d2d9..4775b64 100644 --- a/api/settings.js +++ b/api/settings.js @@ -33,10 +33,18 @@ module.exports = [ if (params.has(key)) { let provided = params.get(key) + // Correct common errors in instance URL if (key === "instance") { provided = provided.replace(/\/+$/, "") } + // Delete existing watch history when it's disabled + if (key === "save_history") { + if (provided !== "1") { + db.prepare("DELETE FROM WatchedVideos WHERE token = ?").run(token) + } + } + if (setting.type === "string") { if (provided) data[key] = provided else data[key] = null