Skip to content

Commit

Permalink
Fix the bug that diff content does not update
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweiprc committed Oct 31, 2024
1 parent c43bd1e commit bb2607d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
8 changes: 2 additions & 6 deletions packages/insomnia/src/sync/git/git-vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,9 @@ export class GitVCS {

throw new MergeConflictError('Need to solve merge conflicts first', {
conflicts: mergeConflicts,
/* labels: {
ours: currentLocalBranch,
theirs: remoteBranch,
}, */
labels: {
ours: localHeadCommitOid,
theirs: remoteHeadCommitOid,
ours: `${currentLocalBranch} ${localHeadCommitOid}`,
theirs: `${remoteBranch} ${remoteHeadCommitOid}`,
},
commitMessage: `Merge branch '${remoteBranch}' into ${currentLocalBranch}`,
commitParent: [localHeadCommitOid, remoteHeadCommitOid],
Expand Down
10 changes: 1 addition & 9 deletions packages/insomnia/src/ui/components/modals/git-log-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,14 @@ export const GitLogModal: FC<Props> = ({ onClose }) => {
<Icon icon="x" />
</Button>
</div>
<div className='rounded w-full border border-solid border-[--hl-sm] overflow-y-auto max-h-96'>
<div className='rounded w-full border border-solid border-[--hl-sm] select-none overflow-y-auto max-h-96'>
<Table
selectionMode='multiple'
defaultSelectedKeys="all"
aria-label='Modified objects'
className="border-separate border-spacing-0 w-full"
>
<TableHeader>
<Column isRowHeader className="sticky px-2 py-2 top-0 z-10 border-b border-[--hl-sm] bg-[--hl-xs] text-left text-xs font-semibold backdrop-blur backdrop-filter focus:outline-none">
Commit ID
</Column>
<Column isRowHeader className="sticky px-2 py-2 top-0 z-10 border-b border-[--hl-sm] bg-[--hl-xs] text-left text-xs font-semibold backdrop-blur backdrop-filter focus:outline-none">
Message
</Column>
Expand All @@ -91,11 +88,6 @@ export const GitLogModal: FC<Props> = ({ onClose }) => {
>
{item => (
<Row className="group focus:outline-none focus-within:bg-[--hl-xxs] transition-colors">
<Cell className="whitespace-nowrap text-sm font-medium border-b border-solid border-[--hl-sm] group-last-of-type:border-none focus:outline-none">
<span className='p-2'>
{item.id}
</span>
</Cell>
<Cell className="whitespace-nowrap text-sm font-medium border-b border-solid border-[--hl-sm] group-last-of-type:border-none focus:outline-none">
<span className='p-2'>
{item.commit.message}
Expand Down
34 changes: 14 additions & 20 deletions packages/insomnia/src/ui/components/modals/sync-merge-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Differ, Viewer } from 'json-diff-kit';
import React, { forwardRef, useImperativeHandle, useState } from 'react';
import React, { forwardRef, useCallback, useImperativeHandle, useState } from 'react';
import { Button, Dialog, Form, GridList, GridListItem, Heading, Modal, ModalOverlay, Radio, RadioGroup } from 'react-aria-components';

import type { MergeConflict } from '../../../sync/types';
Expand Down Expand Up @@ -33,25 +33,31 @@ export const SyncMergeModal = forwardRef<SyncMergeModalHandle>((_, ref) => {
labels: { ours: '', theirs: '' },
});

useImperativeHandle(ref, () => ({
hide: () => setState({
const reset = useCallback(() => {
setState({
conflicts: [],
isOpen: false,
labels: { ours: '', theirs: '' },
}),
});
setSelectedConflict(null);
}, []);

useImperativeHandle(ref, () => ({
hide: reset,
show: ({ conflicts, labels, handleDone }) => {
setState({
conflicts,
handleDone,
isOpen: true,
labels,
});
setSelectedConflict(conflicts?.[0] || null);

window.main.trackSegmentEvent({
event: SegmentEvent.syncConflictResolutionStart,
});
},
}), []);
}), [reset]);

const { conflicts, handleDone } = state;

Expand All @@ -61,11 +67,7 @@ export const SyncMergeModal = forwardRef<SyncMergeModalHandle>((_, ref) => {
<ModalOverlay
isOpen={state.isOpen}
onOpenChange={isOpen => {
!isOpen && setState({
conflicts: [],
isOpen: false,
labels: { ours: '', theirs: '' },
});
!isOpen && reset();

!isOpen && handleDone?.();
}}
Expand All @@ -74,11 +76,7 @@ export const SyncMergeModal = forwardRef<SyncMergeModalHandle>((_, ref) => {
>
<Modal
onOpenChange={isOpen => {
!isOpen && setState({
conflicts: [],
isOpen: false,
labels: { ours: '', theirs: '' },
});
!isOpen && reset();

!isOpen && handleDone?.();
}}
Expand Down Expand Up @@ -116,11 +114,7 @@ export const SyncMergeModal = forwardRef<SyncMergeModalHandle>((_, ref) => {
});
}

setState({
conflicts: [],
isOpen: false,
labels: { ours: '', theirs: '' },
});
reset();
}}
>
<div className='grid [grid-template-columns:300px_1fr] h-full overflow-hidden divide-x divide-solid divide-[--hl-md] gap-2'>
Expand Down

0 comments on commit bb2607d

Please sign in to comment.