Skip to content

Commit

Permalink
update once per hour only
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Dec 3, 2022
1 parent ff0e71a commit aef5803
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/qml/CSLOLDialogUpdate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Dialog {
onOpened: window.show()

property string update_url: "https://github.com/LoL-Fantome/cslol-manager/releases/latest"
property int lastUpdateUTCMinutes: 0

onAccepted: Qt.openUrlExternally(update_url)

Expand All @@ -43,6 +44,11 @@ Dialog {
}

function checkForUpdates() {
let cur_time = Date.now() / (1000 * 60)
if (cur_time - lastUpdateUTCMinutes < 60) {
return
}
lastUpdateUTCMinutes = cur_time
let url = "https://api.github.com/repos/LoL-Fantome/cslol-manager";
makeRequest(url + "/releases", function(releases) {
for (let index in releases) {
Expand Down
1 change: 1 addition & 0 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ApplicationWindow {
property alias windowHeight: window.height
property alias windowWidth: window.width
property bool windowMaximised
property alias lastUpdateUTCMinutes: cslolDialogUpdate.lastUpdateUTCMinutes

fileName: "config.ini"
}
Expand Down

0 comments on commit aef5803

Please sign in to comment.