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 deletion of shaders with the same names #68

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/global/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function Avatar({
style={{ borderRadius: '15px' }}
width={size}
height={size}
priority={true}
/>
) : displayNull ? (
<AccountCircleIcon style={{ height: size, width: size }} />
Expand Down
24 changes: 12 additions & 12 deletions components/profileshaders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,10 @@ export const ProfileShaders = props => {
};

const [, , deleteShader] = useShaderSerDe();
const [isRemoved, setIsRemoved] = useState({ index: null });
const handleDeleteShader = (row, index) => {
if (confirm(`Are you sure you want to delete shader #${row.id} "${row.name}"?`)) {
deleteShader(row.id);
setIsRemoved({ index });
const handleDeleteShader = (id, name) => {
if (confirm(`Are you sure you want to delete shader #${id} "${name}"?`)) {
deleteShader(id);
document.getElementById(`row-id-${id}`).style.display = 'none';
}
};

Expand All @@ -219,10 +218,10 @@ export const ProfileShaders = props => {
{props.rows
.slice()
.sort(getComparator(order, orderBy))
.map((row, index) => {
const labelId = `enhanced-table-checkbox-${index}`;
return !(isRemoved.index === index) ? (
<TableRow hover tabIndex={-1} key={row.name}>
.map(row => {
const elementId = `row-id-${row.id}`;
return (
<TableRow hover tabIndex={-1} key={row.id} id={elementId}>
<TableCell align="left">
<Image
height={TABLE_PREVIEW_HEIGHT}
Expand All @@ -232,11 +231,12 @@ export const ProfileShaders = props => {
row.thumb_url
)}
alt={row.name}
priority={true}
/>
</TableCell>
<TableCell
component="th"
id={labelId}
id={`row-name-${row.name}`}
scope="row"
padding="none"
>
Expand All @@ -250,15 +250,15 @@ export const ProfileShaders = props => {
<TableCell align="left">
<Button
onClick={() =>
handleDeleteShader(row, index)
handleDeleteShader(row.id, row.name)
}
>
Delete
</Button>
</TableCell>
) : null}
</TableRow>
) : null;
);
})}
</TableBody>
</Table>
Expand Down
Loading