MCPcopy
hub / github.com/hedgedoc/hedgedoc / parseHistoryCallback

Function parseHistoryCallback

public/js/cover.js:134–170  ·  view source on GitHub ↗
(list, notehistory)

Source from the content-addressed store, hash-verified

132}
133
134function parseHistoryCallback (list, notehistory) {
135 checkHistoryList()
136 // sort by pinned then timestamp
137 list.sort('', {
138 sortFunction (a, b) {
139 const notea = a.values()
140 const noteb = b.values()
141 if (notea.pinned && !noteb.pinned) {
142 return -1
143 } else if (!notea.pinned && noteb.pinned) {
144 return 1
145 } else {
146 if (notea.timestamp > noteb.timestamp) {
147 return -1
148 } else if (notea.timestamp < noteb.timestamp) {
149 return 1
150 } else {
151 return 0
152 }
153 }
154 }
155 })
156 // parse filter tags
157 const filtertags = []
158 for (let i = 0, l = list.items.length; i < l; i++) {
159 const tags = list.items[i]._values.tags
160 if (tags && tags.length > 0) {
161 for (let j = 0; j < tags.length; j++) {
162 // push info filtertags if not found
163 let found = false
164 if (filtertags.includes(tags[j])) { found = true }
165 if (!found) { filtertags.push(tags[j]) }
166 }
167 }
168 }
169 buildTagsFilter(filtertags)
170}
171
172// update items whenever list updated
173historyList.on('updated', e => {

Callers 1

cover.jsFile · 0.85

Calls 2

checkHistoryListFunction · 0.85
buildTagsFilterFunction · 0.85

Tested by

no test coverage detected