Conditionally render labels button when media exists in post (#5942)

* conditionally render button

* update labels on remove

* tweak
This commit is contained in:
Hailey
2024-10-25 14:52:37 -07:00
committed by GitHub
parent d520dd95b9
commit e05b4a910f
3 changed files with 120 additions and 139 deletions
+15
View File
@@ -158,6 +158,7 @@ export function composerReducer(
}
case 'embed_remove_image': {
const prevMedia = state.embed.media
let nextLabels = state.labels
if (prevMedia?.type === 'images') {
const removedImage = action.image
let nextMedia: ImagesMedia | undefined = {
@@ -168,9 +169,13 @@ export function composerReducer(
}
if (nextMedia.images.length === 0) {
nextMedia = undefined
if (!state.embed.link) {
nextLabels = []
}
}
return {
...state,
labels: nextLabels,
embed: {
...state.embed,
media: nextMedia,
@@ -220,8 +225,13 @@ export function composerReducer(
if (prevMedia?.type === 'video') {
nextMedia = undefined
}
let nextLabels = state.labels
if (!state.embed.link) {
nextLabels = []
}
return {
...state,
labels: nextLabels,
embed: {
...state.embed,
media: nextMedia,
@@ -258,8 +268,13 @@ export function composerReducer(
}
}
case 'embed_remove_link': {
let nextLabels = state.labels
if (!state.embed.media) {
nextLabels = []
}
return {
...state,
labels: nextLabels,
embed: {
...state.embed,
link: undefined,