Skip to content

Commit

Permalink
fix: remove unused actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xstoudi committed Jul 17, 2023
1 parent 3742422 commit 35cb063
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 59 deletions.
22 changes: 3 additions & 19 deletions src/hooks/useSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import { invoke } from '@tauri-apps/api';
import { useCallback } from 'react';

import {
UPDATE_ARTICLES,
UPDATE_CONTENT,
UPDATE_FEED_TYPE,
UPDATE_MULTIPLE_ARTICLES,
UPDATE_MULTIPLE_FEED_TYPE,
UPDATE_MULTIPLE_CONTENT,
} from '../state/data/DataActionType';
import {
DECREMENT_FETCHING,
INCREMENT_FETCHING,
} from '../state/view/ViewActionType';
import SyncRequest from '../types/SyncRequest';
import SyncResponse from '../types/SyncResponse';
import articleMapper from '../utils/articleMapper';

import useData from './useData';
import useDataDispatch from './useDataDispatch';
Expand Down Expand Up @@ -63,27 +59,15 @@ export default function useSync() {
identifier: feed.identifier,
link: feed.link,
}));
/* eslint-enable camelcase */

viewDispatch({
type: INCREMENT_FETCHING,
});

invoke<SyncResponse[]>('sync_all', { syncRequest })
.then((response) => {
dataDispatch({
type: UPDATE_MULTIPLE_FEED_TYPE,
payload: response.map(({ identifier, type }) => ({
identifier,
type,
})),
});
dataDispatch({
type: UPDATE_MULTIPLE_ARTICLES,
payload: response.map(({ identifier, articles }) => ({
identifier,
articles: articles.map(articleMapper),
})),
type: UPDATE_MULTIPLE_CONTENT,
payload: response,
});
})
.catch((error) => {
Expand Down
6 changes: 0 additions & 6 deletions src/state/data/DataActionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ export type DataActionType<Action, Payload = void> = Payload extends void
export const LOAD = 'LOAD';
export const ADD_FEED = 'ADD_FEED';
export const UPDATE_FEED = 'UPDATE_FEED';

export const UPDATE_CONTENT = 'UPDATE_CONTENT';
export const UPDATE_MULTIPLE_CONTENT = 'UPDATE_MULTIPLE_CONTENT';

export const UPDATE_ARTICLES = 'UPDATE_ARTICLES';
export const UPDATE_MULTIPLE_ARTICLES = 'UPDATE_MULTIPLE_ARTICLES';
export const UPDATE_FEED_TYPE = 'UPDATE_FEED_TYPE';
export const UPDATE_MULTIPLE_FEED_TYPE = 'UPDATE_MULTIPLE_FEED_TYPE';
export const READ_ARTICLE = 'READ_ARTICLE';
export const REMOVE_FEED = 'REMOVE_FEED';
8 changes: 0 additions & 8 deletions src/state/data/DataReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ import {
AddFeedAction,
ReadArticleAction,
RemoveFeedAction,
UpdateArticlesAction,
UpdateContentAction,
UpdateFeedAction,
UpdateFeedTypeAction,
UpdateMultipleArticlesAction,
UpdateMultipleContentAction,
UpdateMultipleFeedTypeAction,
} from './actions/FeedActions';
import * as LoadActions from './actions/LoadActions';
import { LoadAction } from './actions/LoadActions';
Expand All @@ -39,10 +35,6 @@ export const initialDataState: DataState = {
export type DataActions =
| AddFeedAction
| UpdateFeedAction
| UpdateArticlesAction
| UpdateMultipleArticlesAction
| UpdateFeedTypeAction
| UpdateMultipleFeedTypeAction
| ReadArticleAction
| RemoveFeedAction
| LoadAction
Expand Down
26 changes: 0 additions & 26 deletions src/state/data/actions/FeedActions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { v4 as uuid } from '@lukeed/uuid';
import { Draft } from 'immer';

import Article from '../../../types/Article';
import Feed from '../../../types/Feed';
import FeedType from '../../../types/FeedType';
import SyncResponse, { ArticleResponse } from '../../../types/SyncResponse';
import articleMapper from '../../../utils/articleMapper';
import reconciliate from '../../../utils/reconciliate';
Expand All @@ -12,11 +10,7 @@ import {
DataActionType,
READ_ARTICLE,
REMOVE_FEED,
UPDATE_ARTICLES,
UPDATE_FEED,
UPDATE_FEED_TYPE,
UPDATE_MULTIPLE_ARTICLES,
UPDATE_MULTIPLE_FEED_TYPE,
UPDATE_CONTENT,
UPDATE_MULTIPLE_CONTENT,
} from '../DataActionType';
Expand All @@ -32,26 +26,6 @@ export type UpdateFeedAction = DataActionType<
{ identifier: string; displayName: string; link: string; interval: string }
>;

export type UpdateArticlesAction = DataActionType<
typeof UPDATE_ARTICLES,
{ identifier: string; articles: Article[] }
>;

export type UpdateMultipleArticlesAction = DataActionType<
typeof UPDATE_MULTIPLE_ARTICLES,
{ identifier: string; articles: Article[] }[]
>;

export type UpdateFeedTypeAction = DataActionType<
typeof UPDATE_FEED_TYPE,
{ identifier: string; type: Exclude<FeedType, null> }
>;

export type UpdateMultipleFeedTypeAction = DataActionType<
typeof UPDATE_MULTIPLE_FEED_TYPE,
{ identifier: string; type: Exclude<FeedType, null> }[]
>;

export type ReadArticleAction = DataActionType<
typeof READ_ARTICLE,
{ identifier: string; articleIdentifier: string }
Expand Down

0 comments on commit 35cb063

Please sign in to comment.