@@ -19,15 +19,19 @@ import * as style from '../style'
1919import * as utils from '../utils'
2020import * as widgets from '../widgets'
2121import { getBlankMsg , verifySignature , SEC } from './signature'
22- import { getPrivateKey , getPublicKey } from './keys'
22+ import { getPublicKey } from './keys'
2323
2424const dom = window . document
2525const messageBodyStyle = style . messageBodyStyle
2626
2727const label = utils . label
2828
2929/**
30+ * elementForImageURI
3031 * HTML component for an image
32+ * @param imageUri
33+ * @param options { inlineImageHeightEms }
34+ * @returns HTMLAnchorElement For Image
3135 */
3236export function elementForImageURI ( imageUri , options ) {
3337 const img = dom . createElement ( 'img' )
@@ -61,33 +65,45 @@ const anchor = function (text, term) {
6165 return a
6266}
6367
64- function nick ( person ) {
68+ function nickname ( person ) {
6569 const s = store . any ( person , ns . foaf ( 'nick' ) )
6670 if ( s ) return '' + s . value
6771 return '' + label ( person )
6872}
6973
7074/**
75+ * creatorAndDate
7176 * Displays creator and date for a chat message
7277 * inside the `td1` element
78+ * @param td1
79+ * @param creator
80+ * @param date
81+ * @param message
82+ * @returns HTMLAnchorElement For Image
7383 */
7484export function creatorAndDate ( td1 , creator , date , message ) {
75- const nickAnchor = td1 . appendChild ( anchor ( nick ( creator ) , creator ) )
85+ const nickAnchor = td1 . appendChild ( anchor ( nickname ( creator ) , creator ) )
7686 if ( creator . uri ) {
7787 store . fetcher . nowOrWhenFetched ( creator . doc ( ) , undefined , function (
7888 _ok ,
7989 _body
8090 ) {
81- nickAnchor . textContent = nick ( creator )
91+ nickAnchor . textContent = nickname ( creator )
8292 } )
8393 }
8494 td1 . appendChild ( dom . createElement ( 'br' ) )
8595 td1 . appendChild ( anchor ( date , message ) )
8696}
8797
8898/**
99+ * creatorAndDateHorizontal
89100 * Horizontally displays creator and date for a chat message
90101 * inside the `td1` element
102+ * @param td1
103+ * @param creator
104+ * @param date
105+ * @param message
106+ * @returns HTMLAnchorElement For Image
91107 */
92108export function creatorAndDateHorizontal ( td1 , creator , date , message ) {
93109 const nickAnchor = td1 . appendChild ( anchor ( label ( creator ) , creator ) )
@@ -96,7 +112,7 @@ export function creatorAndDateHorizontal (td1, creator, date, message) {
96112 _ok ,
97113 _body
98114 ) {
99- nickAnchor . textContent = nick ( creator )
115+ nickAnchor . textContent = nickname ( creator )
100116 } )
101117 }
102118 const dateBit = td1 . appendChild ( anchor ( date , message ) )
@@ -106,12 +122,20 @@ export function creatorAndDateHorizontal (td1, creator, date, message) {
106122}
107123
108124/**
125+ * renderMessageRow
109126 * Renders a chat message, read-only mode
127+ * @param channelObject
128+ * @param message
129+ * @param fresh
130+ * @param options
131+ * @param userContext
132+ * @returns Message Row HTML Table Element
110133 */
111134export function renderMessageRow ( channelObject , message , fresh , options , userContext ) {
135+ let unsignedMessage = false
112136 const colorizeByAuthor =
113137 options . colorizeByAuthor === '1' || options . colorizeByAuthor === true
114-
138+ debug . log ( 'HELLOOOOO SI am here using this render' )
115139 const creator = store . any ( message , ns . foaf ( 'maker' ) )
116140 const date = store . any ( message , ns . dct ( 'created' ) )
117141 const latestVersion = mostRecentVersion ( message )
@@ -130,10 +154,10 @@ export function renderMessageRow (channelObject, message, fresh, options, userCo
130154 msg . maker = creator . uri
131155
132156 // unsigned message
133- if ( ! signature ?. value ) debug . warn ( msgId . uri + ' is unsigned' ) // TODO replace with UI (colored message ?)
134-
135- // signed message, get public key and check signature
136- else {
157+ if ( ! signature ?. value ) {
158+ unsignedMessage = true
159+ debug . warn ( msgId . uri + ' is unsigned' ) // TODO replace with UI (colored message ?)
160+ } else { // signed message, get public key and check signature
137161 getPublicKey ( creator ) . then ( publicKey => {
138162 debug . log ( creator . uri + '\n' + msg . created + '\n' + msg . id + '\n' + publicKey )
139163 if ( ! publicKey ) {
@@ -155,6 +179,7 @@ export function renderMessageRow (channelObject, message, fresh, options, userCo
155179 const sortDate = store . the ( originalMessage , ns . dct ( 'created' ) , null , originalMessage . doc ( ) ) // In message
156180
157181 const messageRow = dom . createElement ( 'tr' )
182+ if ( unsignedMessage ) messageRow . setAttribute ( 'style' , 'background-color: red' )
158183 messageRow . AJAR_date = sortDate . value
159184 messageRow . AJAR_subject = message
160185
@@ -262,7 +287,7 @@ export function renderMessageRow (channelObject, message, fresh, options, userCo
262287 toolsTD . appendChild ( tools )
263288 } )
264289 return messageRow
265- }
290+ } // END OF RENDERMESSAGE
266291
267292export function switchToEditor ( messageRow , message , channelObject , userContext ) {
268293 const messageTable = messageRow . parentNode
0 commit comments