From ae934e4ff42d43b40701eef33f32628159b6a076 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Sat, 20 Jul 2024 12:02:17 +0200 Subject: [PATCH] reset branch diff --- libs/remix-ui/git/src/lib/gitactions.ts | 7 +++++-- libs/remix-ui/git/src/state/actions.ts | 1 + libs/remix-ui/git/src/state/gitpayload.ts | 6 ++++++ libs/remix-ui/git/src/state/gitreducer.tsx | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 2982086113..b2757dee02 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -1,6 +1,6 @@ import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import React from "react"; -import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead, setStoragePayload } from "../state/gitpayload"; +import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead, setStoragePayload, resetBranchDifferences } from "../state/gitpayload"; import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails, storage } from '../types'; import { removeSlash } from "../utils"; import { disableCallBacks, enableCallBacks } from "./listeners"; @@ -784,7 +784,10 @@ export const getBranchDifferences = async (branch: branch, remote: remote, state remote = state.remotes[0] } } - if (!remote) return + if (!remote) { + dispatch(resetBranchDifferences()) + return + } try { const branchDifference: branchDifference = await plugin.call('dgitApi', 'compareBranches', { diff --git a/libs/remix-ui/git/src/state/actions.ts b/libs/remix-ui/git/src/state/actions.ts index 61cdd628c5..6aa8b95bff 100644 --- a/libs/remix-ui/git/src/state/actions.ts +++ b/libs/remix-ui/git/src/state/actions.ts @@ -34,6 +34,7 @@ export interface ActionPayloadTypes { remote: remote branchDifference: branchDifference } + RESET_BRANCH_DIFFERENCES: null SET_GITHUB_USER: GitHubUser SET_RATE_LIMIT: any SET_GITHUB_ACCESS_TOKEN: string diff --git a/libs/remix-ui/git/src/state/gitpayload.ts b/libs/remix-ui/git/src/state/gitpayload.ts index 1211775280..1c93a40a90 100644 --- a/libs/remix-ui/git/src/state/gitpayload.ts +++ b/libs/remix-ui/git/src/state/gitpayload.ts @@ -192,6 +192,12 @@ export const setBranchDifferences = ({ } } +export const resetBranchDifferences = () => { + return { + type: 'RESET_BRANCH_DIFFERENCES' + } +} + export const setGItHubToken = (token: string) => { return { type: 'SET_GITHUB_ACCESS_TOKEN', diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx index df3ed0a7a8..592360a94a 100644 --- a/libs/remix-ui/git/src/state/gitreducer.tsx +++ b/libs/remix-ui/git/src/state/gitreducer.tsx @@ -156,6 +156,12 @@ export const gitReducer = (state: gitState = defaultGitState, action: Actions): branchDifferences: { ...state.branchDifferences } } + case 'RESET_BRANCH_DIFFERENCES': + return { + ...state, + branchDifferences: {} + } + case 'SET_GITHUB_USER': return { ...state,