mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
refactor(PasteService): optimize handler registration logic (#6223)
- Updated registerHandler to only log and update the handler if it changes, reducing unnecessary operations. - Removed logging from unregisterHandler for cleaner code.
This commit is contained in:
parent
74fbd37a20
commit
adf13979ca
@ -157,8 +157,10 @@ export const init = () => {
|
||||
export const registerHandler = (component: ComponentType, handler: PasteHandler) => {
|
||||
if (!component) return
|
||||
|
||||
handlers[component] = handler
|
||||
Logger.info(`[PasteService] Handler registered for ${component}`)
|
||||
// Only log and update if the handler actually changes
|
||||
if (!handlers[component] || handlers[component] !== handler) {
|
||||
handlers[component] = handler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +170,6 @@ export const unregisterHandler = (component: ComponentType) => {
|
||||
if (!component || !handlers[component]) return
|
||||
|
||||
delete handlers[component]
|
||||
Logger.info(`[PasteService] Handler unregistered for ${component}`)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user