mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
chore: minor fixes
This commit is contained in:
parent
46a01711e9
commit
0da52bee9e
3 changed files with 22 additions and 24 deletions
|
|
@ -20,9 +20,9 @@ import { SizeObserver } from './SizeObserver'
|
|||
const VisibleNodesContext = React.createContext<VisibleNodes | null>(null)
|
||||
|
||||
const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplorer(props) {
|
||||
const { visibleNodes, freeze, onNodeClick, searchKey } = props
|
||||
const { state, visibleNodes, freeze, onNodeClick, searchKey } = props
|
||||
const {
|
||||
val: { access_token: accessToken, compressSingletonFolder },
|
||||
val: { compressSingletonFolder },
|
||||
} = useConfigs()
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
@ -32,8 +32,8 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
|
||||
React.useEffect(() => {
|
||||
const { setUpTree, treeRoot, metaData } = props
|
||||
setUpTree({ treeRoot, metaData, compressSingletonFolder, accessToken })
|
||||
}, [props.setUpTree, props.treeRoot, compressSingletonFolder, accessToken])
|
||||
setUpTree({ treeRoot, metaData, compressSingletonFolder })
|
||||
}, [props.setUpTree, props.treeRoot, compressSingletonFolder])
|
||||
|
||||
React.useEffect(() => {
|
||||
const { execAfterRender } = props
|
||||
|
|
@ -69,8 +69,7 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
[renderActions, onNodeClick, searchKey],
|
||||
)
|
||||
|
||||
const renderFiles = React.useCallback(
|
||||
({ nodes, focusedNode }: VisibleNodes) => {
|
||||
function renderFiles({ nodes, focusedNode }: VisibleNodes) {
|
||||
const inSearch = searchKey !== ''
|
||||
if (inSearch && nodes.length === 0) {
|
||||
return (
|
||||
|
|
@ -94,9 +93,7 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
)}
|
||||
</SizeObserver>
|
||||
)
|
||||
},
|
||||
[searchKey, ListView, renderNode],
|
||||
)
|
||||
}
|
||||
|
||||
const revealNode = React.useCallback(function revealNode(
|
||||
goTo: (path: string[]) => void,
|
||||
|
|
@ -118,8 +115,15 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
onKeyDown={props.handleKeyDown}
|
||||
onClick={freeze ? props.toggleShowSettings : undefined}
|
||||
>
|
||||
{props.stateText ? (
|
||||
<LoadingIndicator text={props.stateText} />
|
||||
{state !== 'done' ? (
|
||||
<LoadingIndicator
|
||||
text={
|
||||
{
|
||||
pulling: 'Fetching File List...',
|
||||
rendering: 'Rendering File List...',
|
||||
}[state]
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
visibleNodes && (
|
||||
<>
|
||||
|
|
@ -139,6 +143,7 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
|
||||
RawFileExplorer.defaultProps = {
|
||||
freeze: false,
|
||||
state: 'pulling',
|
||||
searchKey: '',
|
||||
visibleNodes: null,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ $minimal-z-index: max($github-header-z-index, $github-pull-request-float-header-
|
|||
&-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 2px;
|
||||
|
||||
.octicon {
|
||||
width: 20px;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export type Props = {
|
|||
}
|
||||
|
||||
export type ConnectorState = {
|
||||
stateText: string
|
||||
state: 'pulling' | 'rendering' | 'done'
|
||||
visibleNodes: VisibleNodes | null
|
||||
searchKey: string
|
||||
searched: boolean // derived state from searchKey, = !!searchKey
|
||||
|
|
@ -57,14 +57,13 @@ let visibleNodesGenerator: VisibleNodesGenerator
|
|||
|
||||
type BoundMethodCreator<Args extends any[] = []> = MethodCreator<Props, ConnectorState, Args>
|
||||
|
||||
export const init: BoundMethodCreator = dispatch => () =>
|
||||
dispatch.call(setStateText, 'Fetching File List...')
|
||||
export const init: BoundMethodCreator = dispatch => () => dispatch.set({ state: 'pulling' })
|
||||
|
||||
export const setUpTree: BoundMethodCreator<[
|
||||
Pick<Props, 'treeRoot' | 'metaData' | 'accessToken'> & Pick<Config, 'compressSingletonFolder'>,
|
||||
Pick<Props, 'treeRoot' | 'metaData'> & Pick<Config, 'compressSingletonFolder'>,
|
||||
]> = dispatch => async ({ treeRoot, metaData, compressSingletonFolder }) => {
|
||||
if (!treeRoot) return
|
||||
dispatch.call(setStateText, 'Rendering File List...')
|
||||
dispatch.set({ state: 'rendering' })
|
||||
|
||||
visibleNodesGenerator = new VisibleNodesGenerator(treeRoot, {
|
||||
compress: compressSingletonFolder,
|
||||
|
|
@ -73,7 +72,7 @@ export const setUpTree: BoundMethodCreator<[
|
|||
visibleNodesGenerator.init()
|
||||
|
||||
tasksAfterRender.push(DOMHelper.focusSearchInput)
|
||||
dispatch.call(setStateText, '')
|
||||
dispatch.set({ state: 'done' })
|
||||
const targetPath = platform.getCurrentPath(metaData.branchName)
|
||||
if (targetPath) dispatch.call(goTo, targetPath)
|
||||
}
|
||||
|
|
@ -85,13 +84,6 @@ export const execAfterRender: BoundMethodCreator = dispatch => () => {
|
|||
tasksAfterRender.length = 0
|
||||
}
|
||||
|
||||
export const setStateText: BoundMethodCreator<[ConnectorState['stateText']]> = dispatch => (
|
||||
text: string,
|
||||
) =>
|
||||
dispatch.set({
|
||||
stateText: text,
|
||||
})
|
||||
|
||||
export const handleKeyDown: BoundMethodCreator<[React.KeyboardEvent]> = dispatch => event => {
|
||||
const [{ searched, visibleNodes }, { loadWithPJAX }] = dispatch.get()
|
||||
if (!visibleNodes) return
|
||||
|
|
|
|||
Loading…
Reference in a new issue