A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Closes #332

+22 -7
+22 -7
src/Javascript/Workers/search.js
··· 8 8 import lunr from "lunr" 9 9 10 10 11 + const FIELDS = ["album", "artist", "title"] 12 + 13 + 11 14 lunr.Pipeline.registerFunction( 12 15 removeParenthesesFromToken, 13 16 "Remove parentheses from token" ··· 61 64 .reduce( 62 65 ([ acc, previousOperator, previousPrefix ], chunk) => { 63 66 const operator = (a => a && a[0])( chunk.match(/^(\+|-)/) ) 64 - const chunkWithoutOperator = chunk.replace(/^(\+|-)/, "").replace(/\*$/, "") 65 - const prefix = (a => a && a[1])( chunkWithoutOperator.match(/^([^:]+:)/) ) 66 - const chunkWithoutPrefix = chunkWithoutOperator.replace(/^([^:]+:)/, "") 67 + 68 + let chunkWithoutOperator = chunk.replace(/^(\+|-)/, "").replace(/\*$/, "").trim() 69 + let prefix = (a => a && a[1])( chunkWithoutOperator.match(/^([^:]+:)/) ) 70 + let chunkWithoutPrefix = chunkWithoutOperator.replace(/^([^:]+:)/, "") 71 + 72 + if (prefix && !FIELDS.includes(prefix.slice(0, -1))) { 73 + prefix = null 74 + chunkWithoutPrefix = chunkWithoutOperator.replace(":", "\\:") 75 + chunkWithoutOperator = chunkWithoutPrefix 76 + 77 + } else if (prefix && chunkWithoutPrefix.includes(":")) { 78 + chunkWithoutPrefix = chunkWithoutPrefix.replace(":", "\\:") 79 + chunkWithoutOperator = prefix + chunkWithoutPrefix 80 + 81 + } 67 82 68 83 const op = operator || previousOperator 69 84 const pr = prefix ? "" : (operator ? "" : previousPrefix) ··· 114 129 : input 115 130 116 131 index = customLunr(function() { 117 - this.field("album"); 118 - this.field("artist"); 119 - this.field("title"); 132 + FIELDS.forEach( 133 + field => this.field(field) 134 + ) 120 135 121 - (tracks || []) 136 + ;(tracks || []) 122 137 .map(mapTrack) 123 138 .forEach(t => this.add(t)) 124 139 })