Skip to content

Commit

Permalink
feat: add action to search for TMDB matches
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 10, 2024
1 parent d056ae8 commit 9579366
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 @@ -125,6 +126,12 @@ const Action = ({ actionKey, length }: { actionKey: string, length: number }) =>
function ActionsModal({ onClose, show }: Props) {
const [activeTab, setActiveTab] = useState('import');

const isTmdbSearchActionSupported = useIsFeatureSupported(FeatureType.TmdbSearchAction);
useEffect(() => {
const action0 = 'search-for-tmdb-matches';
if (isTmdbSearchActionSupported && !actions.tmdb.data.includes(action0)) actions.tmdb.data.unshift(action0);
}, [isTmdbSearchActionSupported]);

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 @@ -104,6 +104,11 @@ const quickActions = {
functionName: 'ValidateAllImages',
info: 'Identifies any invalid images and re-downloads them.',
},
'search-for-tmdb-matches': {
name: 'Search for TMDB Matches',
functionName: 'SearchForTmdbMatches',
info: 'Scan for TMDB matches for all unlinked AniDB anime.',
},
'update-all-tmdb-movies': {
name: 'Update All TMDB Movies',
functionName: 'UpdateAllTmdbMovies',
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 {
Placeholder = '5.0.0.0', // This is as a placeholder so the string conversion for `parseServerVersion` works and also serves as an example
TmdbSearchAction = '5.0.0.86',
}

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

0 comments on commit 9579366

Please sign in to comment.