diff --git a/src/Applications/UI/Sources/State.elm b/src/Applications/UI/Sources/State.elm index c27e17ca..f0beffe6 100644 --- a/src/Applications/UI/Sources/State.elm +++ b/src/Applications/UI/Sources/State.elm @@ -201,7 +201,20 @@ process model = Return.singleton model toProcess -> - processSpecific toProcess model + if model.isOnline then + processSpecific toProcess model + + else + toProcess + |> List.filter Sources.worksOffline + |> (\s -> + case s of + [] -> + Return.singleton model + + _ -> + processSpecific s model + ) processSpecific : List Source -> Manager diff --git a/src/Library/Sources.elm b/src/Library/Sources.elm index 530df661..70517280 100644 --- a/src/Library/Sources.elm +++ b/src/Library/Sources.elm @@ -92,3 +92,34 @@ enabledSourceIds = setProperId : Int -> Time.Posix -> Source -> Source setProperId n time source = { source | id = String.fromInt (Time.posixToMillis time) ++ String.fromInt n } + + +worksOffline : Source -> Bool +worksOffline source = + case source.service of + AmazonS3 -> + False + + AzureBlob -> + False + + AzureFile -> + False + + Btfs -> + True + + Dropbox -> + False + + Google -> + False + + Ipfs -> + True + + WebDav -> + source.data + |> Dict.get "url" + |> Maybe.map (\u -> String.contains "localhost" u || String.contains "127.0.0.1" u) + |> Maybe.withDefault False