Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Interceptor for noticeboard mobile #35

Merged

Conversation

pranavkonidena
Copy link
Member

@pranavkonidena pranavkonidena commented Feb 19, 2024

Closes #34

Problem

There is notification to the user if their device goes offline, only generic errors were shown

Technicalities of change

I have made a connectivityStatusBloc with a enum for network connection status. In the root of the app , I have passed the context of the material app to the connectivityStatusBloc because it will always be mounted on the widget tree regardless of current widget. My connectivityStatusBloc class is a singleton because there should only be one instantiation of the stream wherever it gets called (We don't want individual network streams for widgets). Hence , it will always be able to render snackbar's succesfully. I have made two functions. One for checking the connectivityStatus using InternetAddress.lookup function of dart:io and have made it a recurring function every 15 seconds until the widget doesn't dispose. I have also made a function to send the required result into the connectivityStatusBloc event sink which manages the snackbars.

For refetch:
There are two types of refetch. One is refetching list of notices, other is reloading the notice detail webview. To reload a web view, we need a webViewController. To do that, I had to upgrade flutter to 3.19.1 and webview_flutter to 4.7.0. I made a NoticeDetailBloc (another stream) which is fed events when user is back online by connectivityStatusBloc based on current position. The reqd widgets listen to the sink of this stream and refetch the required objects.

Note to reviewer

Please squash and merge.
Will fix the GH workflow in another PR. It will fail as I have upgraded flutter version to 3.19.1

Demo

Two videos are attached one for notices list refetch and one for notice detail refetch

2024_02_26_13_46_11.1.mp4
2024_02_26_13_47_29.1.mp4

@pranavkonidena pranavkonidena marked this pull request as ready for review February 20, 2024 04:43
Copy link
Member

@justary27 justary27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When internet restore ho rha then why not do a notice refetch a the end? Also flutter analyze k issue fix krle, btw nice bgm :)

All changes are as follows:
I have updated the web view flutter package to 4.7.0 and upgraded
flutter version to 3.19 because reloading the webview requires a webview
controller, also added another stream for this purpose
Copy link
Member

@justary27 justary27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done, fix the eof and remove the build files from vcs.

noticeboard/lib/enum/current_widget_enum.dart Show resolved Hide resolved
@pranavkonidena pranavkonidena self-assigned this Feb 27, 2024
@justary27 justary27 merged commit 1f5b5e4 into IMGIITRoorkee:beta Feb 27, 2024
1 check failed
@pranavkonidena pranavkonidena deleted the Feat/ConnectivityInterceptor branch February 27, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants