Skip to content

Commit

Permalink
Feat: Add DownloadMissingTmdbPeople as available action (#1148)
Browse files Browse the repository at this point in the history
* Feat: Add `DownloadMissingTmdbPeople` as available action

* Misc: Revert bump to minimum supported server version

* Feat: Only add new action if supported by server
  • Loading branch information
fearnlj01 authored Nov 27, 2024
1 parent f0df158 commit 925389c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/Dialogs/ActionsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import cx from 'classnames';
import { map } from 'lodash';

Expand All @@ -7,6 +7,7 @@ import toast from '@/components/Toast';
import quickActions from '@/core/quick-actions';
import { useRunActionMutation } from '@/core/react-query/action/mutations';
import useEventCallback from '@/hooks/useEventCallback';
import useIsFeatureSupported, { FeatureType } from '@/hooks/useIsFeatureSupported';

const actions = {
import: {
Expand Down Expand Up @@ -122,6 +123,12 @@ const Action = ({ actionKey, length }: { actionKey: string, length: number }) =>
function ActionsModal({ onClose, show }: Props) {
const [activeTab, setActiveTab] = useState('import');

const isRepairTmdbPeopleSupported = useIsFeatureSupported(FeatureType.RepairTmdbPeopleAction);
useEffect(() => {
const action = 'download-missing-tmdb-people';
if (isRepairTmdbPeopleSupported && !actions.moviedb.data.includes(action)) actions.moviedb.data.push(action);
}, [isRepairTmdbPeopleSupported]);

return (
<ModalPanel
show={show}
Expand Down
5 changes: 5 additions & 0 deletions src/core/quick-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ const quickActions = {
functionName: 'PurgeAllUnusedTmdbShows',
info: 'Delete all unused TMDB Shows that are not linked to any AniDB anime.',
},
'download-missing-tmdb-people': {
name: 'Download Missing TMDB People',
functionName: 'DownloadMissingTmdbPeople',
info: 'Downloads any Tmdb People missing in the local database.',
},
'plex-sync-all': {
name: 'Sync Plex Watch Status',
functionName: 'PlexSyncAll',
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useIsFeatureSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { VersionType } from '@/core/types/api/init';

export enum FeatureType {
UnairedEpisodeFilter = '5.0.0.18',
RepairTmdbPeopleAction = '5.0.0.61',
}

const useIsFeatureSupported = (feature: FeatureType) => {
Expand Down

0 comments on commit 925389c

Please sign in to comment.