Skip to content

Commit 1dd0922

Browse files
committedFeb 9, 2020
Фикс обработки и отображения неизвестных вложений
1 parent 7f19976 commit 1dd0922

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

Diff for: ‎src/js/getTranslate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export default function(name, key, replaces, number) {
5151

5252
if(typeof key == 'boolean') key = key ? 1 : 0;
5353
if(key != null) data = data[key];
54-
if(number != null) data = data[caseOfNumber(number)];
54+
if(number != null && data) data = data[caseOfNumber(number)];
55+
if(!data) return data;
5556

5657
if(Array.isArray(replaces)) {
5758
data = String(data);

Diff for: ‎src/js/messages.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { escape, getPhoto, fields, loadProfile, concatProfiles } from './utils';
1+
import { escape, getPhoto, fields, loadProfile, concatProfiles, capitalize } from './utils';
22
import getTranslate from './getTranslate';
33
import store from './store';
44
import emoji from './emoji';
@@ -154,7 +154,14 @@ export function getMessagePreview(msg, peer_id, author) {
154154

155155
if(attachName) {
156156
const count = attachments[attachName].length;
157-
return getTranslate('im_attachments', attachName, [count], count);
157+
const translate = getTranslate('im_attachments', attachName, [count], count);
158+
159+
if(!translate) {
160+
console.warn('[im] Неизвестное вложение:', attachName);
161+
return capitalize(attachName);
162+
}
163+
164+
return translate;
158165
}
159166

160167
if(isReplyMsg) return getTranslate('im_replied');

0 commit comments

Comments
 (0)
Please sign in to comment.