@@ -95,7 +95,8 @@ final class GiftStoreScreenComponent: Component {
9595
9696 private var starsStateDisposable : Disposable ?
9797 private var starsState : StarsContext . State ?
98- private var initialCount : Int ?
98+ private var initialCount : Int32 ?
99+ private var showLoading = true
99100
100101 private var component : GiftStoreScreenComponent ?
101102 private( set) weak var state : State ?
@@ -451,7 +452,7 @@ final class GiftStoreScreenComponent: Component {
451452 }
452453
453454 let bottomContentOffset = max ( 0.0 , self . scrollView. contentSize. height - self . scrollView. contentOffset. y - self . scrollView. frame. height)
454- if interactive, bottomContentOffset < 320 .0 {
455+ if interactive, bottomContentOffset < 1000 .0 {
455456 self . state? . starGiftsContext. loadMore ( )
456457 }
457458 }
@@ -471,6 +472,7 @@ final class GiftStoreScreenComponent: Component {
471472 guard let self else {
472473 return
473474 }
475+ self . showLoading = true
474476 self . state? . starGiftsContext. updateSorting ( . value)
475477 self . scrollToTop ( )
476478 } ) ) )
@@ -481,6 +483,7 @@ final class GiftStoreScreenComponent: Component {
481483 guard let self else {
482484 return
483485 }
486+ self . showLoading = true
484487 self . state? . starGiftsContext. updateSorting ( . date)
485488 self . scrollToTop ( )
486489 } ) ) )
@@ -491,6 +494,7 @@ final class GiftStoreScreenComponent: Component {
491494 guard let self else {
492495 return
493496 }
497+ self . showLoading = true
494498 self . state? . starGiftsContext. updateSorting ( . number)
495499 self . scrollToTop ( )
496500 } ) ) )
@@ -564,6 +568,7 @@ final class GiftStoreScreenComponent: Component {
564568 updatedFilterAttributes. append ( attribute)
565569 }
566570 }
571+ self . showLoading = true
567572 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
568573 self . scrollToTop ( )
569574 } ,
@@ -577,6 +582,7 @@ final class GiftStoreScreenComponent: Component {
577582 }
578583 return true
579584 }
585+ self . showLoading = true
580586 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
581587 self . scrollToTop ( )
582588 }
@@ -657,6 +663,7 @@ final class GiftStoreScreenComponent: Component {
657663 updatedFilterAttributes. append ( attribute)
658664 }
659665 }
666+ self . showLoading = true
660667 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
661668 self . scrollToTop ( )
662669 } ,
@@ -670,6 +677,7 @@ final class GiftStoreScreenComponent: Component {
670677 }
671678 return true
672679 }
680+ self . showLoading = true
673681 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
674682 self . scrollToTop ( )
675683 }
@@ -750,6 +758,7 @@ final class GiftStoreScreenComponent: Component {
750758 updatedFilterAttributes. append ( attribute)
751759 }
752760 }
761+ self . showLoading = true
753762 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
754763 self . scrollToTop ( )
755764 } ,
@@ -763,6 +772,7 @@ final class GiftStoreScreenComponent: Component {
763772 }
764773 return true
765774 }
775+ self . showLoading = true
766776 self . state? . starGiftsContext. updateFilterAttributes ( updatedFilterAttributes)
767777 self . scrollToTop ( )
768778 }
@@ -804,6 +814,12 @@ final class GiftStoreScreenComponent: Component {
804814 self . component = component
805815
806816 let isLoading = self . effectiveIsLoading
817+ if case let . ready( loadMore, nextOffset) = self . state? . starGiftsState? . dataState {
818+ if loadMore && nextOffset == nil {
819+ } else {
820+ self . showLoading = false
821+ }
822+ }
807823
808824 let theme = environment. theme
809825 let strings = environment. strings
@@ -927,7 +943,7 @@ final class GiftStoreScreenComponent: Component {
927943 }
928944
929945 let effectiveCount : Int32
930- if let count = self . effectiveGifts ? . count, count > 0 || self . initialCount != nil {
946+ if let count = self . state ? . starGiftsState ? . count, count > 0 || self . initialCount != nil {
931947 if self . initialCount == nil {
932948 self . initialCount = count
933949 }
@@ -1112,7 +1128,7 @@ final class GiftStoreScreenComponent: Component {
11121128
11131129 self . updateScrolling ( transition: transition)
11141130
1115- if isLoading {
1131+ if isLoading && self . showLoading {
11161132 self . loadingNode. update ( size: availableSize, theme: environment. theme, transition: . immediate)
11171133 loadingTransition. setAlpha ( view: self . loadingNode. view, alpha: 1.0 )
11181134 } else {
0 commit comments