Keep workspace editor target selection
This commit is contained in:
@@ -19,6 +19,9 @@ export function resolvePreferredEditorId(
|
||||
availableEditorIds: readonly EditorTargetId[],
|
||||
storedEditorId: EditorTargetId | null | undefined,
|
||||
): EditorTargetId | null {
|
||||
if (storedEditorId === undefined) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
storedEditorId &&
|
||||
availableEditorIds.some((availableEditorId) => availableEditorId === storedEditorId)
|
||||
@@ -50,7 +53,7 @@ export function usePreferredEditor() {
|
||||
);
|
||||
|
||||
return {
|
||||
preferredEditorId: data ?? null,
|
||||
preferredEditorId: isPending ? undefined : (data ?? null),
|
||||
isLoading: isPending,
|
||||
updatePreferredEditor,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type ReactElement, useCallback, useEffect, useMemo } from "react";
|
||||
import { type ReactElement, useCallback, useMemo } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Pressable,
|
||||
@@ -178,13 +178,6 @@ export function WorkspaceOpenInEditorButton({
|
||||
);
|
||||
const primaryOption = targets.find((target) => target.id === effectivePreferredEditorId) ?? null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!effectivePreferredEditorId || effectivePreferredEditorId === preferredEditorId) {
|
||||
return;
|
||||
}
|
||||
void updatePreferredEditor(effectivePreferredEditorId).catch(() => undefined);
|
||||
}, [effectivePreferredEditorId, preferredEditorId, updatePreferredEditor]);
|
||||
|
||||
const openMutation = useMutation({
|
||||
mutationFn: (target: OpenTarget) => Promise.resolve(target.onOpen()),
|
||||
onError: (error: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user