Skip to content

Commit bf0782a

Browse files
committed
removed user from _feed
1 parent b802d5e commit bf0782a

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

lib/home/_feed.dart

+2-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FeedScreen extends StatefulWidget {
1515
final String id;
1616
final String name;
1717

18-
const FeedScreen({Key? key, required this.scrollController, required this.id, required this.name}) : super(key: key);
18+
const FeedScreen({super.key, required this.scrollController, required this.id, required this.name});
1919

2020
@override
2121
State<FeedScreen> createState() => _FeedScreenState();
@@ -30,7 +30,6 @@ class _FeedScreenState extends State<FeedScreen>
3030

3131
late TabController _tabController;
3232
int _tab = 0;
33-
dynamic _tabValue = L10n.current.following;
3433
Duration animationDuration = Duration.zero;
3534

3635
@override
@@ -53,10 +52,6 @@ class _FeedScreenState extends State<FeedScreen>
5352
super.build(context);
5453
final bool _disableAnimations = PrefService.of(context).get(optionDisableAnimations) == true;
5554

56-
user.idStr = "1";
57-
user.possiblySensitive = false;
58-
user.screenName = "ForYou";
59-
6055
return Provider<GroupModel>(create: (context) {
6156
var model = GroupModel(widget.id);
6257
model.loadGroup();
@@ -84,7 +79,6 @@ class _FeedScreenState extends State<FeedScreen>
8479
} else if (value == L10n.current.following) {
8580
_tab = 0;
8681
}
87-
_tabValue = value;
8882
}),
8983
dropdownMenuEntries: [
9084
DropdownMenuEntry(value: L10n.current.following, label: L10n.current.following),
@@ -131,8 +125,7 @@ class _FeedScreenState extends State<FeedScreen>
131125
SubscriptionGroupScreenContent(
132126
id: widget.id,
133127
),
134-
ForYouTweets(
135-
user: user, type: 'profile', includeReplies: false, pinnedTweets: [], pref: PrefService.of(context)),
128+
ForYouTweets(type: 'profile', includeReplies: false, pinnedTweets: [], pref: PrefService.of(context)),
136129
][_tab]);
137130
});
138131
}

lib/home/_forYou.dart

+9-13
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ import 'package:pref/pref.dart';
1010
import 'package:provider/provider.dart';
1111
import '../constants.dart';
1212

13+
final UserWithExtra user = UserWithExtra();
14+
1315
class ForYouTweets extends StatefulWidget {
14-
final UserWithExtra user;
1516
final String type;
1617
final bool includeReplies;
1718
final List<String> pinnedTweets;
1819
final BasePrefService pref;
1920

2021
const ForYouTweets(
21-
{Key? key,
22-
required this.user,
23-
required this.type,
24-
required this.includeReplies,
25-
required this.pinnedTweets,
26-
required this.pref})
22+
{Key? key, required this.type, required this.includeReplies, required this.pinnedTweets, required this.pref})
2723
: super(key: key);
2824

2925
@override
@@ -40,6 +36,9 @@ class _ForYouTweetsState extends State<ForYouTweets> with AutomaticKeepAliveClie
4036
@override
4137
void initState() {
4238
super.initState();
39+
user.idStr = "1";
40+
user.possiblySensitive = false;
41+
user.screenName = "ForYou";
4342
_pagingController = PagingController(firstPageKey: null);
4443
_pagingController.addPageRequestListener((cursor) {
4544
_loadTweets(cursor);
@@ -63,7 +62,7 @@ class _ForYouTweetsState extends State<ForYouTweets> with AutomaticKeepAliveClie
6362
Future _loadTweets(String? cursor) async {
6463
try {
6564
var result = await Twitter.getTimelineTweets(
66-
widget.user.idStr!,
65+
user.idStr!,
6766
widget.type,
6867
widget.pinnedTweets,
6968
cursor: cursor,
@@ -99,7 +98,7 @@ class _ForYouTweetsState extends State<ForYouTweets> with AutomaticKeepAliveClie
9998
],
10099
builder: (context, child) {
101100
return Consumer<TweetContextState>(builder: (context, model, child) {
102-
if (model.hideSensitive && (widget.user.possiblySensitive ?? false)) {
101+
if (model.hideSensitive && (user.possiblySensitive ?? false)) {
103102
return EmojiErrorWidget(
104103
emoji: '🍆🙈🍆',
105104
message: L10n.current.possibly_sensitive,
@@ -118,10 +117,7 @@ class _ForYouTweetsState extends State<ForYouTweets> with AutomaticKeepAliveClie
118117
builderDelegate: PagedChildBuilderDelegate(
119118
itemBuilder: (context, chain, index) {
120119
return TweetConversation(
121-
id: chain.id,
122-
tweets: chain.tweets,
123-
username: widget.user.screenName!,
124-
isPinned: chain.isPinned);
120+
id: chain.id, tweets: chain.tweets, username: user.screenName!, isPinned: chain.isPinned);
125121
},
126122
firstPageErrorIndicatorBuilder: (context) => FullPageErrorWidget(
127123
error: _pagingController.error[0],

0 commit comments

Comments
 (0)