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:
parent
6d0eed2628
commit
a9d1a5af54
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user