User reflection prop iterator

This commit is contained in:
Jiiks 2018-03-08 19:37:50 +02:00
parent 7e2be8bb19
commit b75c7716c9
1 changed files with 6 additions and 9 deletions

View File

@ -153,17 +153,14 @@ export default class {
setId(msg) { setId(msg) {
if (msg.hasAttribute('message-id')) return; if (msg.hasAttribute('message-id')) return;
const r = Reflection(msg); const messageid = Reflection(msg).prop('message');
const message = r.prop('message'); const authorid = Reflection(msg).prop('message.author.id');
if (!message) return; if (!messageid || !authorid) return;
const { id, author } = message; msg.setAttribute('message-id', messageid);
if (!id || !author) return;
const currentUser = author.id === TempApi.currentUserId;
msg.setAttribute('message-id', message.id);
const msgGroup = msg.closest('.message-group'); const msgGroup = msg.closest('.message-group');
if (!msgGroup) return; if (!msgGroup) return;
msgGroup.setAttribute('author-id', author.id); msgGroup.setAttribute('author-id', authorid);
if (currentUser) msgGroup.setAttribute('author-is-currentuser', true); if (authorid === TempApi.currentUserId) msgGroup.setAttribute('author-is-currentuser', true);
} }
setUserId(user) { setUserId(user) {