How to make sure users sees content when it's due for publishing?

I have a forum in my app where users can publish new topics. A topic can be published directly or some time and date in the future. I want new topics to automatically appear on a forum if a user have the page open and the time is past the time set for publishing.

Initially, I tried setting up a AppVariable called Now with the following setting:
image
, and then use that filter as part of the initial filter on the runtime data source. Doing this will indeed prevent the data source from containing topics that should only be visible in the future, but if someone publishes a new topic directly, the data source would not reflect this unless the page was refreshed. This leads me to the conclusion that Now() contains the timestamp when the data source is initiated. It will not continue to read in new data when the time changes, even if “Initially subscribe to updates” is checked.

If I remove the PublishAt <= Now() from the filter, the data source will update when new topics are posted.

How can I design the app/data sources so that new topics will automatically appear on open pages when they pass the time of publishing? Or will such a design (when I get it working) have too much of a performance impact, so I should opt for a different design altogether? For example, by using a notification service that runs on a schedule?

Hello @lbj

For a straightforward solution, consider using a timer to periodically update your “now” variable every 1, 30, or 60 seconds, based on the level of precision you prefer for the display. If you don’t want to implement this on the client side, you might opt for setting it up within a service. This approach, however, necessitates an additional boolean property, such as “published,” in your datasource. This property should be marked true when the publishing date is on the current time within the scheduled service. This enables you to efficiently filter your datasource using the “published” property instead of the “now” variable. Alternatively, you could provide a manual refresh option through a button that allows users to update the “now” variable themselves, thereby refreshing the articles on demand.

I hope this helps! If you have further questions, feel free to ask.

2 Likes