Bug fix and Document fix
Removed the string object from config.json as it's now all in the locale. and I fixed data.getdata() to return an error code if the index is out of bounds, it now returns a 1. Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
@@ -11,7 +11,12 @@ export function getdata(data, index=-1) {
|
||||
if (data == "posts" || data == 'users' || data == 'comments') {
|
||||
let result = func.require_module(`../data/${data}.json`)
|
||||
if (index != -1) {
|
||||
if (index < result.length-1) {
|
||||
return result[index]
|
||||
}
|
||||
else {
|
||||
return 1 // This index doesn't exist
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -62,8 +62,7 @@ router.get("/user/:username", (req, res) => {
|
||||
router.get("/post/:post_index", (req, res) => {
|
||||
const postID = req.params.post_index
|
||||
let post = data.getdata('posts', postID)
|
||||
|
||||
if (post["deleted"] == true || post == 1) { // data.getdata returns error code 1 if nothing is available
|
||||
if (post == 1) { // data.getdata returns error code 1 if nothing is available
|
||||
res.render("partials/message", {
|
||||
message: locale.post_doesnt_exist,
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user