Archived
jaja
This commit is contained in:
+10
-3
@@ -79,7 +79,14 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
const videos = db.get('videos');
|
||||
req.query.id ? res.send(videos.getById(req.query.id).value()) : res.send(videos.value())
|
||||
if (req.query.prevId){
|
||||
let tmp=videos.map(el=>el.id.reason.map(el=>el.reason.map(el2=>{
|
||||
if(el2.prevId===req.query.prevId){
|
||||
return {...el2, 'id':this.id}
|
||||
}
|
||||
},el)));
|
||||
res.send(tmp)}
|
||||
else{res.send(videos)}
|
||||
});
|
||||
|
||||
// POST /videotrack
|
||||
@@ -118,7 +125,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
||||
row
|
||||
.update('timesWatched', (n) => ++n)
|
||||
.update('lastWatched', () => new Date().toISOString())
|
||||
.update('reason', (n) => setReason(req.body.reason, n, req.body.id))
|
||||
.update('reason', (n) => setReason(req.body.reason, n, req.body.prevId))
|
||||
.write()
|
||||
.then(output => res.send(200, output))
|
||||
} else {
|
||||
@@ -126,7 +133,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
||||
"id": req.body.id.toString(),
|
||||
"timesWatched": 1,
|
||||
"lastWatched": new Date().toISOString(),
|
||||
"reason": setReason(req.body.reason,[],req.body.id)
|
||||
"reason": setReason(req.body.reason,[],req.body.prevId)
|
||||
}
|
||||
videos.push(newRow).last().write().then(output => res.send(200, output))
|
||||
}
|
||||
|
||||
+1
-6
@@ -34,19 +34,14 @@ class App extends React.Component {
|
||||
exact: true,
|
||||
strict: false
|
||||
});
|
||||
if (prevState.videoId !== null) {
|
||||
if (idMatch && idMatch.params.id !== prevState.videoId) {
|
||||
localStorage.setItem('prevId', prevState.videoId)
|
||||
localStorage.setItem('lastId', idMatch.params.id)
|
||||
return { videoId: idMatch.params.id };
|
||||
}
|
||||
else {
|
||||
if (idMatch && idMatch.params.id !== prevState.videoId) {
|
||||
localStorage.setItem('lastId', idMatch.params.id)
|
||||
return { videoId: idMatch.params.id };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user