Skip to content

Commit

Permalink
jotai: drop jotai from variable names
Browse files Browse the repository at this point in the history
Summary:
Those names are useful when we still use Recoil. Now everything is in Jotai
let's rename them to drop the jotai suffix.

Reviewed By: evangrayk

Differential Revision: D53784068

fbshipit-source-id: 1a5f7cbd947e2b9fabcfde3694188b7b3fee906c
  • Loading branch information
quark-zju authored and facebook-github-bot committed Feb 15, 2024
1 parent e932310 commit 27b776e
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 122 deletions.
8 changes: 4 additions & 4 deletions addons/isl/src/CommandHistoryAndProgress.tsx
Expand Up @@ -14,8 +14,8 @@ import {Tooltip} from './Tooltip';
import {codeReviewProvider} from './codeReview/CodeReviewInfo';
import {T, t} from './i18n';
import {
operationListJotai,
queuedOperationsJotai,
operationList,
queuedOperations,
repositoryInfo,
useAbortRunningOperation,
} from './serverAPIState';
Expand Down Expand Up @@ -87,8 +87,8 @@ function OperationDescription(props: {
}

export function CommandHistoryAndProgress() {
const list = useAtomValue(operationListJotai);
const queued = useAtomValue(queuedOperationsJotai);
const list = useAtomValue(operationList);
const queued = useAtomValue(queuedOperations);
const abortRunningOperation = useAbortRunningOperation();

const info = useAtomValue(repositoryInfo);
Expand Down
6 changes: 3 additions & 3 deletions addons/isl/src/Commit.tsx
Expand Up @@ -45,7 +45,7 @@ import {
isFetchingUncommittedChanges,
latestDag,
latestUncommittedChanges,
operationBeingPreviewedJotai,
operationBeingPreviewed,
useRunOperation,
useRunPreviewedOperation,
} from './serverAPIState';
Expand Down Expand Up @@ -260,7 +260,7 @@ export const Commit = memo(
label: hasChildren ? <T>Hide Commit and Descendants</T> : <T>Hide Commit</T>,
onClick: () =>
writeAtom(
operationBeingPreviewedJotai,
operationBeingPreviewed,
new HideOperation(latestSuccessorUnlessExplicitlyObsolete(commit)),
),
});
Expand Down Expand Up @@ -672,7 +672,7 @@ function DraggableCommit({
commit.remoteBookmarks.length > 0
? succeedableRevset(commit.remoteBookmarks[0])
: latestSuccessorUnlessExplicitlyObsolete(commit);
writeAtom(operationBeingPreviewedJotai, op => {
writeAtom(operationBeingPreviewed, op => {
const newRebase = new RebaseOperation(
latestSuccessorUnlessExplicitlyObsolete(beingDragged),
destination,
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/CommitTreeList.tsx
Expand Up @@ -32,7 +32,7 @@ import {
commitFetchError,
commitsShownRange,
isFetchingAdditionalCommits,
latestUncommittedChangesDataJotai,
latestUncommittedChangesData,
useRunOperation,
} from './serverAPIState';
import {MaybeEditStackModal} from './stackEdit/ui/EditStackModal';
Expand Down Expand Up @@ -181,7 +181,7 @@ export function CommitTreeList() {
// so we don't miss the first returned uncommitted changes message.
// TODO: This is a little ugly, is there a better way to tell recoil to start the subscription immediately?
// Or should we queue/cache messages?
useAtomValue(latestUncommittedChangesDataJotai);
useAtomValue(latestUncommittedChangesData);
const renderer = useAtomValue(configGraphRenderer);

useMarkOperationsCompleted();
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/StackActions.tsx
Expand Up @@ -20,7 +20,7 @@ import {SyncStatus, syncStatusAtom} from './codeReview/syncStatus';
import {T, t} from './i18n';
import {IconStack} from './icons/IconStack';
import {dagWithPreviews} from './previews';
import {useRunOperation, latestUncommittedChangesDataJotai} from './serverAPIState';
import {useRunOperation, latestUncommittedChangesData} from './serverAPIState';
import {useConfirmUnsavedEditsBeforeSplit} from './stackEdit/ui/ConfirmUnsavedEditsBeforeSplit';
import {StackEditIcon} from './stackEdit/ui/StackEditIcon';
import {editingStackIntentionHashes, loadingStackState} from './stackEdit/ui/stackEditState';
Expand Down Expand Up @@ -249,7 +249,7 @@ export function StackActions({hash}: {hash: Hash}): React.ReactElement | null {
}

function StackEditButton({info}: {info: DagCommitInfo}): React.ReactElement | null {
const uncommitted = useAtomValue(latestUncommittedChangesDataJotai);
const uncommitted = useAtomValue(latestUncommittedChangesData);
const dag = useAtomValue(dagWithPreviews);
const [[, stackHashes], setStackIntentionHashes] = useAtom(editingStackIntentionHashes);
const loadingState = useAtomValue(loadingStackState);
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/UncommittedChanges.tsx
Expand Up @@ -59,7 +59,7 @@ import {
import {selectedCommits} from './selection';
import {
latestHeadCommit,
operationListJotai,
operationList,
uncommittedChangesFetchError,
useRunOperation,
} from './serverAPIState';
Expand Down Expand Up @@ -745,7 +745,7 @@ function MergeConflictButtons({
// But only if the abort/continue command succeeded.
// TODO: is this reliable? Is it possible to get stuck with buttons disabled because
// we think it's still running?
const lastRunOperation = useAtomValue(operationListJotai).currentOperation;
const lastRunOperation = useAtomValue(operationList).currentOperation;
const justFinishedContinue =
lastRunOperation?.operation instanceof ContinueOperation && lastRunOperation.exitCode === 0;
const justFinishedAbort =
Expand Down
8 changes: 4 additions & 4 deletions addons/isl/src/debug/DebugToolsMenu.tsx
Expand Up @@ -23,8 +23,8 @@ import {dagWithPreviews} from '../previews';
import {RelativeDate} from '../relativeDate';
import {
latestCommitsData,
latestUncommittedChangesDataJotai,
mergeConflictsJotai,
latestUncommittedChangesData,
mergeConflicts,
repositoryInfo,
} from '../serverAPIState';
import {ComponentExplorerButton} from './ComponentExplorer';
Expand Down Expand Up @@ -115,9 +115,9 @@ function ServerClientMessageLogging() {
}

function DebugPerfInfo() {
const latestStatus = useAtomValue(latestUncommittedChangesDataJotai);
const latestStatus = useAtomValue(latestUncommittedChangesData);
const latestLog = useAtomValue(latestCommitsData);
const latestConflicts = useAtomValue(mergeConflictsJotai);
const latestConflicts = useAtomValue(mergeConflicts);
const heartbeat = useHeartbeat();
const repoInfo = useAtomValue(repositoryInfo);
let commandName = 'sl';
Expand Down
24 changes: 12 additions & 12 deletions addons/isl/src/debug/getInterestingAtoms.ts
Expand Up @@ -14,13 +14,13 @@ import {readAtom} from '../jotaiUtils';
import {uncommittedSelection} from '../partialSelection';
import {selectedCommits} from '../selection';
import {
operationBeingPreviewedJotai,
jotaiRepositoryData,
operationBeingPreviewed,
repositoryData,
latestCommitsData,
latestUncommittedChangesDataJotai,
mergeConflictsJotai,
operationListJotai,
queuedOperationsJotai,
latestUncommittedChangesData,
mergeConflicts,
operationList,
queuedOperations,
} from '../serverAPIState';
import {SelfUpdate} from 'shared/immutableExt';

Expand All @@ -31,14 +31,14 @@ function listInterestingAtoms(): Array<Atom<unknown>> {
return [
allDiffSummaries,
codeReviewProvider,
jotaiRepositoryData,
repositoryData,
latestCommitsData,
latestSuccessorsMapAtom,
latestUncommittedChangesDataJotai,
mergeConflictsJotai,
operationBeingPreviewedJotai,
operationListJotai,
queuedOperationsJotai,
latestUncommittedChangesData,
mergeConflicts,
operationBeingPreviewed,
operationList,
queuedOperations,
selectedCommits,
uncommittedSelection,
// This is an atomFamily. Need extra work to read it.
Expand Down
6 changes: 3 additions & 3 deletions addons/isl/src/fold.tsx
Expand Up @@ -25,7 +25,7 @@ import {
} from './operations/FoldOperation';
import {type Dag, dagWithPreviews} from './previews';
import {selectedCommits} from './selection';
import {operationBeingPreviewedJotai, useRunPreviewedOperation} from './serverAPIState';
import {operationBeingPreviewed, useRunPreviewedOperation} from './serverAPIState';
import {firstOfIterable} from './utils';
import {VSCodeButton} from '@vscode/webview-ui-toolkit/react';
import {atom, useAtomValue} from 'jotai';
Expand Down Expand Up @@ -87,7 +87,7 @@ export function FoldButton({commit}: {commit?: CommitInfo}) {
foldable.map(commit => parseCommitMessageFields(schema, commit.title, commit.description)),
);
const message = commitMessageFieldsToString(schema, messageFields);
writeAtom(operationBeingPreviewedJotai, new FoldOperation(foldable, message));
writeAtom(operationBeingPreviewed, new FoldOperation(foldable, message));
writeAtom(selectedCommits, new Set([getFoldRangeCommitHash(foldable, /* isPreview */ true)]));
}, [foldable]);
if (foldable == null || (commit != null && foldable?.[0]?.hash !== commit.hash)) {
Expand All @@ -108,7 +108,7 @@ export function FoldButton({commit}: {commit?: CommitInfo}) {
* This allows running the fold operation to use the newly typed message.
*/
export function updateFoldedMessageWithEditedMessage(): FoldOperation | undefined {
const beingPreviewed = readAtom(operationBeingPreviewedJotai);
const beingPreviewed = readAtom(operationBeingPreviewed);
if (beingPreviewed != null && beingPreviewed instanceof FoldOperation) {
const range = beingPreviewed.getFoldRange();
const combinedHash = getFoldRangeCommitHash(range, /* isPreview */ true);
Expand Down
40 changes: 20 additions & 20 deletions addons/isl/src/previews.ts
Expand Up @@ -19,12 +19,12 @@ import {
latestUncommittedChanges,
latestCommits,
latestDag,
operationBeingPreviewedJotai,
operationBeingPreviewed,
latestHeadCommit,
queuedOperationsJotai,
operationListJotai,
mergeConflictsJotai,
latestUncommittedChangesDataJotai,
queuedOperations,
operationList,
mergeConflicts,
latestUncommittedChangesData,
latestCommitsData,
} from './serverAPIState';
import {atom, useAtom, useAtomValue} from 'jotai';
Expand Down Expand Up @@ -207,17 +207,17 @@ function applyPreviewsToMergeConflicts(
}

export const uncommittedChangesWithPreviews = atom<Array<ChangedFile>>(get => {
const list = get(operationListJotai);
const queued = get(queuedOperationsJotai);
const list = get(operationList);
const queued = get(queuedOperations);
const uncommittedChanges = get(latestUncommittedChanges);

return applyPreviewsToChangedFiles(uncommittedChanges, list, queued);
});

export const optimisticMergeConflicts = atom(get => {
const list = get(operationListJotai);
const queued = get(queuedOperationsJotai);
const conflicts = get(mergeConflictsJotai);
const list = get(operationList);
const queued = get(queuedOperations);
const conflicts = get(mergeConflicts);
if (conflicts?.files == null) {
return conflicts;
}
Expand Down Expand Up @@ -246,11 +246,11 @@ export type {Dag};

export const dagWithPreviews = atom(get => {
const originalDag = get(latestDag);
const list = get(operationListJotai);
const queued = get(queuedOperationsJotai);
const list = get(operationList);
const queued = get(queuedOperations);
const currentOperation = list.currentOperation;
const history = list.operationHistory;
const currentPreview = get(operationBeingPreviewedJotai);
const currentPreview = get(operationBeingPreviewed);
let dag = originalDag;
for (const op of optimisticOperations({history, queued, currentOperation})) {
dag = op.optimisticDag(dag);
Expand Down Expand Up @@ -322,11 +322,11 @@ function* optimisticOperations(props: {
export function useMarkOperationsCompleted(): void {
const fetchedCommits = useAtomValue(latestCommitsData);
const commits = useAtomValue(latestCommits);
const uncommittedChanges = useAtomValue(latestUncommittedChangesDataJotai);
const conflicts = useAtomValue(mergeConflictsJotai);
const uncommittedChanges = useAtomValue(latestUncommittedChangesData);
const conflicts = useAtomValue(mergeConflicts);
const successorMap = useAtomValue(latestSuccessorsMapAtom);

const [list, setOperationList] = useAtom(operationListJotai);
const [list, setOperationList] = useAtom(operationList);

// Mark operations as completed when their optimistic applier is no longer needed
// n.b. this must be a useEffect since React doesn't like setCurrentOperation getting called during render
Expand Down Expand Up @@ -480,8 +480,8 @@ type Class<T> = new (...args: any[]) => T;
export function useIsOperationRunningOrQueued(
cls: Class<Operation>,
): 'running' | 'queued' | undefined {
const list = useAtomValue(operationListJotai);
const queued = useAtomValue(queuedOperationsJotai);
const list = useAtomValue(operationList);
const queued = useAtomValue(queuedOperations);
if (list.currentOperation?.operation instanceof cls && list.currentOperation?.exitCode == null) {
return 'running';
} else if (queued.some(op => op instanceof cls)) {
Expand All @@ -491,8 +491,8 @@ export function useIsOperationRunningOrQueued(
}

export function useMostRecentPendingOperation(): Operation | undefined {
const list = useAtomValue(operationListJotai);
const queued = useAtomValue(queuedOperationsJotai);
const list = useAtomValue(operationList);
const queued = useAtomValue(queuedOperations);
if (queued.length > 0) {
return queued.at(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/selection.ts
Expand Up @@ -16,7 +16,7 @@ import {islDrawerState} from './drawerState';
import {atomFamilyWeak, readAtom, writeAtom} from './jotaiUtils';
import {HideOperation} from './operations/HideOperation';
import {dagWithPreviews} from './previews';
import {latestDag, operationBeingPreviewedJotai} from './serverAPIState';
import {latestDag, operationBeingPreviewed} from './serverAPIState';
import {firstOfIterable, registerCleanup} from './utils';
import {atom, useAtomValue} from 'jotai';
import {useCallback} from 'react';
Expand Down Expand Up @@ -287,7 +287,7 @@ export function useBackspaceToHideSelected(): void {
}

writeAtom(
operationBeingPreviewedJotai,
operationBeingPreviewed,
new HideOperation(latestSuccessorUnlessExplicitlyObsolete(commitToHide)),
);
}, []);
Expand Down

0 comments on commit 27b776e

Please sign in to comment.