diff options
author | Frederick Yin <fkfd@fkfd.me> | 2023-07-25 17:20:16 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2023-07-25 17:20:16 +0800 |
commit | 5cc2aa76d0288390f1de4512d4dcff1ab4ac3806 (patch) | |
tree | 06e50289910cf133e0e44ad0ce867f3ec304acd5 | |
parent | 5fdb94ddfed87d3c51e2e3e2c2433ad47b5e0d85 (diff) |
Do not sync when offline
-rw-r--r-- | contents/ui/kanvas.js | 3 | ||||
-rw-r--r-- | contents/ui/main.qml | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/contents/ui/kanvas.js b/contents/ui/kanvas.js index 3162474..dbd2526 100644 --- a/contents/ui/kanvas.js +++ b/contents/ui/kanvas.js @@ -31,6 +31,9 @@ function callApi(path, perPage, callback) { } function syncCanvas() { + if (networkStatus.networkStatus != "Connected") { + return; + } const courses = plasmoid.configuration.courses.split("\n").map( // each line in the "courses" config consists of // a numeric course id, a space, and a course code diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 8a5d7f0..67857d4 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -7,6 +7,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import "kanvas.js" as Kanvas @@ -20,6 +21,10 @@ Item { readonly property string oauth2Token: plasmoid.configuration.oauth2Token readonly property string authHeader: `Bearer ${oauth2Token}` + PlasmaNM.NetworkStatus { + id: networkStatus + } + // sync on initialization Component.onCompleted: Kanvas.syncCanvas() |