()
| 172 | |
| 173 | let tempQuicklinks = null as QuicklinkObject[] | null; |
| 174 | export function getQuicklinks(): QuicklinkObject[] { |
| 175 | if (tempQuicklinks) return tempQuicklinks; |
| 176 | |
| 177 | const quicklinkChibi: QuicklinkObject[] = Object.values(api.settings.getStaticChibi()).map(el => { |
| 178 | return { |
| 179 | key: el.key, |
| 180 | name: el.name, |
| 181 | domain: typeof el.domain === 'string' ? el.domain : el.domain[0], |
| 182 | database: el.database || null, |
| 183 | search: |
| 184 | typeof el.search === 'object' |
| 185 | ? el.search |
| 186 | : { |
| 187 | anime: el.type === 'anime' ? el.search || null : null, |
| 188 | manga: el.type === 'manga' ? el.search || null : null, |
| 189 | }, |
| 190 | }; |
| 191 | }); |
| 192 | |
| 193 | // **Solves a duplication issue when searching for quicklinks, caused by having 2 instances of the same name** |
| 194 | // If a chibi quicklink has the same name as a page quicklink, it will overwrite it |
| 195 | // This is done to ensure that chibi quicklinks are always preferred over pages quicklinks |
| 196 | // This is because chibi quicklinks are more up-to-date and maintained |
| 197 | const combined = new Map<string, QuicklinkObject>(); |
| 198 | quicklinkPages.forEach(p => combined.set(p.name, p)); |
| 199 | quicklinkChibi.forEach(c => combined.set(c.name, c)); |
| 200 | |
| 201 | tempQuicklinks = Array.from(combined.values()); |
| 202 | return tempQuicklinks; |
| 203 | } |
| 204 | |
| 205 | export function combinedLinks() { |
| 206 | const links = api.settings.get('quicklinks'); |
no test coverage detected