Skip to content

Commit bd7e758

Browse files
committed
use debounce on onchange
1 parent c522710 commit bd7e758

File tree

3 files changed

+3
-338
lines changed

3 files changed

+3
-338
lines changed

packages/insomnia/src/ui/components/.client/codemirror/merge-editor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { MergeView } from 'codemirror/addon/merge/merge';
66
import { DiffMatchPatch, DiffOp } from 'diff-match-patch-ts';
77
import React, { useEffect, useRef } from 'react';
88

9+
import { debounce } from '~/common/misc';
910
import { useIsLightTheme } from '~/ui/hooks/theme';
1011

1112
// these global variables are required by codemirror merge addon
@@ -41,9 +42,9 @@ export const MergeEditor = ({ leftContent, rightContent, centerContent, onChange
4142
const isLightThemeRef = useRef(isLightTheme);
4243

4344
useEffect(() => {
44-
const onChange = (instance: CodeMirror.Editor) => {
45+
const onChange = debounce((instance: CodeMirror.Editor) => {
4546
onChangeRef.current(instance.getDoc().getValue());
46-
};
47+
}, 300);
4748
if (!divRef.current) {
4849
return;
4950
}

packages/insomnia/src/ui/components/dropdowns/git-project-sync-dropdown.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
} from 'react-aria-components';
1515
import { useParams, useRevalidator } from 'react-router';
1616
import * as reactUse from 'react-use';
17-
import { parse, stringify } from 'yaml';
1817

1918
import { useGitProjectCheckoutBranchActionFetcher } from '~/routes/git.branch.checkout';
2019
import { useGitProjectFetchActionFetcher } from '~/routes/git.fetch';
@@ -36,7 +35,6 @@ import { GitPullRequiredModal } from '../modals/git-pull-required-modal';
3635
import { GitProjectRepositorySettingsModal } from '../modals/git-repository-settings-modal';
3736
import { SyncMergeModal } from '../modals/sync-merge-modal';
3837
import { showToast } from '../toast-notification';
39-
import resultSample from './merge-result-sample.json';
4038
interface Props {
4139
gitRepository?: GitRepository;
4240
}
@@ -479,21 +477,6 @@ export const GitProjectSyncDropdown: FC<Props> = ({ gitRepository }) => {
479477

480478
const pendingChangesCount = status?.localChanges ?? 0;
481479

482-
useEffect(() => {
483-
for (const conflict of resultSample.conflicts) {
484-
if (typeof conflict.mergeResult !== 'string') {
485-
conflict.mergeResult = stringify(conflict.mergeResult);
486-
}
487-
}
488-
showModal(SyncMergeModal, {
489-
editorType: 'merge',
490-
conflicts: resultSample.conflicts,
491-
labels: resultSample.labels,
492-
onResolveAll: (conflicts: MergeConflict[]) => {},
493-
onCancelUnresolved: () => {},
494-
});
495-
}, []);
496-
497480
return (
498481
<>
499482
{operationError && (

packages/insomnia/src/ui/components/dropdowns/merge-result-sample.json

Lines changed: 0 additions & 319 deletions
This file was deleted.

0 commit comments

Comments
 (0)