Skip to content

Commit a9c6c76

Browse files
committed
🐛 (fix) tweet not showing after composing tweet.
Issue Fixed:- #111 (comment)
1 parent dbecfce commit a9c6c76

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

lib/page/homePage.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ class _HomePageState extends State<HomePage> {
6666
final chatState = Provider.of<ChatState>(context, listen: false);
6767
final state = Provider.of<AuthState>(context, listen: false);
6868
chatState.databaseInit(state.userId, state.userId);
69-
/// It will update fcm token in database
69+
70+
/// It will update fcm token in database
7071
/// fcm token is required to send firebase notification
7172
state.updateFCMToken();
72-
/// It get fcm server key
73+
74+
/// It get fcm server key
7375
/// Server key is required to configure firebase notification
7476
/// Without fcm server notification can not be sent
7577
chatState.getFCMServerKey();
@@ -83,7 +85,7 @@ class _HomePageState extends State<HomePage> {
8385
void _checkNotification() {
8486
final authstate = Provider.of<AuthState>(context, listen: false);
8587
WidgetsBinding.instance.addPostFrameCallback((_) {
86-
var state = Provider.of<NotificationState>(context);
88+
var state = Provider.of<NotificationState>(context, listen: false);
8789

8890
/// Check if user recieve chat notification from firebase
8991
/// Redirect to chat screen

lib/page/search/SearchPage.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class _SearchPageState extends State<SearchPage> {
2323
@override
2424
void initState() {
2525
WidgetsBinding.instance.addPostFrameCallback((_) {
26-
final state = Provider.of<SearchState>(context);
26+
final state = Provider.of<SearchState>(context, listen: false);
2727
state.resetFilterList();
2828
});
2929
super.initState();

lib/state/feedState.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,15 @@ class FeedState extends AppState {
335335
notifyListeners();
336336
var storageReference = FirebaseStorage.instance
337337
.ref()
338-
.child('tweetImage${Path.basename(file.path)}');
338+
.child("tweetImage")
339+
.child(Path.basename(file.path));
339340
await storageReference.putFile(file);
340341

341-
storageReference.getDownloadURL().then((fileURL) async {
342-
var url = await storageReference.getDownloadURL();
343-
if (url != null) {
344-
return url;
345-
}
346-
return null;
347-
});
342+
var url = await storageReference.getDownloadURL();
343+
if (url != null) {
344+
return url;
345+
}
346+
return null;
348347
} catch (error) {
349348
cprint(error, errorIn: 'uploadFile');
350349
return null;
@@ -354,14 +353,11 @@ class FeedState extends AppState {
354353
/// [Delete file] from firebase storage
355354
Future<void> deleteFile(String url, String baseUrl) async {
356355
try {
357-
String filePath = url.replaceAll(
358-
new RegExp(
359-
r'https://firebasestorage.googleapis.com/v0/b/twitter-clone-4fce9.appspot.com/o/'),
360-
'');
356+
var filePath = url.split(".com/o/")[1];
361357
filePath = filePath.replaceAll(new RegExp(r'%2F'), '/');
362358
filePath = filePath.replaceAll(new RegExp(r'(\?alt).*'), '');
363359
// filePath = filePath.replaceAll('tweetImage/', '');
364-
// cprint('[Path]'+filePath);
360+
cprint('[Path]' + filePath);
365361
var storageReference = FirebaseStorage.instance.ref();
366362
await storageReference.child(filePath).delete().catchError((val) {
367363
cprint('[Error]' + val);

0 commit comments

Comments
 (0)