mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add info toast for new dev version available
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=false react-scripts build",
|
"build": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=false react-scripts build",
|
||||||
"build-netlify": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build",
|
"build-netlify": "echo $COMMIT_REF > ./public/latest_commit.txt && cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"analyze-bundle": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true react-scripts build && source-map-explorer 'build/static/js/*.js'",
|
"analyze-bundle": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true react-scripts build && source-map-explorer 'build/static/js/*.js'",
|
||||||
"electron": "yarn electron:before && electron .",
|
"electron": "yarn electron:before && electron .",
|
||||||
|
|||||||
+13
-2
@@ -25,6 +25,7 @@ import useError from "./hooks/useError";
|
|||||||
import useInfo from "./hooks/useInfo";
|
import useInfo from "./hooks/useInfo";
|
||||||
import useSuccess from "./hooks/useSuccess";
|
import useSuccess from "./hooks/useSuccess";
|
||||||
import packageJson from '../package.json';
|
import packageJson from '../package.json';
|
||||||
|
const commitRef = process?.env?.REACT_APP_COMMIT_REF || '';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const {
|
const {
|
||||||
@@ -73,7 +74,18 @@ export default function App() {
|
|||||||
|
|
||||||
if (packageJson.version !== packageData.version) {
|
if (packageJson.version !== packageData.version) {
|
||||||
const newVersionInfo = `New version available, plebchan v${packageData.version}. Refresh the page to update.`;
|
const newVersionInfo = `New version available, plebchan v${packageData.version}. Refresh the page to update.`;
|
||||||
localStorage.setItem('infoToast', newVersionInfo);;
|
localStorage.setItem('infoToast', newVersionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for commit hash if commitRef is defined
|
||||||
|
if (commitRef.length > 0) {
|
||||||
|
const commitRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/development/public/latest_commit.txt', { cache: 'no-cache' });
|
||||||
|
const latestCommit = await commitRes.text();
|
||||||
|
|
||||||
|
if (latestCommit.trim() !== commitRef.trim()) {
|
||||||
|
const newVersionInfo = `New dev version available, commit ${latestCommit}. Refresh the page to update.`;
|
||||||
|
localStorage.setItem('infoToast', newVersionInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch latest version info:', error);
|
console.error('Failed to fetch latest version info:', error);
|
||||||
@@ -84,7 +96,6 @@ export default function App() {
|
|||||||
}, [setNewInfoMessage]);
|
}, [setNewInfoMessage]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// preload banners
|
// preload banners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadImages = async () => {
|
const loadImages = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user