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