Problem:  A user is awarded points for downloading an app that is in their list of app offers. Since we have to pass the user on to the AppStore for the actual download process, we have no control over when to refresh and check if the offer was completed. Previously the user had to manually refresh the page every time for that app offer to go away (since he/she had completed it). If they downloaded more than one app, it would become a tedious process.

Solution:  Use Angular’s window focus detection to refresh the page and make API calls again. Since the user is passed on to the AppStore, they would have to come back to our app to check if the offer was completed and to see if it was gone from their list. Coming from another app back to FeaturePoints would trigger Angular’s window focus function where it will refresh the page and therefore pulling in fresh data.

@HostListener('window:focus', ['$event'])
onFocus(event: any): void {
    if (this.downloading || this.app.shouldPageReload) {
        this.downloading = false;
        this.app.shouldPageReload = false;
        window.location.reload();
    }
};

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2b843f4a-6b68-4bfd-bb19-72049fce9942/window_focus_smaller_size.mov