git ssb

2+

mixmix / ticktack



Commit dba1ec48c08d0594936b838fc855835948a3aef2

add a chache to message/html/subject

mix irving committed on 2/13/2018, 9:05:15 PM
Parent: 202db7a1462af5a1b1dbeb6b5c220468060f96ea

Files changed

message/html/subject.jschanged
message/html/subject.jsView
@@ -12,23 +12,27 @@
1212 'sbot.async.get': 'first',
1313 })
1414
1515 exports.create = function (api) {
16 + var subjectCache = {}
17 +
1618 return nest('message.html.subject', subject)
1719
1820 function subject (msg) {
1921 if (msg === undefined) debugger
2022 // test if it's a message ref, or a full message object
23 + // a message ref is generally passed in if we're fetching the subject of a root message
2124 if (isMsg(msg)) {
25 + if (subjectCache[msg]) return subjectCache[msg]
26 +
2227 var subject = Value()
2328
2429 api.sbot.async.get(msg, (err, value) => {
2530 if (err) throw err
26-
27- subject.set(getMsgSubject({
28- key: msg,
29- value: api.message.sync.unbox(value)
30- }))
31 +
32 + var _subject = getMsgSubject({ key: msg, value: api.message.sync.unbox(value) })
33 + subject.set(_subject)
34 + subjectCache[msg] = _subject
3135 })
3236
3337 return subject
3438 }

Built with git-ssb-web