Currently, I am dealing with an Angular 9 application that is hosted on Firebase and utilizes Firestore for its data storage. There is a perplexing issue that I haven't been able to figure out completely despite simplifying the app extensively. I will attempt to elucidate the problem below.
About the Application: The application consists of two main pages - Homepage and Transactions page. Both pages retrieve data from the "transactions" collection in Firebase. However, the homepage should display the 4 most recent transactions (sorted by date in descending order), while the Transactions page needs to show the 10 most profitable transactions (sorted by amount in descending order). Currently, I am logging the data to the console for debugging purposes. Before logging the data, there is some minor data manipulation happening as well (refer to code snippet below).
The Challenge: Upon initially loading the Homepage, I am able to view the 4 most recent transactions in the console, which is expected. However, upon navigating to the Transactions page, for a brief moment, the console displays the same 4 recent transactions again, although they are supposed to be exclusive to the Homepage. After this quick display, it then correctly logs the 10 most profitable transactions.
The Code: Below is a snippet of the code used for home.page.ts:
insert code here...
The code for transaction.page.ts follows a similar structure:
insert code here...
The Outcome: A summary of what is logged to the console during each stage of interaction is as follows
- Upon initial entry to the Home page (displaying 4 rows):
insert code output here...
- Transition to the Transactions page:
insert code output here...
The Enigma: Why does the console re-display the same 4 rows from the Homepage when accessing it after navigating away?