mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 02:09:03 +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
0641857f26
commit
bb3bfafe7e
@ -157,8 +157,10 @@ export const init = () => {
|
|||||||
export const registerHandler = (component: ComponentType, handler: PasteHandler) => {
|
export const registerHandler = (component: ComponentType, handler: PasteHandler) => {
|
||||||
if (!component) return
|
if (!component) return
|
||||||
|
|
||||||
handlers[component] = handler
|
// Only log and update if the handler actually changes
|
||||||
Logger.info(`[PasteService] Handler registered for ${component}`)
|
if (!handlers[component] || handlers[component] !== handler) {
|
||||||
|
handlers[component] = handler
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +170,6 @@ export const unregisterHandler = (component: ComponentType) => {
|
|||||||
if (!component || !handlers[component]) return
|
if (!component || !handlers[component]) return
|
||||||
|
|
||||||
delete handlers[component]
|
delete handlers[component]
|
||||||
Logger.info(`[PasteService] Handler unregistered for ${component}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user