mirror of
https://github.com/spotiflacapp/SpotiFLAC-Mobile.git
synced 2026-06-01 03:15:17 +07:00
fix: gomobile compatibility for HandleURLWithExtension return type
This commit is contained in:
parent
4afc14dee8
commit
0cab01780d
2 changed files with 26 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue