feat: Enhance protocol status handling and repair functionality in About and SSOLogin components
This commit is contained in:
@@ -19,41 +19,31 @@ export function About({ requestClose }: AboutProps) {
|
||||
const [protocolBusy, setProtocolBusy] = useState<boolean>(false);
|
||||
|
||||
const formatProtocolStatus = useCallback((data: {
|
||||
scheme: string;
|
||||
platform: string;
|
||||
primaryScheme: string;
|
||||
schemes: Record<string, {
|
||||
isDefault: boolean;
|
||||
registerCall: boolean;
|
||||
error: string | null;
|
||||
}>;
|
||||
windows: null | Record<string, {
|
||||
isDefault: boolean;
|
||||
registerCall: boolean;
|
||||
error: string | null;
|
||||
windows: null | {
|
||||
userChoiceProgId: string | null;
|
||||
userChoiceCommand: string | null;
|
||||
hkcuCommand: string | null;
|
||||
hklmCommand: string | null;
|
||||
}>;
|
||||
};
|
||||
}): string => {
|
||||
const { element } = data.schemes;
|
||||
const primary = data.schemes[data.primaryScheme];
|
||||
const primaryState = primary?.isDefault ? 'registered' : 'not registered';
|
||||
const elementState = element?.isDefault ? 'registered' : 'not registered';
|
||||
const primaryCall = primary?.registerCall ? 'ok' : 'no-change';
|
||||
const elementCall = element?.registerCall ? 'ok' : 'no-change';
|
||||
|
||||
const primaryError = primary?.error ? ` ${data.primaryScheme} error: ${primary.error}` : '';
|
||||
const elementError = element?.error ? ` element error: ${element.error}` : '';
|
||||
|
||||
const primaryWindows = data.windows?.[data.primaryScheme];
|
||||
const primaryOwner =
|
||||
data.platform === 'win32' && primaryWindows?.userChoiceProgId
|
||||
? ` Current ${data.primaryScheme} default ProgId=${primaryWindows.userChoiceProgId}.`
|
||||
const state = data.isDefault ? 'registered' : 'not registered';
|
||||
const startupState = data.registerCall ? 'ok' : 'no-change';
|
||||
const owner =
|
||||
data.platform === 'win32' && data.windows?.userChoiceProgId
|
||||
? ` Current default ProgId=${data.windows.userChoiceProgId}.`
|
||||
: '';
|
||||
const primaryMissingHint =
|
||||
data.platform === 'win32' && !primaryWindows?.hkcuCommand && !primaryWindows?.hklmCommand
|
||||
? ` ${data.primaryScheme} link type is missing from Windows registry. Use Repair to create it.`
|
||||
const missingHint =
|
||||
data.platform === 'win32' && !data.windows?.hkcuCommand && !data.windows?.hklmCommand
|
||||
? ` ${data.scheme} link type is missing from Windows registry. Use Repair to create it.`
|
||||
: '';
|
||||
const errorPart = data.error ? ` Error: ${data.error}` : '';
|
||||
|
||||
return `Primary ${data.primaryScheme} is ${primaryState} (startup=${primaryCall}) on ${data.platform}. Legacy element is ${elementState} (startup=${elementCall}).${primaryOwner}${primaryMissingHint}${primaryError}${elementError}`;
|
||||
return `${data.scheme} is ${state} (startup=${startupState}) on ${data.platform}.${owner}${missingHint}${errorPart}`;
|
||||
}, []);
|
||||
|
||||
const refreshProtocolStatus = useCallback(() => {
|
||||
@@ -92,11 +82,7 @@ export function About({ requestClose }: AboutProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settingsHint =
|
||||
result.data.platform === 'win32' && result.data.openedSettings
|
||||
? ' Windows Default Apps was opened; set PAARROT to Paarrot and press Refresh.'
|
||||
: '';
|
||||
setProtocolStatus(`${formatProtocolStatus(result.data)}${settingsHint}`);
|
||||
setProtocolStatus(formatProtocolStatus(result.data));
|
||||
setProtocolBusy(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -189,7 +175,7 @@ export function About({ requestClose }: AboutProps) {
|
||||
}
|
||||
/>
|
||||
<SettingTile
|
||||
title="Protocol Handlers (paarrot:// + element://)"
|
||||
title="Protocol Handler (paarrot://)"
|
||||
description={protocolStatus}
|
||||
after={
|
||||
<Box gap="100">
|
||||
|
||||
Reference in New Issue
Block a user