Allow loading from directories other than Data

Enables users to upload MO2 mod directory.

Also use updatePlugin instead of addPlugin to prevent duplicate plugins.
This commit is contained in:
Tyler Hallada 2022-03-19 17:42:24 -04:00
parent 6d0eed2628
commit a9d1a5af54
3 changed files with 4 additions and 7 deletions

View File

@ -30,10 +30,7 @@ export const DropZone: React.FC<Props> = ({ children, workerPool }) => {
}
if (next.value.kind === "file" && isPluginPath(next.value.name)) {
plugins.push(next.value);
} else if (
next.value.kind === "directory" &&
next.value.name === "Data"
) {
} else if (next.value.kind === "directory") {
plugins.push(...(await findPluginsInDirHandle(next.value)));
}
}

View File

@ -12,7 +12,7 @@ export const excludedPlugins = [
export const isPluginPath = (path: string) => {
if (
/^((Skyrim Special Edition|Skyrim|SkyrimVR)\/)?(Data\/)?[^/\\]*\.es[mpl]$/i.test(path)
/^.*\.es[mpl]$/i.test(path)
) {
return true;
}

View File

@ -152,7 +152,7 @@ export const pluginsSlice = createSlice({
},
})
export const { addPlugin, setPlugins, setPending, decrementPending, togglePlugin, enableAllPlugins, disableAllPlugins, setFetchedPlugin, clearPlugins } = pluginsSlice.actions
export const { addPlugin, updatePlugin, setPlugins, setPending, decrementPending, togglePlugin, enableAllPlugins, disableAllPlugins, setFetchedPlugin, clearPlugins } = pluginsSlice.actions
export const selectPlugins = (state: AppState) => state.plugins
@ -183,7 +183,7 @@ export const applyLoadOrder = (): AppThunk => (dispatch, getState) => {
}
export const addPluginInOrder = (plugin: PluginFile): AppThunk => (dispatch) => {
dispatch(addPlugin(plugin));
dispatch(updatePlugin(plugin));
dispatch(applyLoadOrder());
}