Skip to content

Commit

Permalink
cleanup: fix lint, tests, compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aolsenjazz committed Oct 14, 2024
1 parent 1d93bfa commit b12bdfa
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 44 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/shared/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ test('getDiff returns 1 pair at second index', () => {
expect(result[1].length).toBe(1);
});

describe('id', () => {
describe('inputIdFromDriver', () => {
test('returns expected ID for xy driver', () => {
const result = inputIdFromDriver(TwoByteDriver);
expect(result).toBe('programchange.11.10');
const result = inputIdFromDriver(XYDrive);
expect(result).toBe('controlchange.11.10/pitchbend.12');
});

test('returns expected ID for two-byte driver', () => {
const result = inputIdFromDriver(ThreeByteDriver);
expect(result).toBe('controlchange.11.10');
const result = inputIdFromDriver(TwoByteDriver);
expect(result).toBe('programchange.11.10');
});

test('returns expected ID for three-byte driver', () => {
const result = inputIdFromDriver(XYDrive);
expect(result).toBe('controlchange.11.10pitchbend.12');
const result = inputIdFromDriver(ThreeByteDriver);
expect(result).toBe('controlchange.11.10');
});
});
2 changes: 1 addition & 1 deletion src/main/plugin-registry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Registry } from './registry';
import type { BasePlugin } from '@shared/plugin-core/base-plugin';
import { Registry } from './registry';

export const PluginRegistry = new Registry<BasePlugin>();
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default function DeviceDetailsPanel(props: PropTypes) {
plugins={config?.plugins || []}
removePlugin={removePlugin}
showPluginMenu={showPluginMenu}
deviceId={id}
importPlugin={(title) => importDeviceSubcomponent(title, 'gui')}
showAddPlugin
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import InputDefaultsSubpanel from '../InputDefaultsSubpanel';

type PropTypes = {
input: InputDTO;
deviceId: string;
};

const { InputConfigService } = window;

export default function MonoInputConfigPanel(props: PropTypes) {
const { input, deviceId } = props;
const { input } = props;

const showPluginMenu = useCallback(
(x: number, y: number) => {
Expand Down Expand Up @@ -46,8 +45,7 @@ export default function MonoInputConfigPanel(props: PropTypes) {
plugins={input.plugins}
removePlugin={removePlugin}
showPluginMenu={showPluginMenu}
showAddPlugin={true}
deviceId={deviceId}
showAddPlugin
importPlugin={(title) => importInputSubcomponent(title, 'gui')}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DeviceConfigDTO } from '@shared/hardware-config/device-config';
import { InputDTO } from '@shared/hardware-config/input-config/base-input-config';

import InputDetailsSubpanel from './InputDetailsSubpanel';
Expand All @@ -7,12 +6,11 @@ import InputDetailsSubpanel from './InputDetailsSubpanel';
import MonoInputConfigPanel from './MonoInputConfigSubpanel';

type InputConfigurationProps = {
config: DeviceConfigDTO;
input: InputDTO;
};

export default function InputConfigPanel(props: InputConfigurationProps) {
const { config, input } = props;
const { input } = props;

let Element = null;
switch (input.type) {
Expand All @@ -25,7 +23,7 @@ export default function InputConfigPanel(props: InputConfigurationProps) {
// Element = <SwitchConfigSubpanel />;
break;
default:
Element = <MonoInputConfigPanel input={input} deviceId={config.id} />;
Element = <MonoInputConfigPanel input={input} />;
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/InputConfigDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function InputConfigDrawer() {
} else if (selectedInput === '') {
Element = <BasicMessage msg="No inputs selected." />;
} else if (config && inputConfig) {
Element = <InputConfigPanel config={config} input={inputConfig} />;
Element = <InputConfigPanel input={inputConfig} />;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const { PluginService } = window;
type PropTypes = {
pluginId: string;
title: string;
selectedDevice: string;
importPlugin: (title: string) => Promise<React.FC<PluginUIProps>>;
};

Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/PluginSubpanel/PluginSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const { PluginService } = window;

type PropTypes = {
pluginId: string;
selectedDevice: string;
removePlugin: (pluginId: string) => void;
importPlugin: (title: string) => Promise<React.FC<PluginUIProps>>;
};
Expand All @@ -27,7 +26,7 @@ type PropTypes = {
* can cause a single plugin slot to represent n plugins, if all homogenous.
*/
export default function PluginSlot(props: PropTypes) {
const { pluginId, removePlugin, selectedDevice, importPlugin } = props;
const { pluginId, removePlugin, importPlugin } = props;

const dispatch = useAppDispatch();
const selectedPlugin = useSelector(selectSelectedPluginId);
Expand Down Expand Up @@ -70,7 +69,6 @@ export default function PluginSlot(props: PropTypes) {
<PluginBody
pluginId={pluginId}
title={plugin.title}
selectedDevice={selectedDevice}
importPlugin={importPlugin}
/>
)}
Expand Down
14 changes: 3 additions & 11 deletions src/renderer/components/PluginSubpanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,25 @@ type PluginSubpanelProps = {
showPluginMenu: (x: number, y: number) => void;
removePlugin: (pluginId: string) => void;
showAddPlugin: boolean;
deviceId: string;
importPlugin: (title: string) => Promise<React.FC<PluginUIProps>>;
};

export default function PluginSubpanel(props: PluginSubpanelProps) {
const {
plugins,
showPluginMenu,
removePlugin,
showAddPlugin,
deviceId,
importPlugin,
} = props;
const { plugins, showPluginMenu, removePlugin, showAddPlugin, importPlugin } =
props;

const pluginSlots = useMemo(() => {
return plugins.map((x) => {
return (
<PluginSlot
key={`plugin${x}`}
pluginId={x}
selectedDevice={deviceId}
removePlugin={removePlugin}
importPlugin={importPlugin}
/>
);
});
}, [plugins, removePlugin, deviceId, importPlugin]);
}, [plugins, removePlugin, importPlugin]);

return (
<div className="plugin-subpanel">
Expand Down
11 changes: 0 additions & 11 deletions src/shared/hardware-config/input-config/switch-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { byteToStatusString } from '@shared/midi-util';
import { SwitchDriver } from '../../driver-types/input-drivers/switch-driver';
import { msgEquals, msgIdentityEquals } from '../../util';
import { BaseInputConfig, InputDefaults, InputDTO } from './base-input-config';

export interface SwitchDTO extends InputDTO {
Expand Down Expand Up @@ -47,16 +46,6 @@ export class SwitchConfig extends BaseInputConfig<SwitchDTO, SwitchDriver> {
// noop, for now
}

public isOriginator(msg: NumberArrayWithStatus): boolean {
for (let i = 0; i < this.driver.steps.length; i++) {
if (msgEquals(msg, this.driver.steps[i])) {
return true;
}
}

return false;
}

public applyDTO(dto: SwitchDTO) {
this.bindings = dto.bindings;
}
Expand Down

0 comments on commit b12bdfa

Please sign in to comment.