Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle if meta is undefined #138

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Conversation

markusahlstrand
Copy link
Contributor

If meta['sesamy-tags'] is undefined this would crash.

@@ -11,14 +11,6 @@ import { __ } from "@wordpress/i18n";
import { useEffect, useState, useMemo } from "@wordpress/element";
import { store as coreStore } from "@wordpress/core-data";

function* getPaymentOptions(enableTiers) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was not used.

@@ -50,8 +42,8 @@ const SesamyPostEditor = () => {
const meta = useSelect((select) =>
select("core/editor").getEditedPostAttribute("meta")
);
const tagMetaValue = meta["_sesamy_tags"].split("|");
//const sesamyTiersTaxonomy = wp.data.select('core').getEntityRecords('taxonomy', 'sesamy_passes');
const tagMetaValue = meta["_sesamy_tags"]?.split("|");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to null if not defined.

@@ -98,11 +90,11 @@ const SesamyPostEditor = () => {
};

const setTag = (tag, included) => {
var tag_array = tagMetaValue ? tagMetaValue : [];
let tag_array = tagMetaValue ? tagMetaValue : [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit cleaning aways some var's.

}
}
)
if (!data.sesamyItemSrc) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier fixes

Copy link

@frankjonatanschultz frankjonatanschultz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@markusahlstrand markusahlstrand merged commit 523c398 into master Nov 4, 2024
@markusahlstrand markusahlstrand deleted the ma/meta-undefined branch November 4, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants