@@ -58,14 +58,23 @@ export default class Results extends React.PureComponent<IProps> {
58
58
searchType = "all"
59
59
}
60
60
61
- // check if id may have been entered
61
+ // check if id or guid may have been entered
62
62
const number = Number ( query )
63
- let firstResult = null
64
- if ( ! isNaN ( number ) && searchType !== "person" ) {
65
- firstResult = await ( await this . getFeedById ( query ) ) ?. feed
63
+ let feedIdResult = null
64
+ let guidResult = null
65
+ if ( query && searchType !== "person" ) {
66
+ if ( ! isNaN ( number ) ) {
67
+ feedIdResult = await ( await this . getFeedById ( query ) ) ?. feed
68
+ // check if a feed object. When query isn't a valid ID, returns list instead of empty object
69
+ if ( feedIdResult . id === undefined ) {
70
+ feedIdResult = null
71
+ }
72
+ }
73
+ // check if guid if no feed returned
74
+ guidResult = await ( await this . getPodcastInfoGuid ( query ) ) ?. feed
66
75
// check if a feed object. When query isn't a valid ID, returns list instead of empty object
67
- if ( firstResult . id === undefined ) {
68
- firstResult = null
76
+ if ( guidResult . id === undefined ) {
77
+ guidResult = null
69
78
}
70
79
}
71
80
@@ -87,8 +96,11 @@ export default class Results extends React.PureComponent<IProps> {
87
96
}
88
97
}
89
98
90
- if ( firstResult ) {
91
- results . unshift ( firstResult )
99
+ if ( guidResult ) {
100
+ results . unshift ( guidResult )
101
+ }
102
+ if ( feedIdResult ) {
103
+ results . unshift ( feedIdResult )
92
104
}
93
105
94
106
if ( this . _isMounted ) {
@@ -111,6 +123,15 @@ export default class Results extends React.PureComponent<IProps> {
111
123
return await response . json ( )
112
124
}
113
125
126
+ async getPodcastInfoGuid ( guid : string ) {
127
+ // noinspection SpellCheckingInspection
128
+ let response = await fetch ( `/api/podcasts/byguid?guid=${ guid } ` , {
129
+ // credentials: 'same-origin',
130
+ method : 'GET' ,
131
+ } )
132
+ return await response . json ( )
133
+ }
134
+
114
135
async getTermSearchResults ( query : string , similar : boolean = false ) {
115
136
query = encodeSearch ( query )
116
137
const similarParam = similar ? "&similar" : ""
0 commit comments