@@ -103,15 +103,14 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
103
103
104
104
@override
105
105
void onInit () {
106
+ super .onInit ();
107
+
106
108
if (Get .arguments is ! Map ) {
107
109
return ;
108
110
}
109
111
110
- state.gid = Get .arguments['gid' ];
111
112
state.galleryUrl = Get .arguments['galleryUrl' ];
112
113
state.gallery = Get .arguments['gallery' ];
113
-
114
- super .onInit ();
115
114
}
116
115
117
116
@override
@@ -156,6 +155,10 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
156
155
if (enableLoadingState) {
157
156
updateSafely ([loadingStateId]);
158
157
}
158
+
159
+ if (e.type == EHSiteExceptionType .galleryDeleted) {
160
+ await _handleGalleryDeleted ();
161
+ }
159
162
return ;
160
163
} on Error catch (e) {
161
164
Log .error ('Get Gallery Detail Failed' , e, e.stackTrace);
@@ -183,6 +186,8 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
183
186
SchedulerBinding .instance.scheduleTask (() => historyService.record (state.gallery), Priority .animation);
184
187
}
185
188
189
+ Future <void > _handleGalleryDeleted () async {}
190
+
186
191
Future <void > loadMoreThumbnails () async {
187
192
if (state.loadingThumbnailsState == LoadingState .loading) {
188
193
return ;
@@ -201,7 +206,7 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
201
206
List <GalleryThumbnail > newThumbNails;
202
207
try {
203
208
newThumbNails = await EHRequest .requestDetailPage (
204
- galleryUrl: state.galleryUrl,
209
+ galleryUrl: state.galleryUrl.url ,
205
210
thumbnailsPageIndex: state.nextPageIndexToLoadThumbnails,
206
211
parser: EHSpiderParser .detailPage2Thumbnails,
207
212
);
@@ -587,13 +592,13 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
587
592
Log .info ('Share gallery:${state .galleryUrl }' );
588
593
589
594
if (GetPlatform .isDesktop) {
590
- await FlutterClipboard .copy (state.galleryUrl);
595
+ await FlutterClipboard .copy (state.galleryUrl.url );
591
596
toast ('hasCopiedToClipboard' .tr);
592
597
return ;
593
598
}
594
599
595
600
Share .share (
596
- state.galleryUrl,
601
+ state.galleryUrl.url ,
597
602
sharePositionOrigin: Rect .fromLTWH (0 , 0 , fullScreenWidth, screenHeight * 2 / 3 ),
598
603
);
599
604
}
@@ -678,7 +683,7 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
678
683
gid: state.gallery! .gid,
679
684
token: state.gallery! .token,
680
685
galleryTitle: state.gallery! .title,
681
- galleryUrl: state.galleryUrl,
686
+ galleryUrl: state.galleryUrl.url ,
682
687
initialIndex: forceIndex ?? readIndexRecord,
683
688
currentImageIndex: forceIndex ?? readIndexRecord,
684
689
readProgressRecordStorageKey: storageKey,
@@ -703,7 +708,7 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
703
708
gid: state.gallery! .gid,
704
709
token: state.gallery! .token,
705
710
galleryTitle: state.gallery! .title,
706
- galleryUrl: state.galleryUrl,
711
+ galleryUrl: state.galleryUrl.url ,
707
712
initialIndex: forceIndex ?? readIndexRecord,
708
713
currentImageIndex: forceIndex ?? readIndexRecord,
709
714
readProgressRecordStorageKey: storageKey,
@@ -726,17 +731,17 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
726
731
727
732
/// 1. if redirect is enabled, try EH site first for EX link
728
733
/// 2. if a gallery can't be found in EH site, it may be moved into EX site
729
- if (state.galleryUrl.contains (EHConsts .EXIndex )) {
734
+ if (state.galleryUrl.url. contains (EHConsts .EXIndex )) {
730
735
if (EHSetting .redirect2Eh.isTrue && ! _galleryOnlyInExSite ()) {
731
- firstLink = state.galleryUrl.replaceFirst (EHConsts .EXIndex , EHConsts .EHIndex );
732
- secondLink = state.galleryUrl;
736
+ firstLink = state.galleryUrl.url. replaceFirst (EHConsts .EXIndex , EHConsts .EHIndex );
737
+ secondLink = state.galleryUrl.url ;
733
738
} else {
734
739
firstLink = null ;
735
- secondLink = state.galleryUrl;
740
+ secondLink = state.galleryUrl.url ;
736
741
}
737
742
} else {
738
- firstLink = state.galleryUrl;
739
- secondLink = state.galleryUrl.replaceFirst (EHConsts .EHIndex , EHConsts .EXIndex );
743
+ firstLink = state.galleryUrl.url ;
744
+ secondLink = state.galleryUrl.url. replaceFirst (EHConsts .EHIndex , EHConsts .EXIndex );
740
745
}
741
746
742
747
/// if we can't find gallery via firstLink, try second link
@@ -749,10 +754,10 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
749
754
parser: EHSpiderParser .detailPage2GalleryAndDetailAndApikey,
750
755
useCacheIfAvailable: useCache,
751
756
);
752
- state.gallery? .galleryUrl = state.galleryUrl = firstLink ;
757
+ state.gallery? .galleryUrl = state.galleryUrl = state.galleryUrl. copyWith (isEH : true ) ;
753
758
return galleryAndDetailAndApikey;
754
759
} on EHSiteException catch (e) {
755
- Log .verbose ('Can\' t find gallery, firstLink: $firstLink ' );
760
+ Log .verbose ('Can\' t find gallery, firstLink: $firstLink , reason: ${ e . message } ' );
756
761
firstException = e;
757
762
}
758
763
}
@@ -764,10 +769,10 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
764
769
parser: EHSpiderParser .detailPage2GalleryAndDetailAndApikey,
765
770
useCacheIfAvailable: useCache,
766
771
);
767
- state.gallery? .galleryUrl = state.galleryUrl = secondLink ;
772
+ state.gallery? .galleryUrl = state.galleryUrl = state.galleryUrl. copyWith (isEH : false ) ;
768
773
return galleryAndDetailAndApikey;
769
774
} on EHSiteException catch (e) {
770
- Log .verbose ('Can\' t find gallery, secondLink: $secondLink ' );
775
+ Log .verbose ('Can\' t find gallery, secondLink: $secondLink , reason: ${ e . message } ' );
771
776
throw firstException ?? e;
772
777
}
773
778
}
@@ -854,6 +859,6 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
854
859
}
855
860
856
861
void _removeCache () {
857
- EHRequest .removeCacheByGalleryUrlAndPage (state.galleryUrl, 0 );
862
+ EHRequest .removeCacheByGalleryUrlAndPage (state.galleryUrl.url , 0 );
858
863
}
859
864
}
0 commit comments