Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion seerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ components:
enableSpecialEpisodes:
type: boolean
example: false
versionCheck:
type: boolean
example: false
Comment thread
M0NsTeRRR marked this conversation as resolved.
NetworkSettings:
type: object
properties:
Expand Down Expand Up @@ -2147,10 +2150,18 @@ paths:
/status:
get:
summary: Get Seerr status
description: Returns the current Seerr status in a JSON object.
description: Returns the current Seerr status in a JSON object. updateAvailable and commitsBehind are omitted when checkUpdateAvailable is false.
security: []
tags:
- public
parameters:
- in: query
name: checkUpdateAvailable
description: If false, updateAvailable and commitsBehind will be omitted from the response. Defaults to true.
required: false
example: false
schema:
type: boolean
responses:
'200':
description: Returned status
Expand Down
5 changes: 3 additions & 2 deletions server/interfaces/api/settingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface PublicSettingsResponse {
emailEnabled: boolean;
newPlexLogin: boolean;
youtubeUrl: string;
versionCheck: boolean;
plexClientIdentifier: string;
}

Expand Down Expand Up @@ -75,7 +76,7 @@ export interface CacheResponse {
export interface StatusResponse {
version: string;
commitTag: string;
updateAvailable: boolean;
commitsBehind: number;
updateAvailable?: boolean;
commitsBehind?: number;
restartRequired: boolean;
}
4 changes: 4 additions & 0 deletions server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export interface MainSettings {
enableSpecialEpisodes: boolean;
locale: string;
youtubeUrl: string;
versionCheck: boolean;
}

export interface ProxySettings {
Expand Down Expand Up @@ -214,6 +215,7 @@ interface FullPublicSettings extends PublicSettings {
userEmailRequired: boolean;
newPlexLogin: boolean;
youtubeUrl: string;
versionCheck: boolean;
plexClientIdentifier: string;
}

Expand Down Expand Up @@ -429,6 +431,7 @@ class Settings {
enableSpecialEpisodes: false,
locale: 'en',
youtubeUrl: '',
versionCheck: true,
},
plex: {
name: '',
Expand Down Expand Up @@ -734,6 +737,7 @@ class Settings {
this.data.notifications.agents.email.options.userEmailRequired,
newPlexLogin: this.data.main.newPlexLogin,
youtubeUrl: this.data.main.youtubeUrl,
versionCheck: this.data.main.versionCheck,
plexClientIdentifier: this.data.clientId,
};
}
Expand Down
52 changes: 27 additions & 25 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,51 @@ const router = Router();
router.use(checkUser);

router.get<unknown, StatusResponse>('/status', async (req, res) => {
const githubApi = new GithubAPI();

const currentVersion = getAppVersion();
const commitTag = getCommitTag();
const checkUpdate = req.query.checkUpdateAvailable !== 'false';
let updateAvailable = false;
let commitsBehind = 0;

if (currentVersion.startsWith('develop-') && commitTag !== 'local') {
const commits = await githubApi.getSeerrCommits();
if (checkUpdate) {
const githubApi = new GithubAPI();

if (commits.length) {
const filteredCommits = commits.filter(
(commit) => !commit.commit.message.includes('[skip ci]')
);
if (filteredCommits[0].sha !== commitTag) {
updateAvailable = true;
}
if (currentVersion.startsWith('develop-') && commitTag !== 'local') {
const commits = await githubApi.getSeerrCommits();

const commitIndex = filteredCommits.findIndex(
(commit) => commit.sha === commitTag
);
if (commits.length) {
const filteredCommits = commits.filter(
(commit) => !commit.commit.message.includes('[skip ci]')
);
if (filteredCommits[0].sha !== commitTag) {
updateAvailable = true;
}

const commitIndex = filteredCommits.findIndex(
(commit) => commit.sha === commitTag
);

if (updateAvailable) {
commitsBehind = commitIndex;
if (updateAvailable) {
commitsBehind = commitIndex;
}
}
}
} else if (commitTag !== 'local') {
const releases = await githubApi.getSeerrReleases();
} else if (commitTag !== 'local') {
const releases = await githubApi.getSeerrReleases();

if (releases.length) {
const latestVersion = releases[0];
if (releases.length) {
const latestVersion = releases[0];

if (!latestVersion.name.includes(currentVersion)) {
updateAvailable = true;
if (!latestVersion.name.includes(currentVersion)) {
updateAvailable = true;
}
}
}
}

return res.status(200).json({
version: getAppVersion(),
commitTag: getCommitTag(),
updateAvailable,
commitsBehind,
...(checkUpdate && { updateAvailable, commitsBehind }),
restartRequired: restartFlag.isSet(),
});
});
Expand Down
43 changes: 25 additions & 18 deletions src/components/Layout/VersionStatus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import useSettings from '@app/hooks/useSettings';
import defineMessages from '@app/utils/defineMessages';
import {
ArrowUpCircleIcon,
Expand All @@ -23,10 +24,14 @@ interface VersionStatusProps {
}

const VersionStatus = ({ onClick }: VersionStatusProps) => {
const settings = useSettings();
const intl = useIntl();
const { data } = useSWR<StatusResponse>('/api/v1/status', {
refreshInterval: 60 * 1000,
});
const { data } = useSWR<StatusResponse>(
`/api/v1/status?checkUpdateAvailable=${settings.currentSettings.versionCheck}`,
{
refreshInterval: 60 * 1000,
}
);

if (!data) {
return null;
Expand Down Expand Up @@ -65,21 +70,23 @@ const VersionStatus = ({ onClick }: VersionStatusProps) => {
)}
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
<span className="font-bold">{versionStream}</span>
<span className="truncate">
{data.commitTag === 'local' ? (
'(⌐■_■)'
) : data.commitsBehind > 0 ? (
intl.formatMessage(messages.commitsbehind, {
commitsBehind: data.commitsBehind,
})
) : data.commitsBehind === -1 ? (
intl.formatMessage(messages.outofdate)
) : (
<code className="bg-transparent p-0">
{data.version.replace('develop-', '')}
</code>
)}
</span>
{data.commitsBehind !== undefined && (
<span className="truncate">
{data.commitTag === 'local' ? (
'(⌐■_■)'
) : data.commitsBehind > 0 ? (
intl.formatMessage(messages.commitsbehind, {
commitsBehind: data.commitsBehind,
})
) : data.commitsBehind === -1 ? (
intl.formatMessage(messages.outofdate)
) : (
<code className="bg-transparent p-0">
{data.version.replace('develop-', '')}
</code>
)}
</span>
)}
</div>
{data.updateAvailable && <ArrowUpCircleIcon className="h-6 w-6" />}
</Link>
Expand Down
95 changes: 60 additions & 35 deletions src/components/Settings/SettingsAbout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import List from '@app/components/Common/List';
import LoadingSpinner from '@app/components/Common/LoadingSpinner';
import PageTitle from '@app/components/Common/PageTitle';
import Releases from '@app/components/Settings/SettingsAbout/Releases';
import useSettings from '@app/hooks/useSettings';
import globalMessages from '@app/i18n/globalMessages';
import ErrorPage from '@app/pages/_error';
import defineMessages from '@app/utils/defineMessages';
Expand All @@ -29,17 +30,21 @@ const messages = defineMessages('components.Settings.SettingsAbout', {
documentation: 'Documentation',
outofdate: 'Out of Date',
uptodate: 'Up to Date',
versionCheckDisabled: 'Version Check Disabled',
runningDevelop:
'You are running the <code>develop</code> branch of Seerr, which is only recommended for those contributing to development or assisting with bleeding-edge testing.',
});

const SettingsAbout = () => {
const settings = useSettings();
const intl = useIntl();
const { data, error } = useSWR<SettingsAboutResponse>(
'/api/v1/settings/about'
);

const { data: status } = useSWR<StatusResponse>('/api/v1/status');
const { data: status } = useSWR<StatusResponse>(
settings.currentSettings.versionCheck ? '/api/v1/status' : null
);

if (!data && !error) {
return <LoadingSpinner />;
Expand Down Expand Up @@ -75,42 +80,62 @@ const SettingsAbout = () => {
<code className="truncate">
{data.version.replace('develop-', '')}
</code>
{status?.commitTag !== 'local' &&
(status?.updateAvailable ? (
<a
href={
data.version.startsWith('develop-')
? `https://github.com/seerr-team/seerr/compare/${status.commitTag}...develop`
: 'https://github.com/seerr-team/seerr/releases'
}
target="_blank"
rel="noopener noreferrer"
>
<Badge
badgeType="warning"
className="ml-2 !cursor-pointer transition hover:bg-yellow-400"
{settings.currentSettings.versionCheck ? (
status && status.commitTag !== 'local' ? (
status.updateAvailable ? (
<a
href={
data.version.startsWith('develop-')
? `https://github.com/seerr-team/seerr/compare/${status.commitTag}...develop`
: 'https://github.com/seerr-team/seerr/releases'
}
target="_blank"
rel="noopener noreferrer"
>
{intl.formatMessage(messages.outofdate)}
</Badge>
</a>
) : (
<a
href={
data.version.startsWith('develop-')
? 'https://github.com/seerr-team/seerr/commits/develop'
: 'https://github.com/seerr-team/seerr/releases'
}
target="_blank"
rel="noopener noreferrer"
>
<Badge
badgeType="success"
className="ml-2 !cursor-pointer transition hover:bg-green-400"
<Badge
badgeType="warning"
className="ml-2 !cursor-pointer transition hover:bg-yellow-400"
>
{intl.formatMessage(messages.outofdate)}
</Badge>
</a>
) : (
<a
href={
data.version.startsWith('develop-')
? 'https://github.com/seerr-team/seerr/commits/develop'
: 'https://github.com/seerr-team/seerr/releases'
}
target="_blank"
rel="noopener noreferrer"
>
{intl.formatMessage(messages.uptodate)}
</Badge>
</a>
))}
<Badge
badgeType="success"
className="ml-2 !cursor-pointer transition hover:bg-green-400"
>
{intl.formatMessage(messages.uptodate)}
</Badge>
</a>
)
) : null
) : (
<a
href={
data.version.startsWith('develop-')
? 'https://github.com/seerr-team/seerr/commits/develop'
: 'https://github.com/seerr-team/seerr/releases'
}
target="_blank"
rel="noopener noreferrer"
>
<Badge
badgeType="primary"
className="ml-2 !cursor-pointer transition hover:bg-yellow-400"
>
{intl.formatMessage(messages.versionCheckDisabled)}
</Badge>
</a>
)}
</List.Item>
<List.Item title={intl.formatMessage(messages.totalmedia)}>
{intl.formatNumber(data.totalMediaItems)}
Expand Down
22 changes: 22 additions & 0 deletions src/components/Settings/SettingsMain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const messages = defineMessages('components.Settings.SettingsMain', {
youtubeUrl: 'YouTube URL',
youtubeUrlTip:
'Base URL for YouTube videos if a self-hosted YouTube instance is used.',
versionCheck: 'Version Check',
versionCheckTip: 'Automatically check for new versions on GitHub.',
validationUrl: 'You must provide a valid URL',
validationUrlTrailingSlash: 'URL must not end in a trailing slash',
});
Expand Down Expand Up @@ -183,6 +185,7 @@ const SettingsMain = () => {
enableSpecialEpisodes: data?.enableSpecialEpisodes,
cacheImages: data?.cacheImages,
youtubeUrl: data?.youtubeUrl,
versionCheck: data?.versionCheck,
}}
enableReinitialize
validationSchema={MainSettingsSchema}
Expand All @@ -205,6 +208,7 @@ const SettingsMain = () => {
enableSpecialEpisodes: values.enableSpecialEpisodes,
cacheImages: values.cacheImages,
youtubeUrl: values.youtubeUrl,
versionCheck: values?.versionCheck,
});
mutate('/api/v1/settings/public');
mutate('/api/v1/status');
Expand Down Expand Up @@ -607,6 +611,24 @@ const SettingsMain = () => {
)}
</div>
</div>
<div className="form-row">
<label htmlFor="versionCheck" className="text-label">
{intl.formatMessage(messages.versionCheck)}
<span className="label-tip">
{intl.formatMessage(messages.versionCheckTip)}
</span>
</label>
<div className="form-input-area">
<Field
type="checkbox"
id="versionCheck"
name="versionCheck"
onChange={() => {
setFieldValue('versionCheck', !values.versionCheck);
}}
/>
</div>
</div>
<div className="actions">
<div className="flex justify-end">
<span className="ml-3 inline-flex rounded-md shadow-sm">
Expand Down
Loading
Loading