From 8eb8e9b271debcde7bdd687ad2f6becbfefa9046 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Tue, 18 Feb 2020 19:01:29 +0100
Subject: [PATCH] Bug when editing news just posted

---
 client/src/views/News.vue | 2 +-
 server/routes/news.js     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/src/views/News.vue b/client/src/views/News.vue
index 5b2c80fe..1509d67d 100644
--- a/client/src/views/News.vue
+++ b/client/src/views/News.vue
@@ -57,7 +57,7 @@ export default {
   },
   created: function() {
     ajax("/news", "GET", { cursor: this.cursor }, res => {
-      this.newsList = res.newsList.sort((n1, n2) => n1.added - n2.added);
+      this.newsList = res.newsList.sort((n1, n2) => n2.added - n1.added);
       const L = res.newsList.length;
       if (L > 0) this.cursor = this.newsList[0].id;
     });
diff --git a/server/routes/news.js b/server/routes/news.js
index ed784564..dbd6d382 100644
--- a/server/routes/news.js
+++ b/server/routes/news.js
@@ -20,7 +20,7 @@ router.post("/news", access.logged, access.ajax, (req,res) => {
     return res.json({errmsg: "Not allowed to post"});
   const content = sanitizeHtml(req.body.news.content);
   NewsModel.create(content, req.userId, (err,ret) => {
-    return res.json(err || {nid:ret.nid});
+    return res.json(err || {id:ret.nid});
   });
 });
 
-- 
2.44.0