mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix pick paths import type error and simplify signature
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
bae2aa0884
commit
a81873fe52
3 files changed
+14
-18
No files matched your search
+9
-6
@@ -4,18 +4,21 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { FileFilter } from "electron";
|
||||
import { requestOpenFilePickingDialog } from "../../../../../../../renderer/ipc";
|
||||
import openPathPickingDialogInjectable from "../../../../../../path-picking-dialog/renderer/pick-paths.injectable";
|
||||
|
||||
const getFilePathsInjectable = getInjectable({
|
||||
id: "get-file-paths",
|
||||
|
||||
instantiate: () => async (fileFilter: FileFilter) =>
|
||||
await requestOpenFilePickingDialog({
|
||||
instantiate: (di) => {
|
||||
const openPathPickingDialog = di.inject(openPathPickingDialogInjectable);
|
||||
|
||||
return async (fileFilter: FileFilter) => await openPathPickingDialog({
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
message: `Select file`,
|
||||
buttonLabel: `Use file`,
|
||||
message: "Select file",
|
||||
buttonLabel: "Use file",
|
||||
filters: [fileFilter, { name: "Any", extensions: ["*"] }],
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
@@ -15,11 +15,8 @@ const openPathPickingDialogInjectable = getInjectable({
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
|
||||
return async (options) => {
|
||||
const { onPick, onCancel, label, ...dialogOptions } = options;
|
||||
const response = await requestFromChannel(openPathPickingDialogChannel, {
|
||||
message: label,
|
||||
...dialogOptions,
|
||||
});
|
||||
const { onPick, onCancel, ...dialogOptions } = options;
|
||||
const response = await requestFromChannel(openPathPickingDialogChannel, dialogOptions);
|
||||
|
||||
if (response.canceled) {
|
||||
await onCancel?.();
|
||||
|
||||
Reference in new issue
Block a user