Topic revisited (issue solved) - History or previously viewed pages

While looking for a similar answer to a question, I came across a topic started by @neitham and commented on by @Erik. The question was regarding creating a list of “recently viewed pages” or some sort of history log for users, but ideally without duplicating visited pages in the list. The original forum post is below.

I’ve been working on a business listing app. I had already implemented a history log. Basically, anytime a button or other trigger to view a detailed page was pressed, an action would create a new record to the History Log collection.

It worked great, but the problem was that the list would show duplicates for every time a page was visited. While testing the app, this led to 10 or 20 records of the same business being listed in the History Log for a user. That got annoying, even though I did have a button to clear history. I finally found a solution though. The action triggers I spoke about early…I did some tweaking to. Instead of the action performing always, I made it perform sometimes and only if the logged in user’s history log did not contain the current listing.

To my surprise, it worked. I cleared my history log, so it was fresh. I visited a business page, backed out and viewed my log. As intended, it showed the new visited listing. I revisited the same page and went to my history log to see that there was no duplicate. I visited a new page and then went to visit the first page…went to my log and there was now two records, but only one for each page visited.