mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Fix plugins
This commit is contained in:
27
src-web/hooks/useCheckForUpdates.tsx
Normal file
27
src-web/hooks/useCheckForUpdates.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
||||
import { useAlert } from './useAlert';
|
||||
import { useAppInfo } from './useAppInfo';
|
||||
|
||||
export function useCheckForUpdates() {
|
||||
const alert = useAlert();
|
||||
const appInfo = useAppInfo();
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
const hasUpdate: boolean = await minPromiseMillis(invoke('cmd_check_for_updates'), 500);
|
||||
if (!hasUpdate) {
|
||||
alert({
|
||||
id: 'no-updates',
|
||||
title: 'No Update Available',
|
||||
body: (
|
||||
<>
|
||||
You are currently on the latest version <InlineCode>{appInfo?.version}</InlineCode>
|
||||
</>
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user