mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 08:15:53 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,64 +1,57 @@
|
||||
import * as React from 'react'
|
||||
import { useEffect, useMemo } from 'react'
|
||||
import { getIsRemoteMode } from '../../bootstrap/state.js'
|
||||
import { useNotifications } from '../../context/notifications.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { useAppState } from '../../state/AppState.js'
|
||||
import { logForDebugging } from '../../utils/debug.js'
|
||||
import { plural } from '../../utils/stringUtils.js'
|
||||
import * as React from 'react';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { getIsRemoteMode } from '../../bootstrap/state.js';
|
||||
import { useNotifications } from '../../context/notifications.js';
|
||||
import { Text } from '@anthropic/ink';
|
||||
import { useAppState } from '../../state/AppState.js';
|
||||
import { logForDebugging } from '../../utils/debug.js';
|
||||
import { plural } from '../../utils/stringUtils.js';
|
||||
|
||||
export function usePluginInstallationStatus(): void {
|
||||
const { addNotification } = useNotifications()
|
||||
const installationStatus = useAppState(s => s.plugins.installationStatus)
|
||||
const { addNotification } = useNotifications();
|
||||
const installationStatus = useAppState(s => s.plugins.installationStatus);
|
||||
|
||||
// Memoize the failed counts to prevent unnecessary effect triggers
|
||||
const { totalFailed, failedMarketplacesCount, failedPluginsCount } =
|
||||
useMemo(() => {
|
||||
if (!installationStatus) {
|
||||
return {
|
||||
totalFailed: 0,
|
||||
failedMarketplacesCount: 0,
|
||||
failedPluginsCount: 0,
|
||||
}
|
||||
}
|
||||
|
||||
const failedMarketplaces = installationStatus.marketplaces.filter(
|
||||
m => m.status === 'failed',
|
||||
)
|
||||
const failedPlugins = installationStatus.plugins.filter(
|
||||
p => p.status === 'failed',
|
||||
)
|
||||
|
||||
const { totalFailed, failedMarketplacesCount, failedPluginsCount } = useMemo(() => {
|
||||
if (!installationStatus) {
|
||||
return {
|
||||
totalFailed: failedMarketplaces.length + failedPlugins.length,
|
||||
failedMarketplacesCount: failedMarketplaces.length,
|
||||
failedPluginsCount: failedPlugins.length,
|
||||
}
|
||||
}, [installationStatus])
|
||||
totalFailed: 0,
|
||||
failedMarketplacesCount: 0,
|
||||
failedPluginsCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const failedMarketplaces = installationStatus.marketplaces.filter(m => m.status === 'failed');
|
||||
const failedPlugins = installationStatus.plugins.filter(p => p.status === 'failed');
|
||||
|
||||
return {
|
||||
totalFailed: failedMarketplaces.length + failedPlugins.length,
|
||||
failedMarketplacesCount: failedMarketplaces.length,
|
||||
failedPluginsCount: failedPlugins.length,
|
||||
};
|
||||
}, [installationStatus]);
|
||||
|
||||
useEffect(() => {
|
||||
if (getIsRemoteMode()) return
|
||||
if (getIsRemoteMode()) return;
|
||||
if (!installationStatus) {
|
||||
logForDebugging('No installation status to monitor')
|
||||
return
|
||||
logForDebugging('No installation status to monitor');
|
||||
return;
|
||||
}
|
||||
|
||||
if (totalFailed === 0) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
logForDebugging(
|
||||
`Plugin installation status: ${failedMarketplacesCount} failed marketplaces, ${failedPluginsCount} failed plugins`,
|
||||
)
|
||||
);
|
||||
|
||||
if (totalFailed === 0) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
// Add notification for failures
|
||||
logForDebugging(
|
||||
`Adding notification for ${totalFailed} failed installations`,
|
||||
)
|
||||
logForDebugging(`Adding notification for ${totalFailed} failed installations`);
|
||||
addNotification({
|
||||
key: 'plugin-install-failed',
|
||||
jsx: (
|
||||
@@ -70,11 +63,6 @@ export function usePluginInstallationStatus(): void {
|
||||
</>
|
||||
),
|
||||
priority: 'medium',
|
||||
})
|
||||
}, [
|
||||
addNotification,
|
||||
totalFailed,
|
||||
failedMarketplacesCount,
|
||||
failedPluginsCount,
|
||||
])
|
||||
});
|
||||
}, [addNotification, totalFailed, failedMarketplacesCount, failedPluginsCount]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user