mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Hide loading spinner when an error occured
This commit is contained in:
parent
662eef58ad
commit
38eea1c8c9
2 changed files with 24 additions and 5 deletions
|
|
@ -2,17 +2,34 @@
|
||||||
(:require [re-frame.core :refer [reg-sub subscribe]]
|
(:require [re-frame.core :refer [reg-sub subscribe]]
|
||||||
[airsonic-ui.api.helpers :as api]
|
[airsonic-ui.api.helpers :as api]
|
||||||
[airsonic-ui.helpers :refer [kebabify]]
|
[airsonic-ui.helpers :refer [kebabify]]
|
||||||
[debux.cs.core :refer-macros [dbg]]
|
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; app initialization
|
||||||
|
;;
|
||||||
|
|
||||||
|
;; TODO: Computation and extaction is mixed; this could be simpler
|
||||||
|
|
||||||
|
(defn- error-notifications [notifications]
|
||||||
|
(filter (fn [[_ n]]
|
||||||
|
(= :error (:level n))) notifications))
|
||||||
|
|
||||||
|
(defn- no-errors? [db]
|
||||||
|
(empty? (error-notifications (:notifications db))))
|
||||||
|
|
||||||
|
(defn- no-route? [db]
|
||||||
|
(empty? (:routes/current-route db)))
|
||||||
|
|
||||||
|
(defn- no-credentials? [db]
|
||||||
|
(and (not (empty? (:credentials db)))
|
||||||
|
(not (get-in db [:credentials :verified?]))))
|
||||||
|
|
||||||
(defn is-booting?
|
(defn is-booting?
|
||||||
"The boot process starts with setting up routing and continues if we found
|
"The boot process starts with setting up routing and continues if we found
|
||||||
previous credentials and ends when we receive a response from the server."
|
previous credentials and ends when we receive a response from the server."
|
||||||
[db _]
|
[db _]
|
||||||
;; so either we don't have any credentials or they are not verified
|
;; so either we don't have any credentials or they are not verified
|
||||||
(or (empty? (:routes/current-route db))
|
(and (no-errors? db) (or (no-route? db) (no-credentials? db))))
|
||||||
(and (not (empty? (:credentials db)))
|
|
||||||
(not (get-in db [:credentials :verified?])))))
|
|
||||||
|
|
||||||
(reg-sub ::is-booting? is-booting?)
|
(reg-sub ::is-booting? is-booting?)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@
|
||||||
:credentials verified-credentials}))))
|
:credentials verified-credentials}))))
|
||||||
(testing "Should be true when routing is not yet set up"
|
(testing "Should be true when routing is not yet set up"
|
||||||
(is (true? (is-booting? {:routes/current-route nil
|
(is (true? (is-booting? {:routes/current-route nil
|
||||||
:credentials verified-credentials}))))))
|
:credentials verified-credentials}))))
|
||||||
|
(testing "Should be false when an error occurred"
|
||||||
|
(is (false? (is-booting? (:db (events/show-notification {} [:_ :error "Something bad happened"]))))))))
|
||||||
|
|
||||||
(deftest cover-images
|
(deftest cover-images
|
||||||
(let [credentials {:server "https://foo.bar"
|
(let [credentials {:server "https://foo.bar"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue