diff --git a/lib/models_new/space/space/data.dart b/lib/models_new/space/space/data.dart index 13296beb..8f8036b4 100644 --- a/lib/models_new/space/space/data.dart +++ b/lib/models_new/space/space/data.dart @@ -58,6 +58,7 @@ class SpaceData { List? entry; List? spaceButtonList; int? relSpecial; + bool? hasItem; SpaceData({ this.relation, @@ -94,90 +95,95 @@ class SpaceData { this.relSpecial, }); - factory SpaceData.fromJson(Map json) => SpaceData( - relation: json['relation'] as int?, - guestRelation: json['guest_relation'] as int?, - medal: json['medal'] as int?, - defaultTab: json['default_tab'] as String?, - isParams: json['is_params'] as bool?, - setting: json['setting'] == null - ? null - : SpaceSetting.fromJson(json['setting'] as Map), - tab: json['tab'] == null - ? null - : SpaceTab.fromJson(json['tab'] as Map), - card: json['card'] == null - ? null - : SpaceCard.fromJson(json['card'] as Map), - images: json['images'] == null - ? null - : SpaceImages.fromJson(json['images'] as Map), - live: json['live'] == null - ? null - : Live.fromJson(json['live'] as Map), - elec: json['elec'] == null - ? null - : Elec.fromJson(json['elec'] as Map), - archive: json['archive'] == null - ? null - : Archive.fromJson(json['archive'] as Map), - series: json['series'] == null - ? null - : SpaceSeries.fromJson(json['series'] as Map), - playGame: json['play_game'] == null - ? null - : PlayGame.fromJson(json['play_game'] as Map), - article: json['article'] == null - ? null - : Article.fromJson(json['article'] as Map), - season: json['season'] == null - ? null - : SpaceSeason.fromJson(json['season'] as Map), - coinArchive: json['coin_archive'] == null - ? null - : CoinArchive.fromJson( - json['coin_archive'] as Map), - likeArchive: json['like_archive'] == null - ? null - : LikeArchive.fromJson( - json['like_archive'] as Map), - audios: json['audios'] == null - ? null - : Audios.fromJson(json['audios'] as Map), - favourite2: json['favourite2'] == null - ? null - : Favourite2.fromJson(json['favourite2'] as Map), - comic: json['comic'] == null - ? null - : Comic.fromJson(json['comic'] as Map), - ugcSeason: json['ugc_season'] == null - ? null - : UgcSeason.fromJson(json['ugc_season'] as Map), - cheese: json['cheese'] == null - ? null - : Cheese.fromJson(json['cheese'] as Map), - guard: json['guard'] == null - ? null - : Guard.fromJson(json['guard'] as Map), - attentionTip: json['attention_tip'] == null - ? null - : AttentionTip.fromJson( - json['attention_tip'] as Map), - nftShowModule: json['nft_show_module'] == null - ? null - : NftShowModule.fromJson( - json['nft_show_module'] as Map), - tab2: (json['tab2'] as List?) - ?.map((e) => SpaceTab2.fromJson(e as Map)) - .toList(), - nftFaceButton: json['nft_face_button'] as dynamic, - digitalButton: json['digital_button'] as dynamic, - entry: (json['entry'] as List?) - ?.map((e) => Entry.fromJson(e as Map)) - .toList(), - spaceButtonList: (json['space_button_list'] as List?) - ?.map((e) => SpaceButtonList.fromJson(e as Map)) - .toList(), - relSpecial: (json['rel_special'] as num?)?.toInt(), - ); + SpaceData.fromJson(Map json) { + relation = json['relation'] as int?; + guestRelation = json['guest_relation'] as int?; + medal = json['medal'] as int?; + defaultTab = json['default_tab'] as String?; + isParams = json['is_params'] as bool?; + setting = json['setting'] == null + ? null + : SpaceSetting.fromJson(json['setting'] as Map); + tab = json['tab'] == null + ? null + : SpaceTab.fromJson(json['tab'] as Map); + card = json['card'] == null + ? null + : SpaceCard.fromJson(json['card'] as Map); + images = json['images'] == null + ? null + : SpaceImages.fromJson(json['images'] as Map); + live = json['live'] == null + ? null + : Live.fromJson(json['live'] as Map); + elec = json['elec'] == null + ? null + : Elec.fromJson(json['elec'] as Map); + archive = json['archive'] == null + ? null + : Archive.fromJson(json['archive'] as Map); + series = json['series'] == null + ? null + : SpaceSeries.fromJson(json['series'] as Map); + playGame = json['play_game'] == null + ? null + : PlayGame.fromJson(json['play_game'] as Map); + article = json['article'] == null + ? null + : Article.fromJson(json['article'] as Map); + season = json['season'] == null + ? null + : SpaceSeason.fromJson(json['season'] as Map); + coinArchive = json['coin_archive'] == null + ? null + : CoinArchive.fromJson(json['coin_archive'] as Map); + likeArchive = json['like_archive'] == null + ? null + : LikeArchive.fromJson(json['like_archive'] as Map); + audios = json['audios'] == null + ? null + : Audios.fromJson(json['audios'] as Map); + favourite2 = json['favourite2'] == null + ? null + : Favourite2.fromJson(json['favourite2'] as Map); + comic = json['comic'] == null + ? null + : Comic.fromJson(json['comic'] as Map); + ugcSeason = json['ugc_season'] == null + ? null + : UgcSeason.fromJson(json['ugc_season'] as Map); + cheese = json['cheese'] == null + ? null + : Cheese.fromJson(json['cheese'] as Map); + guard = json['guard'] == null + ? null + : Guard.fromJson(json['guard'] as Map); + attentionTip = json['attention_tip'] == null + ? null + : AttentionTip.fromJson(json['attention_tip'] as Map); + nftShowModule = json['nft_show_module'] == null + ? null + : NftShowModule.fromJson( + json['nft_show_module'] as Map); + tab2 = (json['tab2'] as List?) + ?.map((e) => SpaceTab2.fromJson(e as Map)) + .toList(); + nftFaceButton = json['nft_face_button'] as dynamic; + digitalButton = json['digital_button'] as dynamic; + entry = (json['entry'] as List?) + ?.map((e) => Entry.fromJson(e as Map)) + .toList(); + spaceButtonList = (json['space_button_list'] as List?) + ?.map((e) => SpaceButtonList.fromJson(e as Map)) + .toList(); + relSpecial = (json['rel_special'] as num?)?.toInt(); + hasItem = archive?.item?.isNotEmpty == true || + favourite2?.item?.isNotEmpty == true || + coinArchive?.item?.isNotEmpty == true || + likeArchive?.item?.isNotEmpty == true || + article?.item?.isNotEmpty == true || + audios?.item?.isNotEmpty == true || + comic?.item?.isNotEmpty == true || + season?.item?.isNotEmpty == true; + } } diff --git a/lib/models_new/space/space/tab.dart b/lib/models_new/space/space/tab.dart index a3412707..1fe35bcb 100644 --- a/lib/models_new/space/space/tab.dart +++ b/lib/models_new/space/space/tab.dart @@ -22,7 +22,7 @@ class SpaceTab { bool? opus; bool? cheeseVideo; bool? brand; - bool? hasItem; + // bool? hasItem; SpaceTab({ this.archive, @@ -74,6 +74,6 @@ class SpaceTab { opus = json['opus'] as bool?; cheeseVideo = json['cheese_video'] as bool?; brand = json['brand'] as bool?; - hasItem = json.values.any((e) => e == true); + // hasItem = json.values.any((e) => e == true); } } diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 5ff61147..456c875b 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -187,20 +187,22 @@ class LiveRoomController extends GetxController { LiveHttp.liveRoomDanmaPrefetch(roomId: roomId).then((v) { if (v['status']) { if ((v['data'] as List?)?.isNotEmpty == true) { - messages.addAll((v['data'] as List) - .map((obj) => { - 'name': obj['user']['base']['name'], - 'uid': obj['user']['uid'], - 'text': obj['text'], - 'emots': obj['emots'], - 'uemote': obj['emoticon']['emoticon_unique'] != "" - ? obj['emoticon'] - : null, - }) - .toList()); - WidgetsBinding.instance.addPostFrameCallback( - (_) => scrollToBottom(), - ); + try { + messages.addAll((v['data'] as List) + .map((obj) => { + 'name': obj['user']['base']['name'], + 'uid': obj['user']['uid'], + 'text': obj['text'], + 'emots': obj['emots'], + 'uemote': obj['emoticon']['emoticon_unique'] != "" + ? obj['emoticon'] + : null, + }) + .toList()); + WidgetsBinding.instance.addPostFrameCallback( + (_) => scrollToBottom(), + ); + } catch (_) {} } } }); @@ -268,34 +270,36 @@ class LiveRoomController extends GetxController { .toList(), ) ..addEventListener((obj) { - if (obj['cmd'] == 'DANMU_MSG') { - // logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}'); - final info = obj['info']; - final first = info[0]; - final content = first[15]; - final extra = jsonDecode(content['extra']); - final user = content['user']; - final uid = user['uid']; - messages.add({ - 'name': user['base']['name'], - 'uid': uid, - 'text': info[1], - 'emots': extra['emots'], - 'uemote': first[13], - }); - if (showDanmaku) { - controller?.addDanmaku( - DanmakuContentItem( - extra['content'], - color: DmUtils.decimalToColor(extra['color']), - type: DmUtils.getPosition(extra['mode']), - selfSend: isLogin && uid == accountService.mid, - ), - ); - WidgetsBinding.instance - .addPostFrameCallback((_) => scrollToBottom()); + try { + if (obj['cmd'] == 'DANMU_MSG') { + // logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}'); + final info = obj['info']; + final first = info[0]; + final content = first[15]; + final extra = jsonDecode(content['extra']); + final user = content['user']; + final uid = user['uid']; + messages.add({ + 'name': user['base']['name'], + 'uid': uid, + 'text': info[1], + 'emots': extra['emots'], + 'uemote': first[13], + }); + if (showDanmaku) { + controller?.addDanmaku( + DanmakuContentItem( + extra['content'], + color: DmUtils.decimalToColor(extra['color']), + type: DmUtils.getPosition(extra['mode']), + selfSend: isLogin && uid == accountService.mid, + ), + ); + WidgetsBinding.instance + .addPostFrameCallback((_) => scrollToBottom()); + } } - } + } catch (_) {} }) ..init(); } diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 904e630f..cb7641fa 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -85,7 +85,7 @@ class MemberController extends CommonDataController } tab2?.retainWhere((item) => implTabs.contains(item.param)); if (tab2?.isNotEmpty == true) { - if (data.tab!.hasItem != true && tab2!.first.param == 'home') { + if (data.hasItem != true && tab2!.first.param == 'home') { // remove empty home tab tab2!.removeAt(0); }