Commit 61c7de212f2f9e5ff13ceea09919dcb6d3774c27
Change decision functions to variables
Josiah Witt committed on 3/15/2018, 12:55:29 AMParent: 1f77997f086f31ce27aa9d3d2401244657e728f6
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -19,39 +19,32 @@ | |||
19 | 19 … | if (!item) return result | |
20 | 20 … | ||
21 | 21 … | var { root, tagKey, author, message, tagged, timestamp } = item | |
22 | 22 … | var storedTimestamp = get(result, [author, tagKey, message]) | |
23 … | + var shouldAddTag = tagged && (!storedTimestamp || timestamp > storedTimestamp) | ||
24 … | + var shouldRemoveTag = storedTimestamp && tagged === false | ||
23 | 25 … | ||
24 | 26 … | if (root) { | |
25 | 27 … | var rootTag = { | |
26 | 28 … | [author]: { | |
27 | 29 … | [tagKey]: {} | |
28 | 30 … | } | |
29 | 31 … | } | |
30 | 32 … | result = merge(result, rootTag) | |
31 | - } else if (shouldAddTag()) { | ||
33 … | + } else if (shouldAddTag) { | ||
32 | 34 … | var newTag = { | |
33 | 35 … | [author]: { | |
34 | 36 … | [tagKey]: { | |
35 | 37 … | [message]: timestamp | |
36 | 38 … | } | |
37 | 39 … | } | |
38 | 40 … | } | |
39 | 41 … | result = merge(result, newTag) | |
40 | - } else if (shouldRemoveTag()) { | ||
42 … | + } else if (shouldRemoveTag) { | ||
41 | 43 … | delete result[author][tagKey][message] | |
42 | 44 … | } | |
43 | 45 … | ||
44 | 46 … | return result | |
45 | - | ||
46 | - function shouldAddTag() { | ||
47 | - if (!tagged) return false | ||
48 | - return !storedTimestamp || timestamp > storedTimestamp | ||
49 | - } | ||
50 | - | ||
51 | - function shouldRemoveTag() { | ||
52 | - return storedTimestamp && tagged === false | ||
53 | - } | ||
54 | 47 … | } | |
55 | 48 … | ||
56 | 49 … | function map(msg) { | |
57 | 50 … | // only include your own tags (for now) |
Built with git-ssb-web