Bug fix and refactoring

This commit is contained in:
syuilo 2020-12-28 23:05:30 +09:00
parent 8523f6d132
commit 0ae634c55f
5 changed files with 14 additions and 15 deletions

View file

@ -61,12 +61,12 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faCheck, faPollH } from '@fortawesome/free-solid-svg-icons'; 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 { 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 XReactionIcon from './reaction-icon.vue';
import MkFollowButton from './follow-button.vue'; import MkFollowButton from './follow-button.vue';
import notePage from '../filters/note'; import notePage from '../filters/note';
import { userPage } from '../filters/user'; import { userPage } from '../filters/user';
import { locale } from '../i18n'; import { i18n } from '@/i18n';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -91,7 +91,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
getNoteSummary: (text: string) => noteSummary(text, locale), getNoteSummary: (text: string) => getNoteSummary(text, i18n.locale),
followRequestDone: false, followRequestDone: false,
groupInviteDone: false, groupInviteDone: false,
connection: null, connection: null,

View file

@ -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 getUserName from '../../misc/get-user-name';
import { i18n } from '@/sw/i18n'; import { i18n } from '@/sw/i18n';

View file

@ -2,7 +2,7 @@
* 稿 * 稿
* @param {*} note (packされた)稿 * @param {*} note (packされた)稿
*/ */
const summarize = (note: any, locale: any): string => { export const getNoteSummary = (note: any, locale: any): string => {
if (note.deletedAt) { if (note.deletedAt) {
return `(${locale['deletedNote']})`; return `(${locale['deletedNote']})`;
} }
@ -50,5 +50,3 @@ const summarize = (note: any, locale: any): string => {
return summary.trim(); return summary.trim();
}; };
export default summarize;

View file

@ -1,6 +1,7 @@
import getUserName from './get-user-name'; 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 getReactionEmoji from './get-reaction-emoji';
import locales = require('../../locales');
/** /**
* *
@ -11,17 +12,17 @@ export default function(notification: any): string {
case 'follow': case 'follow':
return `${getUserName(notification.user)}にフォローされました`; return `${getUserName(notification.user)}にフォローされました`;
case 'mention': case 'mention':
return `言及されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note)}`; return `言及されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note, locales['ja-JP'])}`;
case 'reply': case 'reply':
return `返信されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note)}`; return `返信されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note, locales['ja-JP'])}`;
case 'renote': 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': case 'quote':
return `引用されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note)}`; return `引用されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note, locales['ja-JP'])}`;
case 'reaction': 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': case 'pollVote':
return `投票されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note)}`; return `投票されました:\n${getUserName(notification.user)}${getNoteSummary(notification.note, locales['ja-JP'])}`;
default: default:
return `<不明な通知タイプ: ${notification.type}>`; return `<不明な通知タイプ: ${notification.type}>`;
} }

View file

@ -19,7 +19,7 @@ import { genOpenapiSpec } from '../api/openapi/gen-spec';
import config from '../../config'; import config from '../../config';
import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips } from '../../models'; import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips } from '../../models';
import parseAcct from '../../misc/acct/parse'; 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 { ensure } from '../../prelude/ensure';
import { getConnection } from 'typeorm'; import { getConnection } from 'typeorm';
import redis from '../../db/redis'; import redis from '../../db/redis';