-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from SimonB50/main
Librusek v0.2.0
- Loading branch information
Showing
36 changed files
with
789 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
import { getVersion as getAppVersion } from "@tauri-apps/api/app"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const apiUrl = "https://synergia.librus.pl/gateway/api/2.0"; | ||
const repoApiUrl = "https://api.github.com/repos/SimonB50/librusek"; | ||
|
||
const getVersion = async () => { | ||
const appVersion = await getAppVersion(); | ||
const versionRequest = await fetch(`${repoApiUrl}/releases/latest`); | ||
if (versionRequest.status !== 200) return { | ||
currentVersion: appVersion, | ||
latestVersion: "unknown", | ||
updateAvailable: false, | ||
} | ||
const versionResponse = await versionRequest.json(); | ||
const latestVersion = versionResponse.tag_name.slice(1); | ||
return { | ||
currentVersion: appVersion, | ||
latestVersion: latestVersion, | ||
updateAvailable: appVersion !== latestVersion, | ||
} | ||
} | ||
const useVersion = () => { | ||
const [data, setData] = useState(null); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const data = await getVersion(); | ||
setData(data); | ||
setError(null); | ||
} catch (err) { | ||
setError(err.message); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
const upperFirst = (string) => { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
return { data, loading, error }; | ||
} | ||
|
||
export { apiUrl, upperFirst }; | ||
export { apiUrl, repoApiUrl, getVersion, useVersion }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.