Refactor: Use better english

This commit is contained in:
syuilo
2018-05-25 21:05:16 +09:00
parent 94b2ddef45
commit 712c0ef27d
4 changed files with 39 additions and 44 deletions

View File

@ -482,7 +482,7 @@ const endpoints: Endpoint[] = [
name: 'notes/replies'
},
{
name: 'notes/context'
name: 'notes/conversation'
},
{
name: 'notes/create',

View File

@ -5,11 +5,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
/**
* Show a context of a note
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
* Show conversation of a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
@ -33,7 +29,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('note not found');
}
const context = [];
const conversation = [];
let i = 0;
async function get(id) {
@ -41,10 +37,10 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const p = await Note.findOne({ _id: id });
if (i > offset) {
context.push(p);
conversation.push(p);
}
if (context.length == limit) {
if (conversation.length == limit) {
return;
}
@ -58,6 +54,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Serialize
res(await Promise.all(context.map(async note =>
await pack(note, user))));
res(await Promise.all(conversation.map(note => pack(note, user))));
});