-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby): Convert redux/actions/add-page-dependency to TS (#22062)
* Convert add-page-dependency to TS * Only add types * Resolve discussions
- Loading branch information
1 parent
4149c52
commit 13f58b2
Showing
11 changed files
with
58 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { store } from "../" | ||
|
||
import { createPageDependency as internalCreatePageDependency } from "./internal" | ||
|
||
export const createPageDependency = ({ | ||
path, | ||
nodeId, | ||
connection, | ||
}: { | ||
path: string | ||
nodeId: string | ||
connection: string | ||
}): void => { | ||
const { componentDataDependencies } = store.getState() | ||
|
||
// Check that the dependencies aren't already recorded so we | ||
// can avoid creating lots of very noisy actions. | ||
let nodeDependencyExists = false | ||
let connectionDependencyExists = false | ||
if (!nodeId) { | ||
nodeDependencyExists = true | ||
} | ||
if ( | ||
nodeId && | ||
componentDataDependencies.nodes.has(nodeId) && | ||
componentDataDependencies.nodes.get(nodeId).has(path) | ||
) { | ||
nodeDependencyExists = true | ||
} | ||
if (!connection) { | ||
connectionDependencyExists = true | ||
} | ||
if ( | ||
connection && | ||
componentDataDependencies.connections.has(connection) && | ||
componentDataDependencies.connections.get(connection).has(path) | ||
) { | ||
connectionDependencyExists = true | ||
} | ||
if (nodeDependencyExists && connectionDependencyExists) { | ||
return | ||
} | ||
|
||
// It's new, let's dispatch it | ||
store.dispatch(internalCreatePageDependency({ path, nodeId, connection })) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters