1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-08 06:55:26 +02:00

fix more bugs

This commit is contained in:
Nikita Melnikov 2022-10-03 19:08:03 +08:00
parent 8d566c8c78
commit 46539d8833
3 changed files with 7 additions and 4 deletions

View file

@ -130,7 +130,9 @@ class PagesOrder {
const pageOrder = await PageOrder.get(parentPageId);
// Create unique array with ordered and unordered pages id
pageOrder.order = Array.from(new Set([...pageOrder.order, ...unordered]));
pageOrder.order = Array
.from(new Set([...pageOrder.order, ...unordered].map(id => id?.toString())))
.map(toEntityId);
pageOrder.putAbove(currentPageId, putAbovePageId);
await pageOrder.save();
await PagesFlatArray.regenerate();

View file

@ -1,5 +1,5 @@
import urlify from '../utils/urlify.js';
import database from '../database/index.js';
import database, {isEqualIds} from '../database/index.js';
import { EntityId } from '../database/types.js';
const pagesDb = database['pages'];
@ -208,7 +208,7 @@ class Page {
if (uri) {
let pageWithSameUri = await Page.getByUri(uri);
while (pageWithSameUri._id && pageWithSameUri._id !== this._id) {
while (pageWithSameUri._id && !isEqualIds(pageWithSameUri._id, this._id)) {
pageWithSameUriCount++;
pageWithSameUri = await Page.getByUri(uri + `-${pageWithSameUriCount}`);
}

View file

@ -93,7 +93,8 @@ router.post('/page/:id', multer.none(), async (req: Request, res: Response) => {
const id = toEntityId(req.params.id);
try {
const { title, body, parent, putAbovePageId, uri } = req.body;
const { title, body, putAbovePageId, uri } = req.body;
const parent = toEntityId(req.body.parent);
const pages = await Pages.getAllPages();
let page = await Pages.get(id);