mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
Fixed bug with custom icons not working with apps
This commit is contained in:
parent
1220c56fc5
commit
426766225b
7 changed files with 31 additions and 39 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue