(config: PriorityIndicatorConfig)
| 227 | } |
| 228 | |
| 229 | export function updatePriorityIndicator(config: PriorityIndicatorConfig): HTMLElement | null { |
| 230 | const { mainRow, card, task, plugin, visibleProperties } = { |
| 231 | ...config, |
| 232 | card: config.mainRow?.closest<HTMLElement>(".task-card") ?? config.mainRow, |
| 233 | }; |
| 234 | if (!card) { |
| 235 | return null; |
| 236 | } |
| 237 | const existingPriorityDot = card.querySelector<HTMLElement>(".task-card__priority-dot"); |
| 238 | const priorityConfig = plugin.priorityManager.getPriorityConfig(task.priority); |
| 239 | |
| 240 | if ( |
| 241 | !task.priority || |
| 242 | !priorityConfig || |
| 243 | !shouldShowPriorityIndicator(visibleProperties, plugin) |
| 244 | ) { |
| 245 | existingPriorityDot?.remove(); |
| 246 | return null; |
| 247 | } |
| 248 | |
| 249 | if (!existingPriorityDot) { |
| 250 | if (!mainRow) { |
| 251 | return null; |
| 252 | } |
| 253 | const priorityDot = createPriorityIndicator(config); |
| 254 | if (priorityDot) { |
| 255 | insertPrimaryIndicator(mainRow, priorityDot, ".task-card__status-dot"); |
| 256 | } |
| 257 | return priorityDot; |
| 258 | } |
| 259 | |
| 260 | configurePriorityIndicator(existingPriorityDot, priorityConfig, plugin); |
| 261 | const newPriorityDot = existingPriorityDot.cloneNode(true) as HTMLElement; |
| 262 | prepareInteractiveControl(newPriorityDot); |
| 263 | newPriorityDot.addEventListener("click", config.onClick); |
| 264 | existingPriorityDot.replaceWith(newPriorityDot); |
| 265 | return newPriorityDot; |
| 266 | } |
no test coverage detected