mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fix update
This commit is contained in:
@@ -21,7 +21,6 @@ type Hunk = {
|
||||
tree: File;
|
||||
loading: boolean;
|
||||
error: Error;
|
||||
updateSources: (hunk: number) => void;
|
||||
};
|
||||
|
||||
type Props = WithTranslation & {
|
||||
@@ -34,6 +33,7 @@ type Props = WithTranslation & {
|
||||
|
||||
// dispatch props
|
||||
fetchSources: (repository: Repository, revision: string, path: string, hunk: number) => void;
|
||||
updateSources: (hunk: number) => () => void;
|
||||
|
||||
// context props
|
||||
match: any;
|
||||
@@ -67,10 +67,10 @@ class FileTree extends React.Component<Props, State> {
|
||||
|
||||
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>): void {
|
||||
if (prevState.stoppableUpdateHandler === this.state.stoppableUpdateHandler) {
|
||||
const { hunks } = this.props;
|
||||
const { hunks, updateSources } = this.props;
|
||||
hunks?.forEach((hunk, index) => {
|
||||
if (hunk.tree?._embedded?.children && hunk.tree._embedded.children.find(c => c.partialResult)) {
|
||||
const stoppableUpdateHandler = setTimeout(hunk.updateSources, 3000);
|
||||
const stoppableUpdateHandler = setTimeout(updateSources(index), 3000);
|
||||
this.setState(prevState => {
|
||||
return {
|
||||
stoppableUpdateHandler: [...prevState.stoppableUpdateHandler, stoppableUpdateHandler]
|
||||
@@ -177,7 +177,7 @@ const mapDispatchToProps = (dispatch: any, ownProps: Props) => {
|
||||
const { repository, revision, path } = ownProps;
|
||||
|
||||
return {
|
||||
updateSources: (hunk: number) => dispatch(fetchSources(repository, revision, path, false, hunk)),
|
||||
updateSources: (hunk: number) => () => dispatch(fetchSources(repository, revision, path, false, hunk)),
|
||||
fetchSources: (repository: Repository, revision: string, path: string, hunk: number) => {
|
||||
dispatch(fetchSources(repository, revision, path, true, hunk));
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ export function fetchSources(repository: Repository, revision: string, path: str
|
||||
}
|
||||
|
||||
let offset = 0;
|
||||
const hunkCount = getHunkCount(state, repository, revision, path);
|
||||
for (let i = 0; i < hunkCount; ++i) {
|
||||
for (let i = 0; i < hunk; ++i) {
|
||||
const sources = getSources(state, repository, revision, path, i);
|
||||
if (sources?._embedded.children) {
|
||||
offset += sources._embedded.children.length;
|
||||
@@ -136,7 +135,6 @@ export default function reducer(
|
||||
} else if (action.itemId && action.type === FETCH_UPDATES_PENDING) {
|
||||
return {
|
||||
...state,
|
||||
[action.itemId + "hunkCount"]: action.payload.hunk + 1,
|
||||
[action.itemId + action.payload.hunk]: {
|
||||
sources: action.payload.sources,
|
||||
updatePending: true,
|
||||
|
||||
Reference in New Issue
Block a user