mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-12 23:47:06 +00:00
remove version check
This commit is contained in:
parent
a192e05ac7
commit
b600a86345
3 changed files with 1 additions and 101 deletions
|
@ -263,10 +263,6 @@ const createWindow = async () => {
|
|||
ipcMain.on('stop-watcher', async () => {
|
||||
await stopWatchFiles();
|
||||
});
|
||||
|
||||
ipcMain.handle('get-app-version', () => {
|
||||
return app.getVersion();
|
||||
});
|
||||
};
|
||||
|
||||
app.on('open-url', async (event, url) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Icon } from '@iconify/react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import Button from 'renderer/components/Button';
|
||||
import useSound from 'use-sound';
|
||||
import { ScreenshotArgs, ScreenshotResult } from 'main/screenshot';
|
||||
|
@ -8,9 +8,6 @@ import WebPage from 'main/screenshot/webpage';
|
|||
|
||||
import screenshotSfx from 'renderer/assets/sfx/screenshot.mp3';
|
||||
import { updateWebViewHeightAndScale } from 'common/webViewUtils';
|
||||
import useCheckVersion from 'renderer/components/useCheckVersion/useCheckVersion';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { setNotifications } from 'renderer/store/features/renderer';
|
||||
import { ColorBlindnessTools } from './ColorBlindnessTools';
|
||||
|
||||
interface Props {
|
||||
|
@ -48,16 +45,6 @@ const Toolbar = ({
|
|||
useState<boolean>(false);
|
||||
const [rotated, setRotated] = useState<boolean>(false);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const { isNewVersionAvailable } = useCheckVersion();
|
||||
|
||||
useEffect(() => {
|
||||
if (isNewVersionAvailable) {
|
||||
dispatch(setNotifications(newVersionText));
|
||||
}
|
||||
}, [dispatch, isNewVersionAvailable]);
|
||||
|
||||
const refreshView = () => {
|
||||
if (webview) {
|
||||
webview.reload();
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import { gt } from 'semver';
|
||||
import useLocalStorage from '../useLocalStorage/useLocalStorage';
|
||||
|
||||
const fetchAssets = async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
'https://api.github.com/repos/responsively-org/responsively-app-releases/releases/latest'
|
||||
);
|
||||
const data = await response.json();
|
||||
return data.tag_name;
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Error getting assets', err);
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const getAppVersion = async () => {
|
||||
try {
|
||||
const version = await window.electron.ipcRenderer.invoke('get-app-version');
|
||||
return `v${version}`;
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Error getting app version', err);
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const useCheckVersion = () => {
|
||||
const [isNewVersionAvailable, setIsNewVersionAvailable] = useState<
|
||||
null | boolean
|
||||
>(null);
|
||||
const [latestVersion, setLatestVersion] = useLocalStorage<undefined | string>(
|
||||
'latestVersion'
|
||||
);
|
||||
const [currentVersion, setCurrentVersion] = useState('');
|
||||
const [lastCheck, setLastCheck] = useLocalStorage<number | undefined>(
|
||||
'lastCheck'
|
||||
);
|
||||
const biWeeklyCheckInMs = 1209600000;
|
||||
|
||||
useEffect(() => {
|
||||
const checkVersion = async () => {
|
||||
const currentVersionResult = await getAppVersion();
|
||||
|
||||
setCurrentVersion(currentVersionResult);
|
||||
|
||||
const now = Date.now();
|
||||
if (!latestVersion || !lastCheck || now - lastCheck > biWeeklyCheckInMs) {
|
||||
const latestVersionResult = await fetchAssets();
|
||||
if (latestVersionResult) {
|
||||
setLatestVersion(latestVersionResult);
|
||||
setLastCheck(now);
|
||||
}
|
||||
}
|
||||
const isNewVersion =
|
||||
currentVersionResult &&
|
||||
latestVersion &&
|
||||
gt(latestVersion, currentVersionResult);
|
||||
|
||||
setIsNewVersionAvailable(Boolean(isNewVersion));
|
||||
};
|
||||
|
||||
if (isNewVersionAvailable === null) {
|
||||
checkVersion();
|
||||
}
|
||||
}, [
|
||||
isNewVersionAvailable,
|
||||
lastCheck,
|
||||
latestVersion,
|
||||
setLastCheck,
|
||||
setLatestVersion,
|
||||
]);
|
||||
|
||||
return {
|
||||
isNewVersionAvailable,
|
||||
currentVersion,
|
||||
latestVersion,
|
||||
};
|
||||
};
|
||||
|
||||
export default useCheckVersion;
|
Loading…
Reference in a new issue