Skip to content

Commit

Permalink
修复下载npe
Browse files Browse the repository at this point in the history
cookie登陆时若格式错误,进行提示
修复阅读页面部分异常
  • Loading branch information
jiangtian616 committed Jul 23, 2022
1 parent 9c8c69f commit 7d2c127
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions lib/src/pages/read/read_page_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,14 @@ class ReadPageLogic extends GetxController {
/// for some reason like slow loading of some image, [ItemPositions] may be not in index order, and even some of
/// them are not in viewport
List<ItemPosition> _filterAndSortItems(Iterable<ItemPosition> positions) {
positions = positions.where((item) => !(item.itemTrailingEdge < 0 || item.itemLeadingEdge > 1)).toList();
(positions as List<ItemPosition>).sort((a, b) => a.index - b.index);
return positions;
List<ItemPosition> actualPositions = positions.where((item) => !(item.itemTrailingEdge < 0 || item.itemLeadingEdge > 1)).toList();
actualPositions.sort((a, b) => a.index - b.index);

if (actualPositions.isEmpty) {
Log.upload(StateError('NoItemPosition!'), stackTrace: StackTrace.current, extraInfos: {'positions': positions});
}

return actualPositions;
}

double _getVisibleHeight() {
Expand Down
14 changes: 12 additions & 2 deletions lib/src/pages/setting/account/login/login_page_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,18 @@ class LoginPageLogic extends GetxController {
return;
}

int ipbMemberId = int.parse(match.group(1)!);
String ipbPassHash = match.group(2)!;
int ipbMemberId;
String ipbPassHash;
try {
ipbMemberId = int.parse(match.group(1)!);
ipbPassHash = match.group(2)!;
} on Exception catch (e) {
Log.error('loginFail'.tr, e);
Log.upload(e);
snack('loginFail'.tr, 'cookieFormatError'.tr);
return;
}

await cookieManager.storeEhCookiesForAllUri([
Cookie('ipb_member_id', ipbMemberId.toString()),
Cookie('ipb_pass_hash', ipbPassHash),
Expand Down
4 changes: 3 additions & 1 deletion lib/src/service/gallery_download_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,9 @@ class GalleryDownloadService extends GetxController {
}

bool _taskHasBeenPausedOrRemoved(GalleryDownloadedData gallery) {
return gid2DownloadProgress[gallery.gid] == null || gid2DownloadProgress[gallery.gid]!.downloadStatus == DownloadStatus.paused;
return gid2DownloadProgress[gallery.gid] == null ||
gid2DownloadProgress[gallery.gid]!.downloadStatus == DownloadStatus.paused ||
gid2ImageHrefs[gallery.gid] == null;
}

static void ensureDownloadDirExists() {
Expand Down

0 comments on commit 7d2c127

Please sign in to comment.