summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-12-28 23:05:30 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-12-28 23:05:30 +0900
commit5c490e75213f0f876c35ab4fb6cf71eefa3afab7 (patch)
tree0c6a4ec4b7e7aae785cbcf013cf8f4c37f97dfe9
parent12.64.0 (diff)
downloadsharkey-5c490e75213f0f876c35ab4fb6cf71eefa3afab7.tar.gz
sharkey-5c490e75213f0f876c35ab4fb6cf71eefa3afab7.tar.bz2
sharkey-5c490e75213f0f876c35ab4fb6cf71eefa3afab7.zip
Bug fix and refactoring
-rw-r--r--src/client/components/notification.vue6
-rw-r--r--src/client/sw/compose-notification.ts2
-rw-r--r--src/misc/get-note-summary.ts4
-rw-r--r--src/misc/get-notification-summary.ts15
-rw-r--r--src/server/web/index.ts2
5 files changed, 14 insertions, 15 deletions
diff --git a/src/client/components/notification.vue b/src/client/components/notification.vue
index 0c6be82bb8..2fe8500891 100644
--- a/src/client/components/notification.vue
+++ b/src/client/components/notification.vue
@@ -61,12 +61,12 @@
import { defineComponent } from 'vue';
import { faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faCheck, faPollH } from '@fortawesome/free-solid-svg-icons';
import { faClock } from '@fortawesome/free-regular-svg-icons';
-import noteSummary from '../../misc/get-note-summary';
+import { getNoteSummary } from '../../misc/get-note-summary';
import XReactionIcon from './reaction-icon.vue';
import MkFollowButton from './follow-button.vue';
import notePage from '../filters/note';
import { userPage } from '../filters/user';
-import { locale } from '../i18n';
+import { i18n } from '@/i18n';
import * as os from '@/os';
export default defineComponent({
@@ -91,7 +91,7 @@ export default defineComponent({
},
data() {
return {
- getNoteSummary: (text: string) => noteSummary(text, locale),
+ getNoteSummary: (text: string) => getNoteSummary(text, i18n.locale),
followRequestDone: false,
groupInviteDone: false,
connection: null,
diff --git a/src/client/sw/compose-notification.ts b/src/client/sw/compose-notification.ts
index 0863d7ef8b..17421db5c8 100644
--- a/src/client/sw/compose-notification.ts
+++ b/src/client/sw/compose-notification.ts
@@ -1,4 +1,4 @@
-import getNoteSummary from '../../misc/get-note-summary';
+import { getNoteSummary } from '../../misc/get-note-summary';
import getUserName from '../../misc/get-user-name';
import { i18n } from '@/sw/i18n';
diff --git a/src/misc/get-note-summary.ts b/src/misc/get-note-summary.ts
index 7db8bca3ec..b80da16caf 100644
--- a/src/misc/get-note-summary.ts
+++ b/src/misc/get-note-summary.ts
@@ -2,7 +2,7 @@
* 投稿を表す文字列を取得します。
* @param {*} note (packされた)投稿
*/
-const summarize = (note: any, locale: any): string => {
+export const getNoteSummary = (note: any, locale: any): string => {
if (note.deletedAt) {
return `(${locale['deletedNote']})`;
}
@@ -50,5 +50,3 @@ const summarize = (note: any, locale: any): string => {
return summary.trim();
};
-
-export default summarize;
diff --git a/src/misc/get-notification-summary.ts b/src/misc/get-notification-summary.ts
index b20711c605..aade3f75be 100644
--- a/src/misc/get-notification-summary.ts
+++ b/src/misc/get-notification-summary.ts
@@ -1,6 +1,7 @@
import getUserName from './get-user-name';
-import getNoteSummary from './get-note-summary';
+import { getNoteSummary } from './get-note-summary';
import getReactionEmoji from './get-reaction-emoji';
+import locales = require('../../locales');
/**
* 通知を表す文字列を取得します。
@@ -11,17 +12,17 @@ export default function(notification: any): string {
case 'follow':
return `${getUserName(notification.user)}にフォローされました`;
case 'mention':
- return `言及されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
+ return `言及されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
case 'reply':
- return `返信されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
+ return `返信されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
case 'renote':
- return `Renoteされました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
+ return `Renoteされました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
case 'quote':
- return `引用されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
+ return `引用されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
case 'reaction':
- return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getNoteSummary(notification.note)}」`;
+ return `リアクションされました:\n${getUserName(notification.user)} <${getReactionEmoji(notification.reaction)}>「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
case 'pollVote':
- return `投票されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note)}」`;
+ return `投票されました:\n${getUserName(notification.user)}「${getNoteSummary(notification.note, locales['ja-JP'])}」`;
default:
return `<不明な通知タイプ: ${notification.type}>`;
}
diff --git a/src/server/web/index.ts b/src/server/web/index.ts
index 57ce9b38a4..caa3f65c27 100644
--- a/src/server/web/index.ts
+++ b/src/server/web/index.ts
@@ -19,7 +19,7 @@ import { genOpenapiSpec } from '../api/openapi/gen-spec';
import config from '../../config';
import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips } from '../../models';
import parseAcct from '../../misc/acct/parse';
-import getNoteSummary from '../../misc/get-note-summary';
+import { getNoteSummary } from '../../misc/get-note-summary';
import { ensure } from '../../prelude/ensure';
import { getConnection } from 'typeorm';
import redis from '../../db/redis';