Skip to content

Commit

Permalink
Fix RSVP Guest Count in Query.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Jan 10, 2025
1 parent 235c173 commit 5bb1c8e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion build/blocks/rsvp-guest-count-display/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"example": {},
"attributes": {},
"usesContext": [
"commentId"
"commentId",
"gatherpress/rsvpResponses"
],
"supports": {
"align": [
Expand Down
2 changes: 1 addition & 1 deletion build/blocks/rsvp-guest-count-display/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-i18n'), 'version' => '6e170f08233749ccc34b');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-i18n'), 'version' => 'fa8b89d30ccf6aa5d10e');
4 changes: 2 additions & 2 deletions build/blocks/rsvp-guest-count-display/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/blocks/rsvp-guest-count-display/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"icon": "yes",
"example": {},
"attributes": {},
"usesContext": [ "commentId" ],
"usesContext": [ "commentId", "gatherpress/rsvpResponses" ],
"supports": {
"align": [ "left", "center", "right" ],
"spacing": {
Expand Down
13 changes: 3 additions & 10 deletions src/blocks/rsvp-guest-count-display/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { _n, sprintf } from '@wordpress/i18n';
import { useBlockProps } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies.
*/
import { getFromGlobal } from '../../helpers/globals';

/**
* Edit function for the RSVP Guest Count Display Block.
*
Expand All @@ -25,15 +20,13 @@ import { getFromGlobal } from '../../helpers/globals';
*/
const Edit = ({ context }) => {
const { commentId } = context;
const rsvpResponses = context?.['gatherpress/rsvpResponses'] ?? null;

// Example guest count.
let guestCount = 1;

if (commentId) {
const responses = getFromGlobal(
'eventDetails.responses.attending.responses'
);
const matchedResponse = responses.find(
if (commentId && rsvpResponses) {
const matchedResponse = rsvpResponses.attending.responses.find(
(response) => response.commentId === commentId
);

Expand Down

0 comments on commit 5bb1c8e

Please sign in to comment.