fix: gomobile compatibility for HandleURLWithExtension return type

This commit is contained in:
zarzet 2026-01-12 23:43:57 +07:00
parent 4afc14dee8
commit 0cab01780d
No known key found for this signature in database
GPG key ID: D22AEB239271AACA
2 changed files with 26 additions and 5 deletions

View file

@ -1512,11 +1512,19 @@ func GetSearchProvidersJSON() (string, error) {
// Returns JSON with type, tracks, album info, etc.
func HandleURLWithExtensionJSON(url string) (string, error) {
manager := GetExtensionManager()
result, extensionID, err := manager.HandleURLWithExtension(url)
resultWithID, err := manager.HandleURLWithExtension(url)
if err != nil {
return "", err
}
result := resultWithID.Result
extensionID := resultWithID.ExtensionID
// Check if result is nil (handler found but returned error)
if result == nil {
return "", fmt.Errorf("extension %s failed to handle URL", extensionID)
}
// Build response
response := map[string]interface{}{
"type": result.Type,

View file

@ -1210,19 +1210,32 @@ func (m *ExtensionManager) FindURLHandler(url string) *ExtensionProviderWrapper
return nil
}
// ExtURLHandleResultWithExtID wraps ExtURLHandleResult with extension ID for gomobile compatibility
type ExtURLHandleResultWithExtID struct {
Result *ExtURLHandleResult
ExtensionID string
}
// HandleURLWithExtension tries to handle a URL with any matching extension
func (m *ExtensionManager) HandleURLWithExtension(url string) (*ExtURLHandleResult, string, error) {
// Returns result with extension ID, or error if no handler found
func (m *ExtensionManager) HandleURLWithExtension(url string) (*ExtURLHandleResultWithExtID, error) {
handler := m.FindURLHandler(url)
if handler == nil {
return nil, "", fmt.Errorf("no extension found to handle URL: %s", url)
return nil, fmt.Errorf("no extension found to handle URL: %s", url)
}
result, err := handler.HandleURL(url)
if err != nil {
return nil, handler.extension.ID, err
return &ExtURLHandleResultWithExtID{
Result: nil,
ExtensionID: handler.extension.ID,
}, err
}
return result, handler.extension.ID, nil
return &ExtURLHandleResultWithExtID{
Result: result,
ExtensionID: handler.extension.ID,
}, nil
}
// GetPostProcessingProviders returns all extensions that provide post-processing