Skip to content

Commit

Permalink
Social: Hide share status when no connection is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Aug 28, 2024
1 parent 9d6ccdc commit 4a3bb0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fixed share status being shown even if no connection is enabled
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useSelect } from '@wordpress/data';
import { PluginPostPublishPanel } from '@wordpress/edit-post';
import { store as editorStore } from '@wordpress/editor';
import { usePostMeta } from '../../hooks/use-post-meta';
import { usePostPrePublishValue } from '../../hooks/use-post-pre-publish-value';
import { store as socialStore } from '../../social-store';
import { ShareStatus } from './share-status';

Expand All @@ -11,7 +12,7 @@ import { ShareStatus } from './share-status';
* @return {import('react').ReactNode} - Post publish share status component.
*/
export function PostPublishShareStatus() {
const { isPublicizeEnabled: willPostBeShared } = usePostMeta();
const { isPublicizeEnabled } = usePostMeta();
const { featureFlags, postId, isPostPublised } = useSelect( select => {
const store = select( socialStore );

Expand All @@ -25,6 +26,12 @@ export function PostPublishShareStatus() {
};
}, [] );

const enabledConnections = usePostPrePublishValue(
useSelect( select => select( socialStore ).getEnabledConnections(), [] )
);

const willPostBeShared = isPublicizeEnabled && enabledConnections.length > 0;

if ( ! featureFlags.useShareStatus || ! willPostBeShared || ! isPostPublised ) {
return null;
}
Expand Down

0 comments on commit 4a3bb0d

Please sign in to comment.