mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat: status checker to prompt users to reload their frontend when app version changes
This commit is contained in:
@@ -175,11 +175,9 @@ const Sidebar: React.FC<SidebarProps> = ({ open, setClosed }) => {
|
||||
>
|
||||
<div className="flex-shrink-0 flex items-center px-4">
|
||||
<span className="text-xl text-gray-50">
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img src="/logo.png" alt="Overseerr Logo" />
|
||||
</a>
|
||||
</Link>
|
||||
<a href="/">
|
||||
<img src="/logo.png" alt="Overseerr Logo" />
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<nav className="mt-5 px-2 space-y-1">
|
||||
@@ -239,11 +237,9 @@ const Sidebar: React.FC<SidebarProps> = ({ open, setClosed }) => {
|
||||
<div className="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
|
||||
<div className="flex items-center flex-shrink-0 px-4">
|
||||
<span className="text-2xl text-gray-50">
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img src="/logo.png" alt="Overseerr Logo" />
|
||||
</a>
|
||||
</Link>
|
||||
<a href="/">
|
||||
<img src="/logo.png" alt="Overseerr Logo" />
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<nav className="mt-5 flex-1 px-2 bg-gray-800 space-y-1">
|
||||
|
62
src/components/StatusChacker/index.tsx
Normal file
62
src/components/StatusChacker/index.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import React from 'react';
|
||||
import useSWR from 'swr';
|
||||
import Modal from '../Common/Modal';
|
||||
import Transition from '../Transition';
|
||||
|
||||
const StatusChecker: React.FC = () => {
|
||||
const { data, error } = useSWR<{ version: string; commitTag: string }>(
|
||||
'/api/v1/status',
|
||||
{
|
||||
refreshInterval: 60 * 1000,
|
||||
}
|
||||
);
|
||||
|
||||
if (!data && !error) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Transition
|
||||
enter="opacity-0 transition duration-300"
|
||||
enterFrom="opacity-0"
|
||||
enterTo="opacity-100"
|
||||
leave="opacity-100 transition duration-300"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
appear
|
||||
show={data.commitTag !== process.env.commitTag}
|
||||
>
|
||||
<Modal
|
||||
iconSvg={
|
||||
<svg
|
||||
className="w-6 h-6"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"
|
||||
/>
|
||||
</svg>
|
||||
}
|
||||
title="New Version Available"
|
||||
onOk={() => location.reload()}
|
||||
okText="Reload Overseerr"
|
||||
backgroundClickable={false}
|
||||
>
|
||||
An update is now available. Click the button below to reload the
|
||||
application.
|
||||
</Modal>
|
||||
</Transition>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatusChecker;
|
Reference in New Issue
Block a user