Feature Request: Live status refresh and REST endpoint (5-second polling) #5

Open
opened 2025-08-12 13:45:00 +00:00 by jfig · 0 comments
Owner

Currently the plugin fetches the SpaceAPI endpoint via ssi_get_status() and caches the result with a transient. The status badge only updates when a page is loaded; it never refreshes while the visitor stays on the page.

Proposed improvement

  • Register a WordPress REST API route (e.g., /wp-json/wp-spaceapi-consumer/status) that returns the current open/closed state. This route should call ssi_get_status() to retrieve the status and update the transient.
  • Enqueue a small JavaScript file with the block/shortcode that polls the new REST endpoint every 5 seconds and updates the badge’s text and CSS class accordingly. This will make the indicator live‑refreshing without requiring a page reload.
  • While the client‑side refresh is active, the server should re-fetch the remote SpaceAPI endpoint every 5 seconds so that the transient always contains fresh data.
  • Provide a filter or setting to allow administrators to adjust the polling interval if 5 seconds is too aggressive.

This feature would allow visitors to see real‑time changes in the space’s status and would provide a simple REST endpoint for other services to query.

Currently the plugin fetches the SpaceAPI endpoint via `ssi_get_status()` and caches the result with a transient. The status badge only updates when a page is loaded; it never refreshes while the visitor stays on the page. ### Proposed improvement * Register a WordPress REST API route (e.g., `/wp-json/wp-spaceapi-consumer/status`) that returns the current open/closed state. This route should call `ssi_get_status()` to retrieve the status and update the transient. * Enqueue a small JavaScript file with the block/shortcode that polls the new REST endpoint every **5 seconds** and updates the badge’s text and CSS class accordingly. This will make the indicator live‑refreshing without requiring a page reload. * While the client‑side refresh is active, the server should re-fetch the remote SpaceAPI endpoint every **5 seconds** so that the transient always contains fresh data. * Provide a filter or setting to allow administrators to adjust the polling interval if 5 seconds is too aggressive. This feature would allow visitors to see real‑time changes in the space’s status and would provide a simple REST endpoint for other services to query.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jfig/wp-spaceapi-consumer#5
No description provided.