@@ -140,7 +140,7 @@ export class MgtGet extends MgtTemplatedComponent {
140140 * trigger the element to update.
141141 */
142142 protected render ( ) {
143- if ( this . isLoadingState ) {
143+ if ( this . isLoadingState && ! this . isPolling ) {
144144 return this . renderTemplate ( 'loading' , null ) ;
145145 } else if ( this . error ) {
146146 return this . renderTemplate ( 'error' , this . error ) ;
@@ -179,8 +179,6 @@ export class MgtGet extends MgtTemplatedComponent {
179179 }
180180 } else if ( this . response ) {
181181 return this . renderTemplate ( 'default' , this . response ) || html `` ;
182- } else if ( this . isLoadingState ) {
183- return this . renderTemplate ( 'loading' , null ) || html `` ;
184182 } else {
185183 return html `` ;
186184 }
@@ -205,12 +203,14 @@ export class MgtGet extends MgtTemplatedComponent {
205203 if ( this . resource ) {
206204 try {
207205 let uri = this . resource ;
208- let delta = false ;
206+ let isDeltaLink = false ;
209207
210208 // if we had a response earlier with a delta link, use it instead
211209 if ( this . response && this . response [ '@odata.deltaLink' ] ) {
212210 uri = this . response [ '@odata.deltaLink' ] ;
213- delta = true ;
211+ isDeltaLink = true ;
212+ } else {
213+ isDeltaLink = new URL ( uri , 'https://graph.microsoft.com' ) . pathname . endsWith ( 'delta' ) ;
214214 }
215215
216216 const graph = provider . graph . forComponent ( this ) ;
@@ -220,23 +220,23 @@ export class MgtGet extends MgtTemplatedComponent {
220220 request = request . middlewareOptions ( prepScopes ( ...this . scopes ) ) ;
221221 }
222222
223- const response = await request . get ( ) ;
223+ let response = await request . get ( ) ;
224224
225- if ( delta && this . response && Array . isArray ( this . response . value ) && Array . isArray ( response . value ) ) {
225+ if ( isDeltaLink && this . response && Array . isArray ( this . response . value ) && Array . isArray ( response . value ) ) {
226226 response . value = this . response . value . concat ( response . value ) ;
227227 }
228228
229- if ( ! equals ( this . response , response ) ) {
229+ if ( ! this . isPolling && ! equals ( this . response , response ) ) {
230230 this . response = response ;
231231 }
232232
233233 // get more pages if there are available
234- if ( this . response && Array . isArray ( this . response . value ) && this . response [ '@odata.nextLink' ] ) {
234+ if ( response && Array . isArray ( response . value ) && response [ '@odata.nextLink' ] ) {
235235 let pageCount = 1 ;
236- let page = this . response ;
236+ let page = response ;
237237
238238 while (
239- ( pageCount < this . maxPages || this . maxPages <= 0 || this . pollingRate ) &&
239+ ( pageCount < this . maxPages || this . maxPages <= 0 || ( isDeltaLink && this . pollingRate ) ) &&
240240 page &&
241241 page [ '@odata.nextLink' ]
242242 ) {
@@ -247,11 +247,18 @@ export class MgtGet extends MgtTemplatedComponent {
247247 . version ( this . version )
248248 . get ( ) ;
249249 if ( page && page . value && page . value . length ) {
250- page . value = this . response . value . concat ( page . value ) ;
251- this . response = page ;
250+ page . value = response . value . concat ( page . value ) ;
251+ response = page ;
252+ if ( ! this . isPolling ) {
253+ this . response = response ;
254+ }
252255 }
253256 }
254257 }
258+
259+ if ( ! equals ( this . response , response ) ) {
260+ this . response = response ;
261+ }
255262 } catch ( e ) {
256263 this . error = e ;
257264 }
0 commit comments