Skip to content

Commit

Permalink
If papers is specified, only render specific paper even if uuid is pr…
Browse files Browse the repository at this point in the history
…esent
  • Loading branch information
pathikrit committed May 10, 2024
1 parent ce8192a commit c33c2b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ const app = express()
.get('/latest', (req, res) => res.render('paper'))
.post('/latest', (req, res) => {
const result = {}
if (req.body.uuid) {
if (req.body.papers) {
result.paper = nextPaper({newspapers: req.body.papers.map(paper => ({id: paper}))}, req.body.prev)
if (!result.paper) result.missing = `Newspapers = ${req.body.papers}`
} if (req.body.uuid) {
result.device = db.devices.find(device => device.id === req.body.uuid)
if (result.device) result.paper = nextPaper(result.device, req.body.prev)
else result.missing = `Device Id = ${req.body.uuid}`
} else if (req.body.papers) {
result.paper = nextPaper({newspapers: req.body.papers.map(paper => ({id: paper}))}, req.body.prev)
if (!result.paper) result.missing = `Newspapers = ${req.body.papers}`
} else {
result.paper = nextPaper(null, req.body.prev)
}
Expand Down

0 comments on commit c33c2b0

Please sign in to comment.