Skip to content

Commit

Permalink
未ログイン時にお気に入りボタンなどを消した
Browse files Browse the repository at this point in the history
  • Loading branch information
kgtkr committed Jan 24, 2024
1 parent 3c24c50 commit 949e309
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
13 changes: 12 additions & 1 deletion packages/client/src/components/tags-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
usePrefixedStorageCollection,
} from "../domains/entities/storage/StorageCollectionHooks";
import { FavoriteTags } from "../domains/entities/storage/FavoriteTags";
import { useUserContext } from "../hooks";

export interface TagsInputProps {
value: ReadonlyArray<string>;
Expand All @@ -23,6 +24,7 @@ export function TagsInput({ value, onChange, fullWidth }: TagsInputProps) {
const [deleteTag] = useDeleteStorage(FavoriteTags);
const [setTag] = useSetStorage(FavoriteTags);
const { data, loading } = GA.useFindTopicTagsQuery();
const userContext = useUserContext();

// TODO: `useFindTopicTagsQuery` error handling

Expand All @@ -43,9 +45,18 @@ export function TagsInput({ value, onChange, fullWidth }: TagsInputProps) {
{...getTagProps({ index })}
key={option}
icon={
tagsSet.has(option) ? <Icon>star</Icon> : <Icon>star_border</Icon>
userContext.value !== null ? (
tagsSet.has(option) ? (
<Icon>star</Icon>
) : (
<Icon>star_border</Icon>
)
) : undefined
}
onClick={() => {
if (userContext.value === null) {
return;
}
if (tagsSet.has(option)) {
deleteTag({ tag: option });
} else {
Expand Down
18 changes: 10 additions & 8 deletions packages/client/src/pages/topic/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,16 @@ export const TopicPage = (_props: {}) => {
>
ジャンプ
</MenuItem>
<MenuItem
onClick={() => {
setAnchorEl(null);
dispatch({ type: "CLICK_OPEN_NG_MODAL" });
}}
>
NG
</MenuItem>
{user.value !== null && (
<MenuItem
onClick={() => {
setAnchorEl(null);
dispatch({ type: "CLICK_OPEN_NG_MODAL" });
}}
>
NG
</MenuItem>
)}
</Menu>
</div>
</Paper>
Expand Down

0 comments on commit 949e309

Please sign in to comment.