Skip to content

Commit

Permalink
Resolve the next part of type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Feb 5, 2025
1 parent a104624 commit 23eebe3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 16 deletions.
3 changes: 2 additions & 1 deletion packages/app/app/actions/importfavs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { rest, store } from '@nuclear/core';
import globals from '../globals';
import * as FavoritesActions from './favorites';
import { ImportFavs } from './actionTypes';
import { ScrobblingState } from '../reducers/scrobbling';

const MAX_TRACKS_PER_PAGE = 1000;
export function FavImportInit() {
Expand Down Expand Up @@ -40,7 +41,7 @@ function FmSuccessFinal(count) {
}

export function fetchAllFmFavorites() {
const storage = store.get('lastFm');
const storage = store.get('lastFm') as ScrobblingState;
if (storage) {
return async dispatch => {
dispatch({ type: ImportFavs.LASTFM_FAV_IMPORT_START });
Expand Down
3 changes: 2 additions & 1 deletion packages/app/app/actions/plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UserPlugin from '../structs/userPlugin';
import { error } from './toasts';
import { createApi } from '@nuclear/core';
import { find, forEach, isNil } from 'lodash';
import { PluginsState } from '../reducers/plugins';

export const CREATE_PLUGINS = 'CREATE_PLUGINS';
export const SELECT_STREAM_PROVIDER = 'SELECT_STREAM_PROVIDER';
Expand Down Expand Up @@ -158,7 +159,7 @@ export function serializePlugins(plugins) {

export function deserializePlugins() {
return dispatch => {
const plugins = store.get('plugins') || [];
const plugins = (store.get('plugins') || []) as PluginsState['userPlugins'];
forEach(plugins, plugin => {
dispatch(loadUserPlugin(plugin.path));
});
Expand Down
8 changes: 4 additions & 4 deletions packages/app/app/actions/scrobbling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { rest } from '@nuclear/core';

import { Scrobbling } from './actionTypes';
import globals from '../globals';
import { ScrobblingState } from '../reducers/scrobbling';

const lastfm = new rest.LastFmApi(globals.lastfmApiKey, globals.lastfmApiSecret);

export function lastFmReadSettings() {
return dispatch => {
const settings = store.get('lastFm') || {};
const settings = (store.get('lastFm') as ScrobblingState);
if (settings) {
dispatch({
type: Scrobbling.LASTFM_READ_SETTINGS,
payload: {
lastFmName: settings.lastFmName,
lastFmAuthToken: settings.lastFmAuthToken,
lastFmSessionKey: settings.lastFmSessionKey,
lastFmScrobblingEnabled: settings.lastFmScrobblingEnabled,
lastFmFavImportStatus: settings.lastFmFavImportStatus
lastFmScrobblingEnabled: settings.lastFmScrobblingEnabled
}
});
} else {
Expand Down Expand Up @@ -50,7 +50,7 @@ export function lastFmConnectAction() {
};
}

export function lastFmLoginAction(authToken) {
export function lastFmLoginAction(authToken: string) {
return dispatch => {
dispatch({
type: 'FAV_IMPORT_INIT',
Expand Down
2 changes: 1 addition & 1 deletion packages/app/app/actions/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function generateNotification(title: string, details: string, icon?: Node | Rea
},
type)));

const timeout = get(settings, 'notificationTimeout') ?? 3;
const timeout = get(settings, 'notificationTimeout') as number ?? 3;
setTimeout(() => dispatch(removeNotification(id)), timeout * 1000);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type UserPlugin = {
description: string;
image: string | null;
author: string;
loading: boolean;
error: boolean;
loading?: boolean;
error?: boolean;
}

type UserPluginsSectionProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type LastFmSocialIntegrationProps = {
enableScrobbling: Function;
disableScrobbling: Function;
lastFmConnectAction: React.MouseEventHandler;
lastFmLoginAction: React.MouseEventHandler;
lastFmLoginAction: (authToken: string) => void;
lastFmLogOut: React.MouseEventHandler;
};
scrobbling: ReturnType<typeof ScrobblingReducer>;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/app/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type SettingsProps = {
enableScrobbling: Function;
disableScrobbling: Function;
lastFmConnectAction: React.MouseEventHandler;
lastFmLoginAction: React.MouseEventHandler;
lastFmLoginAction: (authToken: string) => void;
lastFmLogOut: React.MouseEventHandler;
};
mastodonActions: {
Expand Down
7 changes: 4 additions & 3 deletions packages/app/app/reducers/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type UserPlugin = {
name: string;
description: string;
image: string;
author: string;
loading?: boolean;
error?: boolean;
}

type PluginKey = keyof typeof config.plugins;
Expand All @@ -32,9 +35,7 @@ export type PluginsState = {
selected: {
[key in PluginKey]?: string;
};
userPlugins: {
[key: string]: UserPlugin;
};
userPlugins: Record<string, UserPlugin>;
}

const initialState: PluginsState = {
Expand Down
11 changes: 9 additions & 2 deletions packages/app/app/reducers/scrobbling.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Scrobbling } from '../actions/actionTypes';

const initialState = {
export type ScrobblingState = {
lastFmName: string | null;
lastFmAuthToken: string | null;
lastFmSessionKey: string | null;
lastFmScrobblingEnabled: boolean;
};

const initialState: ScrobblingState = {
lastFmName: null,
lastFmAuthToken: null,
lastFmSessionKey: null,
lastFmScrobblingEnabled: false
};

export default function ScrobblingReducer(state=initialState, action) {
export default function ScrobblingReducer(state=initialState, action): ScrobblingState {
switch (action.type) {
case Scrobbling.LASTFM_CONNECT:
return Object.assign({}, state, {
Expand Down

0 comments on commit 23eebe3

Please sign in to comment.