* Display keybinding warnings to the user via notifications. * Shows a brief message pointing to /doctor for details.
(warnings, isReload)
| 57 | * Shows a brief message pointing to /doctor for details. |
| 58 | */ |
| 59 | function useKeybindingWarnings(warnings, isReload) { |
| 60 | const $ = _c(9); |
| 61 | const { |
| 62 | addNotification, |
| 63 | removeNotification |
| 64 | } = useNotifications(); |
| 65 | let t0; |
| 66 | if ($[0] !== addNotification || $[1] !== removeNotification || $[2] !== warnings) { |
| 67 | t0 = () => { |
| 68 | if (warnings.length === 0) { |
| 69 | removeNotification("keybinding-config-warning"); |
| 70 | return; |
| 71 | } |
| 72 | const errorCount = count(warnings, _temp); |
| 73 | const warnCount = count(warnings, _temp2); |
| 74 | let message; |
| 75 | if (errorCount > 0 && warnCount > 0) { |
| 76 | message = `Found ${errorCount} keybinding ${plural(errorCount, "error")} and ${warnCount} ${plural(warnCount, "warning")}`; |
| 77 | } else { |
| 78 | if (errorCount > 0) { |
| 79 | message = `Found ${errorCount} keybinding ${plural(errorCount, "error")}`; |
| 80 | } else { |
| 81 | message = `Found ${warnCount} keybinding ${plural(warnCount, "warning")}`; |
| 82 | } |
| 83 | } |
| 84 | message = message + " \xB7 /doctor for details"; |
| 85 | addNotification({ |
| 86 | key: "keybinding-config-warning", |
| 87 | text: message, |
| 88 | color: errorCount > 0 ? "error" : "warning", |
| 89 | priority: errorCount > 0 ? "immediate" : "high", |
| 90 | timeoutMs: 60000 |
| 91 | }); |
| 92 | }; |
| 93 | $[0] = addNotification; |
| 94 | $[1] = removeNotification; |
| 95 | $[2] = warnings; |
| 96 | $[3] = t0; |
| 97 | } else { |
| 98 | t0 = $[3]; |
| 99 | } |
| 100 | let t1; |
| 101 | if ($[4] !== addNotification || $[5] !== isReload || $[6] !== removeNotification || $[7] !== warnings) { |
| 102 | t1 = [warnings, isReload, addNotification, removeNotification]; |
| 103 | $[4] = addNotification; |
| 104 | $[5] = isReload; |
| 105 | $[6] = removeNotification; |
| 106 | $[7] = warnings; |
| 107 | $[8] = t1; |
| 108 | } else { |
| 109 | t1 = $[8]; |
| 110 | } |
| 111 | useEffect(t0, t1); |
| 112 | } |
| 113 | function _temp2(w_0) { |
| 114 | return w_0.severity === "warning"; |
| 115 | } |
no test coverage detected