Advice: I'm trying to make a tracking time feature in my application but when should I send the data to the backend - reactjs

I'm making a client management system in Laravel and ReactJS. I use Laravel for the backend and the api and ReactJS (with Context API) for the frontend of course.
I want to add a tracking timer into my application so the idea is that you can click on a button and select a client and it will start a timer, when you click on the stop button it will stop the timer and the time passed, is how much you spend working for that client.
My question is when should I send the time spend to the backend API?
My ideas:
After the users clicked on the stop button.
Every single minute (but with this technique the client will send a lot of requests to the backend).
NOTE: When a user refreshes the page the timer needs to continue where it left off.
Does anyone have some advice on how to do this?

From your requirement, I guess that's fair enough when the stop button is clicked. In fact, you may capture the date-time
once start is clicked
once again when the stop button is clicked also find the difference between these two to identify the time consumed in your client application.
This way, refreshing the page will have no impact since these are loosely coupled.

Related

Working with a web extension native-messaging API in multiple tab scenario

I'm trying to understand how to properly handle a multiple-tab scenario for web extension that, through the native-messaging API, utilizes a locally stored application through a runtime communication port.
I have one set up and working; but I don't understand what is supposed to take place when more than one browser tab uses the native application. I was planning on opening the native application only once to handle requests from all tabs that can use it, but am uncertain now. I should probably state that the application remains open and listening for new requests rather than closing after each individual request. It's opened by the background script which handles the requests from each tab's content script.
What happens if a request to the native application from one tab is still processing and a user switches to another tab and sends an additional request to the same native application? Will both requests process, is the second blocked, or will the first cease mid way and the second begin?
I can alter the set up to open a separate instance of the native application for each tab. At least I can see multiple processes open in the task manager rather than one only, when I do this.
Even in the scenario of one instance of the native application per browser tab, what happens if the user clicks the button twice, so to speak, before the first request completes? Should there always be a native_app_busy check that ignores the second request if the first is still processing?
I have a lot of experimenting to do, of course, but thought it prudent to ask how it is supposed to work. Thank you.

How to have a screen intermittently render in React Native (with Expo)

I'm building a React Native (with Expo) app and have a survey form screen that I want to have appear intermittently for the user to fill out. Let's call it SurveyScreen. I'm doing this by setting a setInterval to poll the backend server hourly for scheduling data to see if the user is due to fill out a survey. This will probably be done in the main App.js in componentDidMount
The above seems straightforward to me. What I'm not clear on is once the polling api determines that the user is due for a survey, how to have the app display SurveyScreen no matter what page the user is on in the app.
One point of clarification is should SurveyScreen appear immediately after receiving a green light api response or should the screen appear after the next user action, e.g. navigation to another page, tap a button, etc? I think either way would be fine at this point. Would love to know both ways if possible.
Any ideas? Thanks.
Update the state.
Example: you subscribe to api => event fires => you update state => survey pops up
You can use portal to easily position survey on top of everything.

Xamarin forms - Periodic list view data refresh

We are building Xamarin forms app to run on iOS, Android and Windows 10. We are data binding view model to UI which has List View control. We want the data to be refreshed from rest service, every 3-5 seconds when user is viewing the app. We don't want the data to refresh when app is in background, but refresh the data as soon as app is foreground. I tried using Xamarin.Forms.Device.StartTimer and await Task.Delay, but this does not seem to be working very well, sometimes the data does not refresh when not in interactive debug mode especially with Xamarin.Forms.Device.StartTimer , I am not sure what is going wrong as I am not able to do logging on device. On using await Task.Delay, sometimes the Task gets cancelled. In app onresume event, code makes rest service call which fails with connection refused error.
So I wanted to know which is the best way to handle data refresh, any ideas?
Thanks in advance
At last to do periodic refresh, i used Task.Delay and a boolean variable to known whether refresh needs to be performed or not. If user navigates away from the page, i set the boolean variable to false to stop the refresh.

Scheduling app in ionic which triggers functions after specified time

I'm a newbie to Ionic app development and have a requirement for which I've mined the internet but in vain.
My requirement is as below:
The user can select a Time Period i.e say 3hrs from now, after this time period, a trigger will run within the app and will perform a certain function depending what the user has selected (like play music, send sms or email). I have my individual modules of code ready for playing music, sending sms or email.
I only need to know how to trigger those events in ionic.
The important part is that the trigger should work even when the app is closed, screen is locked and should also survive a reboot.
I've tried the following, http://www.gajotres.net/how-to-use-local-notifications-with-ionic-framework/ ,
https://github.com/wnyc/cordova-plugin-wakeuptimer ,
https://scotch.io/tutorials/build-a-real-time-scheduling-app-using-angularjs-and-firebase but could not meet my requirements and in Vain.
Please help me and guide me through this.
Thanks in Advance,
Thats not possible with ionic, as hack u can use local notification and schedule notification as per ur requirement, on tap u can call any other action.

How to integrate payment gateway in applications created using javascript frameworks like ExtJs?

Our application is a one-page application created using ExtJs. For any user action, the browser tab is never reloaded and all the actions are performed using ajax. A user can open/close multiple ExtJs windows/panels within the same browser tab, and this way everything remains confined to the same browser tab.
Now, we need to integrate payment gateway in the application, which involves redirecting the user to the bank website and having her brought back to our application.
The issue is that when browser redirects the user, then all the application javascript code along with panels and windows get destroyed, and when the user comes back to the application then she finds it to be different from one she left.
As a solution to this, we were thinking of using following two appraoches:
Option 1. Maintaining the state of application - When user leaves for the bank's website then somehow we maintain the state of application - like which windows are opened carrying what data, which variables have which values etc.. and when user returns back, we generate the same application state for her.
Option 2. Have a browser pop-up window for payment gateway - We intend to provide a button which will open a small pop-up window carrying the transaction details, and in this pop-up window the entire payment gateway process will take place taking care of redirection and everything.
Option 1 is proving to be very cumbersome and complicated as maintaining the exact state is not getting feasible.
For Option 2, we are not sure if this is safe and possible?
Has anyone implemented such an approach earlier. Otherwise, what are the other options which we can go for?
Thanks for any help in advance.
I faced the problem and I implemented it using websocket/polling in the main application while a new window pops up for the payment.
After the payment is successful the main application will be notified.
That way each payment runs in it own sandbox totally unbound from the main application which makes maintenance quite easy. Note that our backend create a new session for each payment using the existing one.
I think it is not uncommon to open new windows for payment that's why I decided to go this.

Resources