From 426766225b8e46e4da2dd60f470f3bf87b1c2027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Malak?= Date: Thu, 18 Nov 2021 13:05:32 +0100 Subject: [PATCH] Fixed bug with custom icons not working with apps --- CHANGELOG.md | 3 +++ README.md | 2 +- controllers/apps/createApp.js | 21 ++++++++------------- controllers/apps/updateApp.js | 10 +++++----- controllers/bookmarks/createBookmark.js | 10 +++++----- controllers/bookmarks/updateBookmark.js | 10 +++++----- controllers/categories/createCategory.js | 14 ++++---------- 7 files changed, 31 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b755d2..9f66a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v2.0.1 (TBA) +- Fixed bug with custom icons not working with apps when "pin by default" was disabled + ### v2.0.0 (2021-11-15) - Added authentication system: - Only logged in user can access settings ([#33](https://github.com/pawelmalak/flame/issues/33)) diff --git a/README.md b/README.md index 6995444..a53474e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Flame is self-hosted startpage for your server. Its design is inspired (heavily) - 📌 Pin your favourite items to the homescreen for quick and easy access - 🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own - 🔑 Authentication system to protect your settings, apps and bookmarks -- 🔨 Dozens of option to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes +- 🔨 Dozens of options to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes - ☀️ Weather widget with current temperature, cloud coverage and animated weather status - 🐳 Docker integration to automatically pick and add apps based on their labels diff --git a/controllers/apps/createApp.js b/controllers/apps/createApp.js index a8208fa..4e0c887 100644 --- a/controllers/apps/createApp.js +++ b/controllers/apps/createApp.js @@ -8,25 +8,20 @@ const loadConfig = require('../../utils/loadConfig'); const createApp = asyncWrapper(async (req, res, next) => { const { pinAppsByDefault } = await loadConfig(); - let app; - let _body = { ...req.body }; + let body = { ...req.body }; - if (_body.icon) { - _body.icon = _body.icon.trim(); + if (body.icon) { + body.icon = body.icon.trim(); } if (req.file) { - _body.icon = req.file.filename; + body.icon = req.file.filename; } - if (pinAppsByDefault) { - app = await App.create({ - ..._body, - isPinned: true, - }); - } else { - app = await App.create(req.body); - } + const app = await App.create({ + ...body, + isPinned: pinAppsByDefault, + }); res.status(201).json({ success: true, diff --git a/controllers/apps/updateApp.js b/controllers/apps/updateApp.js index 290e4ef..cc626e4 100644 --- a/controllers/apps/updateApp.js +++ b/controllers/apps/updateApp.js @@ -18,17 +18,17 @@ const updateApp = asyncWrapper(async (req, res, next) => { ); } - let _body = { ...req.body }; + let body = { ...req.body }; - if (_body.icon) { - _body.icon = _body.icon.trim(); + if (body.icon) { + body.icon = body.icon.trim(); } if (req.file) { - _body.icon = req.file.filename; + body.icon = req.file.filename; } - app = await app.update(_body); + app = await app.update(body); res.status(200).json({ success: true, diff --git a/controllers/bookmarks/createBookmark.js b/controllers/bookmarks/createBookmark.js index 7bf6a01..4b5fb18 100644 --- a/controllers/bookmarks/createBookmark.js +++ b/controllers/bookmarks/createBookmark.js @@ -7,20 +7,20 @@ const Bookmark = require('../../models/Bookmark'); const createBookmark = asyncWrapper(async (req, res, next) => { let bookmark; - let _body = { + let body = { ...req.body, categoryId: parseInt(req.body.categoryId), }; - if (_body.icon) { - _body.icon = _body.icon.trim(); + if (body.icon) { + body.icon = body.icon.trim(); } if (req.file) { - _body.icon = req.file.filename; + body.icon = req.file.filename; } - bookmark = await Bookmark.create(_body); + bookmark = await Bookmark.create(body); res.status(201).json({ success: true, diff --git a/controllers/bookmarks/updateBookmark.js b/controllers/bookmarks/updateBookmark.js index 2899364..448b16c 100644 --- a/controllers/bookmarks/updateBookmark.js +++ b/controllers/bookmarks/updateBookmark.js @@ -19,20 +19,20 @@ const updateBookmark = asyncWrapper(async (req, res, next) => { ); } - let _body = { + let body = { ...req.body, categoryId: parseInt(req.body.categoryId), }; - if (_body.icon) { - _body.icon = _body.icon.trim(); + if (body.icon) { + body.icon = body.icon.trim(); } if (req.file) { - _body.icon = req.file.filename; + body.icon = req.file.filename; } - bookmark = await bookmark.update(_body); + bookmark = await bookmark.update(body); res.status(200).json({ success: true, diff --git a/controllers/categories/createCategory.js b/controllers/categories/createCategory.js index f25b57f..ada5645 100644 --- a/controllers/categories/createCategory.js +++ b/controllers/categories/createCategory.js @@ -8,16 +8,10 @@ const loadConfig = require('../../utils/loadConfig'); const createCategory = asyncWrapper(async (req, res, next) => { const { pinCategoriesByDefault: pinCategories } = await loadConfig(); - let category; - - if (pinCategories) { - category = await Category.create({ - ...req.body, - isPinned: true, - }); - } else { - category = await Category.create(req.body); - } + const category = await Category.create({ + ...req.body, + isPinned: pinCategories, + }); res.status(201).json({ success: true,