Skip to content

Commit

Permalink
fix: disable tag buttons during updates, don't clear tag search facet…
Browse files Browse the repository at this point in the history
… when removing active tags
  • Loading branch information
robinpyon committed Feb 10, 2021
1 parent 625104a commit 139ba16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
7 changes: 6 additions & 1 deletion src/components/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ const Tag: FC<Props> = (props: Props) => {
<Text
muted={!isSearchFacetTag}
size={1}
style={{userSelect: 'none'}}
style={{
opacity: tag?.updating ? 0.25 : 1,
userSelect: 'none'
}}
textOverflow="ellipsis"
weight={isSearchFacetTag ? 'bold' : 'regular'}
>
Expand All @@ -89,6 +92,7 @@ const Tag: FC<Props> = (props: Props) => {
<ButtonContainer align="center" paddingRight={1} style={{flexShrink: 0}}>
{/* Edit icon */}
<Button
disabled={tag?.updating}
fontSize={1}
icon={EditIcon}
mode="bleed"
Expand All @@ -102,6 +106,7 @@ const Tag: FC<Props> = (props: Props) => {
/>
{/* Delete icon */}
<Button
disabled={tag?.updating}
fontSize={1}
icon={TrashIcon}
mode="bleed"
Expand Down
3 changes: 1 addition & 2 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import notifications, {
notificationsTagCreateCompleteEpic,
notificationsTagDeleteCompleteEpic
} from './notifications'
import search, {searchFacetTagRemoveEpic, searchFacetTagUpdateEpic} from './search'
import search, {searchFacetTagUpdateEpic} from './search'
import tags, {
tagsCreateEpic,
tagsDeleteEpic,
Expand Down Expand Up @@ -53,7 +53,6 @@ export const rootEpic = combineEpics(
notificationsAssetUpdateCompleteEpic,
notificationsTagCreateCompleteEpic,
notificationsTagDeleteCompleteEpic,
searchFacetTagRemoveEpic,
searchFacetTagUpdateEpic,
tagsCreateEpic,
tagsDeleteEpic,
Expand Down
24 changes: 0 additions & 24 deletions src/modules/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,30 +192,6 @@ export const searchQuerySet = (searchQuery: string): SearchQuerySetAction => ({
* EPICS *
*********/

/**
* Listen for tag delete completions:
* - clear tag search facet (if present and set to the recently deleted tag)
*/
export const searchFacetTagRemoveEpic = (
action$: Observable<TagsActions>,
state$: StateObservable<RootReducerState>
): Observable<SearchActions> =>
action$.pipe(
filter(isOfType(TagsActionTypes.DELETE_COMPLETE)),
withLatestFrom(state$),
mergeMap(([action, state]) => {
const currentSearchFacetTag = state.search.facets?.find(facet => facet.name === 'tag')

if (currentSearchFacetTag?.type === 'searchable') {
if (currentSearchFacetTag.value?.value === action?.payload?.tagId) {
return of(searchFacetsRemove('tag'))
}
}

return empty()
})
)

/**
* Listen for tag update completions:
* - update tag search facet (if present and set to the recently deleted tag)
Expand Down

0 comments on commit 139ba16

Please sign in to comment.