From 712c0ef27d72e522f8628c349b5ccf950cfeaed6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 25 May 2018 21:05:16 +0900 Subject: [PATCH] Refactor: Use better english --- .../desktop/views/components/note-detail.vue | 34 +++++++++---------- .../mobile/views/components/note-detail.vue | 32 ++++++++--------- src/server/api/endpoints.ts | 2 +- .../notes/{context.ts => conversation.ts} | 15 +++----- 4 files changed, 39 insertions(+), 44 deletions(-) rename src/server/api/endpoints/notes/{context.ts => conversation.ts} (80%) diff --git a/src/client/app/desktop/views/components/note-detail.vue b/src/client/app/desktop/views/components/note-detail.vue index d5526e5d6a..5b48b7a1ba 100644 --- a/src/client/app/desktop/views/components/note-detail.vue +++ b/src/client/app/desktop/views/components/note-detail.vue @@ -2,16 +2,16 @@
-
- +
+
@@ -107,8 +107,8 @@ export default Vue.extend({ data() { return { - context: [], - contextFetching: false, + conversation: [], + conversationFetching: false, replies: [] }; }, @@ -176,15 +176,15 @@ export default Vue.extend({ }, methods: { - fetchContext() { - this.contextFetching = true; + fetchConversation() { + this.conversationFetching = true; - // Fetch context - (this as any).api('notes/context', { + // Fetch conversation + (this as any).api('notes/conversation', { noteId: this.p.replyId - }).then(context => { - this.contextFetching = false; - this.context = context.reverse(); + }).then(conversation => { + this.conversationFetching = false; + this.conversation = conversation.reverse(); }); }, reply() { @@ -249,7 +249,7 @@ root(isDark) &:disabled color isDark ? #21242b : #ccc - > .context + > .conversation > * border-bottom 1px solid isDark ? #1c2023 : #eef0f2 diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue index c6664a91da..244dbb6c03 100644 --- a/src/client/app/mobile/views/components/note-detail.vue +++ b/src/client/app/mobile/views/components/note-detail.vue @@ -2,15 +2,15 @@
-
- +
+
@@ -99,8 +99,8 @@ export default Vue.extend({ data() { return { - context: [], - contextFetching: false, + conversation: [], + conversationFetching: false, replies: [] }; }, @@ -166,14 +166,14 @@ export default Vue.extend({ methods: { fetchContext() { - this.contextFetching = true; + this.conversationFetching = true; - // Fetch context - (this as any).api('notes/context', { + // Fetch conversation + (this as any).api('notes/conversation', { noteId: this.p.replyId - }).then(context => { - this.contextFetching = false; - this.context = context.reverse(); + }).then(conversation => { + this.conversationFetching = false; + this.conversation = conversation.reverse(); }); }, reply() { @@ -245,7 +245,7 @@ root(isDark) &:disabled color #ccc - > .context + > .conversation > * border-bottom 1px solid isDark ? #1c2023 : #eef0f2 diff --git a/src/server/api/endpoints.ts b/src/server/api/endpoints.ts index 7647c76d3d..892da3540f 100644 --- a/src/server/api/endpoints.ts +++ b/src/server/api/endpoints.ts @@ -482,7 +482,7 @@ const endpoints: Endpoint[] = [ name: 'notes/replies' }, { - name: 'notes/context' + name: 'notes/conversation' }, { name: 'notes/create', diff --git a/src/server/api/endpoints/notes/context.ts b/src/server/api/endpoints/notes/conversation.ts similarity index 80% rename from src/server/api/endpoints/notes/context.ts rename to src/server/api/endpoints/notes/conversation.ts index 1cd27250e2..02f7229ccf 100644 --- a/src/server/api/endpoints/notes/context.ts +++ b/src/server/api/endpoints/notes/conversation.ts @@ -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} + * 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)))); });