Skip to content
This repository was archived by the owner on Mar 8, 2026. It is now read-only.

Commit f10498a

Browse files
committed
checking for updates, file organizeation
1 parent 70911dd commit f10498a

11 files changed

Lines changed: 109 additions & 7 deletions

File tree

src/back/api/checkForUpdate.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import requests
2+
import src.back.util.print as print
3+
4+
urlToVersion = "https://raw.githubusercontent.com/daveberrys/SendYourFIles/refs/heads/main/version.txt"
5+
6+
def getLatestVersion():
7+
try:
8+
response = requests.get(urlToVersion, timeout=5)
9+
if response.status_code == 200:
10+
return response.text.strip()
11+
return None
12+
except Exception as e:
13+
print.error(f"Update check failed: {e}")
14+
return None
15+
16+
def isUpdateAvailable(currentVersion):
17+
latest = getLatestVersion()
18+
19+
if latest is None:
20+
return {"status": "error"}
21+
22+
print.debug(f"Latest version is {latest} and current version is {currentVersion}")
23+
if latest != currentVersion:
24+
print.debug(f"Update available! {latest} is newer than {currentVersion}")
25+
return {"status": "success", "available": True, "latest": latest}
26+
27+
print.debug(f"No update available. {latest} is the latest version.")
28+
return {"status": "success", "available": False, "latest": currentVersion}

src/back/system/contact.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import webview
22
import os
3+
34
from src.back.api.sendingFile import catbox, litterbox, buzzheavier
5+
from src.back.api.checkForUpdate import isUpdateAvailable
46

57
class API:
68
def pickFile(self):
@@ -20,3 +22,11 @@ def uploadTo(self, path, platform, duration="1h"):
2022
elif platform == "buzzheavier":
2123
return buzzheavier(path)
2224
return "Unknown platform"
25+
26+
def checkForUpdates(self):
27+
try:
28+
with open("version.txt", "r") as f:
29+
currentVersion = f.read().strip()
30+
return isUpdateAvailable(currentVersion)
31+
except Exception as e:
32+
return f"Error: {str(e)}"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ body {
7878
.bigText {
7979
font-weight: bold;
8080
font-size: 30px;
81+
} .smallText {
82+
color: gray;
83+
font-size: 12px;
8184
}
8285

8386
.frame > .textYap {

src/front/main/index.html

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<link rel="stylesheet" href="popup/popupStyle.css">
2-
<link rel="stylesheet" href="cacaStyle.css">
1+
<link rel="stylesheet" href="css/popupStyle.css">
2+
<link rel="stylesheet" href="css/cacaStyle.css">
33

44
<script>
55
let selectedPath = null;
@@ -8,12 +8,16 @@
88
async function loadPopups() {
99
const popups = [
1010
'sendTo.html',
11-
'sendTo-Fallback.html',
1211
'settings.html',
1312
'credits.html',
13+
14+
'extra/sendTo-Fallback.html',
1415
'extra/litterboxTime.html',
1516
'extra/limiter/catbox.html',
16-
'extra/limiter/litterbox.html'
17+
'extra/limiter/litterbox.html',
18+
19+
'extra/updaters/newUpdateAvailable.html',
20+
'extra/updaters/failedToFetch.html',
1721
];
1822

1923
for (const file of popups) {
@@ -28,7 +32,12 @@
2832
}
2933
}
3034

31-
window.addEventListener('DOMContentLoaded', loadPopups);
35+
window.addEventListener('DOMContentLoaded', () => {
36+
loadPopups().then(() => {
37+
checkUpdates(); // Call this AFTER popups are loaded
38+
});
39+
});
40+
3241
async function chooseFile() {
3342
try {
3443
const data = await window.pywebview.api.pickFile();
@@ -156,6 +165,29 @@
156165
logPanel.innerText = "Error: Could not reach the server.";
157166
}
158167
}
168+
169+
// I don't even wanna explain how this works dude
170+
async function checkUpdates() {
171+
try {
172+
const result = await window.pywebview.api.checkForUpdates();
173+
174+
if (result.status === "error") {
175+
showPopup('failedToFetchPopup');
176+
} else if (result.status === "success" && result.available) {
177+
const downloadLink = document.getElementById('updateDownloadLink');
178+
if (downloadLink) {
179+
downloadLink.href = `https://github.com/daveberrys/SendYourFiles/releases/tag/${result.latest}`;
180+
}
181+
const versionText = document.getElementById('updateVersionText');
182+
if (versionText) {
183+
versionText.innerText = `Latest version: ${result.latest}`;
184+
}
185+
showPopup('newUpdateAvailablePopup');
186+
}
187+
} catch (e) {
188+
console.error("Javascript failed to call update check:", e);
189+
}
190+
}
159191
</script>
160192

161193
<main class="xyCenter">
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="failedToFetchPopup" class="popup-overlay" onclick="if(event.target == this) closePopup('failedToFetchPopup')">
2+
<div class="popup-content">
3+
<h3>Uh oh! Failed to fetch!</h3>
4+
<p>Something somewhere in the code failed to fetch. Maybe check your connection or is the website down?</p>
5+
<p>Let us know if we made a problem at
6+
<a href="https://github.com/daveberrys/SendYourFiles/issues" target="_blank">
7+
the github issues tab!
8+
</a>
9+
</p>
10+
11+
<div class="button secondary" onclick="closePopup('failedToFetchPopup')">Cancel</div>
12+
</div>
13+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div id="newUpdateAvailablePopup" class="popup-overlay" onclick="if(event.target == this) closePopup('newUpdateAvailablePopup')">
2+
<div class="popup-content">
3+
<h3>New Update Available!</h3>
4+
<p>A new update is available! We'd recommend downloading the latest for better stability.</p>
5+
<p id="updateVersionText"></p>
6+
7+
<div class="flex" style="gap: 5px;">
8+
<a id="updateDownloadLink" target="_blank" style="display: contents">
9+
<div class="button" onclick="closePopup('newUpdateAvailablePopup')">Download</div>
10+
</a>
11+
<div class="button" onclick="closePopup('newUpdateAvailablePopup')">Cancel</div>
12+
</div>
13+
</div>
14+
</div>

src/front/main/popup/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h3>Settings</h3>
44
<p>Coming soon...</p>
55
<p>EST: Probably whenever I'm motivated to do it.</p>
6-
<span style="color: gray; font-size: 12px;">hint hint: gift me something and I'll do it faster 👀</span>
6+
<span class="smallText">hint hint: gift me something and I'll do it faster 👀</span>
77
<div class="button secondary" onclick="closePopup('settingsPopup')">Close</div>
88
</div>
99
</div>

src/front/window.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def startUp(debugMode):
1212
# css = f.read()
1313
# window.load_css(css)
1414

15+
API.checkForUpdates(API())
16+
1517
here = os.path.join(os.path.dirname(__file__), "main", "index.html")
1618
print.debug(f"URL for HTTP is at {here}")
1719

0 commit comments

Comments
 (0)