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

Test #235

Closed
wants to merge 353 commits into from
Closed

Test #235

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
353 commits
Select commit Hold shift + click to select a range
618eb91
clean
Kluskey Oct 2, 2024
bced4b4
auth fixes
Kluskey Oct 2, 2024
980b145
clean inner control bar
Kluskey Oct 2, 2024
4bb0d07
control bar, hierarchy
Kluskey Oct 2, 2024
66191ae
rm boilerplate from rtk
Kluskey Oct 2, 2024
1a88dba
rename
Kluskey Oct 2, 2024
4709f67
clean
Kluskey Oct 2, 2024
a0c1aa0
layout
Kluskey Oct 2, 2024
daccf59
fix build layout!
Kluskey Oct 2, 2024
59e40aa
control bar adjustments
Kluskey Oct 2, 2024
b285458
license update
Kluskey Oct 4, 2024
fff0c7c
update LICENSE
Kluskey Oct 4, 2024
faba9c4
license
Kluskey Oct 4, 2024
d1ff26e
add asset search + throttle
Kluskey Oct 4, 2024
5018245
redux-undo add
Kluskey Oct 5, 2024
575f355
fix build layout
Kluskey Oct 5, 2024
c9abaa1
add engine
Kluskey Oct 5, 2024
0d903f9
layout clean
Kluskey Oct 5, 2024
a591e51
search asset fix
Kluskey Oct 5, 2024
c0ec839
break out assets migration into separate file
Kluskey Oct 5, 2024
65c9972
home fix
Kluskey Oct 5, 2024
c0b0da9
text search assets
Kluskey Oct 5, 2024
3aa1544
add description, computed columns
Kluskey Oct 5, 2024
7646e71
name prefix search assets spaces
Kluskey Oct 5, 2024
d039d25
fix display
Kluskey Oct 5, 2024
abc791d
same
Kluskey Oct 5, 2024
e70bf12
asset search fixes
Kluskey Oct 5, 2024
da3157b
real time text search
Kluskey Oct 5, 2024
6af9f71
asset search
Kluskey Oct 5, 2024
dc9635b
add recent assets
Kluskey Oct 5, 2024
cf7d726
storage thumb
Kluskey Oct 5, 2024
64c191f
sidebar optimize
Kluskey Oct 5, 2024
9ed4918
basic file upload!
Kluskey Oct 5, 2024
019b1ea
lift dropzone
Kluskey Oct 5, 2024
eb48c35
update asset url to be id not name
Kluskey Oct 5, 2024
756a279
dropzone
Kluskey Oct 5, 2024
5b78ca8
copy
Kluskey Oct 5, 2024
8c983a9
border
Kluskey Oct 5, 2024
bfbc000
asset tags
Kluskey Oct 5, 2024
ceb84ff
key prop
Kluskey Oct 5, 2024
1ea0024
add right click download asset
Kluskey Oct 5, 2024
2d9e312
x toggle
Kluskey Oct 5, 2024
9b2b5c8
basic scene ui
Kluskey Oct 5, 2024
84ba467
del scene
Kluskey Oct 5, 2024
5dddcfd
scene name edit
Kluskey Oct 5, 2024
1aabeaa
hover on scene
Kluskey Oct 5, 2024
46ae5d8
clean
Kluskey Oct 5, 2024
2b07c11
two way input polish
Kluskey Oct 5, 2024
1055da3
add entities crud
Kluskey Oct 5, 2024
c2dfea3
change from hover to click sidebar
Kluskey Oct 5, 2024
1807ffd
local
Kluskey Oct 5, 2024
dcb8697
near bsic tree
Kluskey Oct 5, 2024
60c5012
formatting
Kluskey Oct 5, 2024
fe20af6
clean format
Kluskey Oct 5, 2024
05137ea
depth fix + dragdrop
Kluskey Oct 5, 2024
55b798e
node key dragdrop clea
Kluskey Oct 6, 2024
a22c73f
drag drop keep parent open
Kluskey Oct 6, 2024
dbcc8e8
clean
Kluskey Oct 6, 2024
2132376
WIP
Kluskey Oct 6, 2024
9924a8a
boilerplate working
Kluskey Oct 6, 2024
dd15f8b
import
Kluskey Oct 6, 2024
bf14ac3
working bg
Kluskey Oct 6, 2024
9bd9354
clean
Kluskey Oct 6, 2024
d2d14c4
hide action menu tree item
Kluskey Oct 6, 2024
5095423
child type rm
Kluskey Oct 6, 2024
1653717
rm movedialog
Kluskey Oct 6, 2024
18c798d
clean
Kluskey Oct 6, 2024
bd38fac
clean
Kluskey Oct 6, 2024
a45000e
clean
Kluskey Oct 6, 2024
3e61b50
clean
Kluskey Oct 6, 2024
4983af3
basic scene crud
Kluskey Oct 6, 2024
4153466
add currentscene
Kluskey Oct 6, 2024
639428c
entity work
Kluskey Oct 6, 2024
831ea27
working entities crud
Kluskey Oct 7, 2024
076f5fd
break slices into different files
Kluskey Oct 7, 2024
2db7c9c
cache polish
Kluskey Oct 7, 2024
8252dd5
add component CRUD
Kluskey Oct 7, 2024
c194b52
clean
Kluskey Oct 7, 2024
9b10f04
component entities updates
Kluskey Oct 7, 2024
b2528fd
rm component name
Kluskey Oct 7, 2024
c954a3f
entities
Kluskey Oct 7, 2024
008ef65
create scene upon space creation
Kluskey Oct 7, 2024
dae06b1
entity children setup
Kluskey Oct 7, 2024
ca8569f
updatable entity name hierarchy
Kluskey Oct 7, 2024
724d574
basic parent update setup
Kluskey Oct 7, 2024
105ebb5
working child tree item saving
Kluskey Oct 7, 2024
7113627
optional children add
Kluskey Oct 7, 2024
0c6a2ce
clean
Kluskey Oct 7, 2024
ec7fde6
bug fixes for cachcing
Kluskey Oct 7, 2024
3e0409f
working reordering of entities!
Kluskey Oct 7, 2024
d2bd909
optimize entity queries
Kluskey Oct 8, 2024
7b0ceda
working .children refactor pt 1
Kluskey Oct 8, 2024
bcb2979
clean the junk
Kluskey Oct 8, 2024
4d83fd0
clean more atlassian junk
Kluskey Oct 8, 2024
f974c59
packages
Kluskey Oct 8, 2024
8787011
progress
Kluskey Oct 8, 2024
26fa74a
hook up entities
Kluskey Oct 8, 2024
fab88cd
cleaning tree
Kluskey Oct 8, 2024
4f0447d
root entity
Kluskey Oct 8, 2024
13deafa
sidebar size fix
Kluskey Oct 8, 2024
402df2a
fix for input firing w/o change
Kluskey Oct 8, 2024
0f5937d
progress on saving entity
Kluskey Oct 8, 2024
4404ea7
tree mostly working
Kluskey Oct 8, 2024
690d947
clean query
Kluskey Oct 8, 2024
c5c3626
clean query
Kluskey Oct 8, 2024
f50dd5b
clean query
Kluskey Oct 8, 2024
38b3b3e
add constraint that parent_id can't be entity_id
Kluskey Oct 8, 2024
ba237a2
fix circular tree references
Kluskey Oct 8, 2024
52f2e58
clean
Kluskey Oct 8, 2024
cf65de8
scene switching
Kluskey Oct 9, 2024
bf5677d
viewport spacing fixes
Kluskey Oct 9, 2024
c7ce45a
fix entity API errors
Kluskey Oct 9, 2024
2042751
motion duration
Kluskey Oct 9, 2024
d776e65
persist entity expanded/collapsed across renders
Kluskey Oct 9, 2024
736b704
persist scene open closed across renders
Kluskey Oct 9, 2024
933b96f
boilerplate playcanvas add
Kluskey Oct 9, 2024
e4d5ddb
play button
Kluskey Oct 9, 2024
a43dc5b
play build working
Kluskey Oct 9, 2024
f78b6cb
typo
Kluskey Oct 9, 2024
75e1a35
clean
Kluskey Oct 9, 2024
7cd5498
new scene creates 2 entities
Kluskey Oct 9, 2024
d7ba791
scene creation updates anf cies
Kluskey Oct 9, 2024
3322712
polish buttons
Kluskey Oct 9, 2024
8d1feef
fix auto expanded entities
Kluskey Oct 9, 2024
081b64d
more fixes
Kluskey Oct 9, 2024
116e8bf
font fixes
Kluskey Oct 9, 2024
12c0c1f
entity tree clean
Kluskey Oct 10, 2024
4a49d1a
add focus color entity
Kluskey Oct 10, 2024
8783825
fix sidebar spacing
Kluskey Oct 10, 2024
1f8af5b
add analytics base
Kluskey Oct 10, 2024
a449b95
add ga
Kluskey Oct 10, 2024
93c63cf
analytics update
Kluskey Oct 10, 2024
55663f0
analytics fixes
Kluskey Oct 10, 2024
7b0826f
clean
Kluskey Oct 10, 2024
a983da7
clean
Kluskey Oct 10, 2024
c500a81
effects for pc update 1
Kluskey Oct 10, 2024
797f426
inspector v0
Kluskey Oct 10, 2024
bd2748a
update input styling
Kluskey Oct 10, 2024
ad51925
clean autocomplete
Kluskey Oct 10, 2024
af3940e
separator
Kluskey Oct 10, 2024
428d79e
two way input polish
Kluskey Oct 10, 2024
b6a87d4
fix space viewport
Kluskey Oct 11, 2024
4d85d42
clean + home redirects
Kluskey Oct 11, 2024
62826b4
home redir
Kluskey Oct 11, 2024
6e384f6
license text updaet
Kluskey Oct 11, 2024
debe00b
license
Kluskey Oct 11, 2024
7d2a4dc
upgrade deps + pin node 22
Kluskey Oct 11, 2024
dea03a6
fix window undefined
Kluskey Oct 11, 2024
8611618
fix window is not defined error, remove ga
Kluskey Oct 11, 2024
94dba55
clean
Kluskey Oct 11, 2024
94ac340
fix canvas fill mode
Kluskey Oct 11, 2024
895dc79
fix entity font
Kluskey Oct 11, 2024
acbe2af
polish entity tree
Kluskey Oct 11, 2024
c99372d
entity polish
Kluskey Oct 11, 2024
98d8bd7
fix entity selection
Kluskey Oct 11, 2024
8a1c3b8
fix switcher css
Kluskey Oct 11, 2024
76d3aab
polish
Kluskey Oct 11, 2024
f4b2627
polish
Kluskey Oct 11, 2024
36fb142
abstract entity formgroup
Kluskey Oct 11, 2024
9628a6c
entity form group design
Kluskey Oct 11, 2024
b273ca3
working vec3 entity update
Kluskey Oct 11, 2024
0fb4fb7
vec3 inputs working nicely
Kluskey Oct 11, 2024
867a5dc
clean
Kluskey Oct 11, 2024
df10cf2
fix generic entity
Kluskey Oct 11, 2024
7f58f9e
prevent default on enter key
Kluskey Oct 11, 2024
af88a24
inspector entity name
Kluskey Oct 11, 2024
3e29db5
rename synced text input
Kluskey Oct 11, 2024
8e22a17
rename vec3 input
Kluskey Oct 11, 2024
fc821e7
text input polish
Kluskey Oct 11, 2024
616387e
add enabled checkbox
Kluskey Oct 12, 2024
01f2efc
rename synced text input
Kluskey Oct 12, 2024
8d87c45
fix issue with entity batch update; add unique check
Kluskey Oct 12, 2024
ce03a93
boilerplate viewport
Kluskey Oct 12, 2024
809f2ca
add vscode debugging
Kluskey Oct 12, 2024
c306515
clean
Kluskey Oct 12, 2024
d144e5a
add in engine defaults
Kluskey Oct 12, 2024
7839023
basic proj import working
Kluskey Oct 12, 2024
77e67ba
build and play
Kluskey Oct 12, 2024
d3d0470
play fix
Kluskey Oct 12, 2024
067b31a
build view
Kluskey Oct 12, 2024
f00827c
its beautiful
Kluskey Oct 12, 2024
e30b17c
note
Kluskey Oct 12, 2024
d9df474
clean
Kluskey Oct 12, 2024
79eb20d
fix loading errors
Kluskey Oct 12, 2024
02ed3e4
fix z index
Kluskey Oct 12, 2024
2f25884
fix loading bug
Kluskey Oct 12, 2024
50b5129
add appearance transition
Kluskey Oct 12, 2024
9fc22c9
note
Kluskey Oct 12, 2024
22a3c07
clean
Kluskey Oct 12, 2024
4f4368a
fix build mode script
Kluskey Oct 12, 2024
98c1ede
clean start scripts
Kluskey Oct 12, 2024
468d542
change to start custom
Kluskey Oct 12, 2024
ef69be6
move start script
Kluskey Oct 12, 2024
4a95830
rename for space viewport v2
Kluskey Oct 12, 2024
1c59e1c
comment
Kluskey Oct 12, 2024
232d3c5
file upload initial working
Kluskey Oct 12, 2024
b866553
supabase upload working
Kluskey Oct 12, 2024
fa6f85d
abstract
Kluskey Oct 12, 2024
bcb4ec5
nearly working; WIP. About to change to runtime import
Kluskey Oct 12, 2024
cd4e0c4
WORKING IMPORT!
Kluskey Oct 12, 2024
01384d2
fix play mode
Kluskey Oct 12, 2024
17e457e
comment
Kluskey Oct 12, 2024
99caa5b
add prettier
Kluskey Oct 13, 2024
d9695ce
prettier ignore
Kluskey Oct 13, 2024
c7e05fc
run prettier on ts/tsx
Kluskey Oct 13, 2024
15b044b
fix spacing of inspector, sidebar
Kluskey Oct 13, 2024
b63078c
rm components
Kluskey Oct 13, 2024
c3bd696
change asset, scene, space id to bigint unique
Kluskey Oct 13, 2024
f2e3c50
add space_packs
Kluskey Oct 13, 2024
908500d
update ids to numbers where appropriate
Kluskey Oct 13, 2024
d232258
node version fix
Kluskey Oct 13, 2024
ea67c29
node 20 restrict
Kluskey Oct 13, 2024
bd03c4a
rm ga
Kluskey Oct 13, 2024
ebee8a9
type scenesApi
Kluskey Oct 13, 2024
e98e577
add spacepacks api
Kluskey Oct 13, 2024
f8eb12a
space packs replace pc import
Kluskey Oct 13, 2024
540b64e
rm pcimports
Kluskey Oct 13, 2024
ca6c36d
rename
Kluskey Oct 13, 2024
dd3fa33
type analytics events
Kluskey Oct 14, 2024
975951b
analytics types + api types
Kluskey Oct 14, 2024
f344269
rm engine manager old code
Kluskey Oct 14, 2024
d83f41d
rename local state, add space-packs.state
Kluskey Oct 14, 2024
e07b892
create base spacePacks slice
Kluskey Oct 14, 2024
91bf99a
typing, space packs, settings jsonb
Kluskey Oct 14, 2024
7e8f4ed
manifest file
Kluskey Oct 14, 2024
277c9d8
numerous fixes + work toward spackpack slice
Kluskey Oct 14, 2024
6346657
commen
Kluskey Oct 14, 2024
d8fcd7a
start script progress
Kluskey Oct 14, 2024
bc56d6d
analytics updates
Kluskey Oct 14, 2024
0df444f
clean spaceviewport + anims
Kluskey Oct 15, 2024
4ea31ba
clean
Kluskey Oct 15, 2024
3c74118
comment
Kluskey Oct 15, 2024
e143365
engine/viewport clean
Kluskey Oct 15, 2024
c3396a6
db types
Kluskey Oct 15, 2024
e571bf6
start fix
Kluskey Oct 15, 2024
1a94444
it appeared!
Kluskey Oct 15, 2024
4c26fc1
clean
Kluskey Oct 15, 2024
40818af
transition speed
Kluskey Oct 15, 2024
9a7d72a
fix scene creation not creating root entity
Kluskey Oct 15, 2024
fb1540a
fix get entity
Kluskey Oct 15, 2024
3ac0839
fix entities
Kluskey Oct 15, 2024
8fc6bfe
add redux subscribers for pc updates
Kluskey Oct 15, 2024
9f3e4ad
clean
Kluskey Oct 15, 2024
c5d0de2
add components, data jsonb
Kluskey Oct 15, 2024
778f373
update db types
Kluskey Oct 15, 2024
e3ce597
control bar gap
Kluskey Oct 15, 2024
46637dd
add create component button
Kluskey Oct 15, 2024
7feef88
add c
Kluskey Oct 15, 2024
3c82b2a
add components crud on entity
Kluskey Oct 15, 2024
9e23ee2
update crud component
Kluskey Oct 15, 2024
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
Prev Previous commit
Next Next commit
working entities crud
  • Loading branch information
Kluskey committed Oct 7, 2024
commit 831ea279c7c92f5d9e2e2e7afe78cb1ac4e9a768
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import TreeItem from '@/components/tree-view/tree-item';
import { cn } from '@/utils/cn';
import { Button } from '@/components/ui/button';
import { PlusCircleIcon } from 'lucide-react';
import { useCreateEntityMutation } from '@/state/supabase';
import { useCreateEntityMutation, useGetAllEntitiesQuery } from '@/state/supabase';
import { useAppSelector } from '@/hooks/hooks';
import { getCurrentScene } from '@/state/local';

Expand Down Expand Up @@ -64,7 +64,10 @@ function createTreeItemRegistry() {

export default function EntityHierarchy() {
const currentScene = useAppSelector(getCurrentScene)
const [state, updateState] = useReducer(treeStateReducer, null, getInitialTreeState);
const entities = useGetAllEntitiesQuery(currentScene)
console.log('entities', entities);

const [state, updateState] = useReducer(treeStateReducer, entities, getInitialTreeState);
const [createEntity, { data: createdEntity }] = useCreateEntityMutation();

const ref = useRef<HTMLDivElement>(null);
Expand Down
3 changes: 3 additions & 0 deletions mirror-2/app/space/[spaceId]/build/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default async function Layout({ children, params }: {
<Sidebar />
<InnerControlBar />
<SpaceViewport />

{/* only loading children for separate data fetching to keep this as server component */}
{children}
</div>
</div>
)
Expand Down
19 changes: 17 additions & 2 deletions mirror-2/app/space/[spaceId]/build/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
"use client"

import { useGetSingleSpaceQuery } from "@/state/supabase"
import { useAppDispatch } from "@/hooks/hooks"
import { setCurrentScene } from "@/state/local"
import { useGetSingleSpaceBuildModeQuery } from "@/state/supabase"
import { useParams } from "next/navigation"
import { useEffect } from "react"


// blank page since we're using the parallel routes for spaceViewport, controlBar, etc.
export default function Page() {
const params = useParams<{ spaceId: string }>()
const space = useGetSingleSpaceQuery(params.spaceId)
const { data: space, error } = useGetSingleSpaceBuildModeQuery(params.spaceId)

// after successful query, update the current scene to the first in the space.scenes array
const dispatch = useAppDispatch();
useEffect(() => {
// if no current Scene, set it to the first scene

if (space?.scenes.length > 0) {
console.log("setting current scene to first scene", space.scenes[0])
dispatch(setCurrentScene(space.scenes[0].id))
}
}, [space])

return null
}
15 changes: 1 addition & 14 deletions mirror-2/app/space/[spaceId]/build/space-viewport.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
"use client"

import { useAppDispatch, useAppSelector } from "@/hooks/hooks";
import { getCurrentScene, setCurrentScene } from "@/state/local";
import { useGetAllEntitiesQuery, useGetAllScenesQuery } from "@/state/supabase";
import { useParams } from "next/navigation";
import { useEffect } from "react";

export default function SpaceViewport() {
// get all entities for the scene. may move this to a loader in the future
const params = useParams<{ spaceId: string }>()
const { data: scenes } = useGetAllScenesQuery(params.spaceId);
const { data: entities } = useGetAllEntitiesQuery(params.spaceId);
const currentScene = useAppSelector(getCurrentScene)
const dispatch = useAppDispatch();
useEffect(() => {
if (!currentScene) {
// if no current Scene, set it to the first scene
if (scenes && scenes.length > 0) {
console.log("setting current scene to first scene", scenes[0])
dispatch(setCurrentScene(scenes[0].id))
}
}
}, [])


return (
<main className="h-full">
Expand Down
6 changes: 4 additions & 2 deletions mirror-2/components/tree-view/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ export type TreeState = {
data: TreeItem[];
};

export function getInitialTreeState(): TreeState {
export function getInitialTreeState(initial): TreeState {
console.log('initial', initial);
return { data: getInitialData(), lastAction: null };
}

export function getInitialData(): TreeItem[] {

return [
{
id: '1',
isOpen: true,
isOpen: false,

children: [
{
Expand Down
84 changes: 75 additions & 9 deletions mirror-2/state/supabase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface CreateAssetMutation {
export const supabaseApi = createApi({
reducerPath: 'supabaseApi',
baseQuery: fakeBaseQuery(),
tagTypes: ['Assets', 'Spaces', 'Scenes', 'Entities', 'Users'],
tagTypes: ['Assets', 'Spaces', 'Scenes', 'Entities', 'Components', 'Users'],
endpoints: (builder) => ({

/**
Expand All @@ -40,8 +40,10 @@ export const supabaseApi = createApi({
return { error: error.message };
}
return { data };
}
}),
},
invalidatesTags: ['Spaces']
},
),

getSingleSpace: builder.query<any, string>({
queryFn: async (spaceId) => {
Expand All @@ -57,6 +59,61 @@ export const supabaseApi = createApi({
return { error: error.message };
}
return { data };
},
providesTags: (result, error, spaceId) => [{ type: 'Spaces', id: spaceId }]
}),

/**
* Helper: includes scenes, entities, assets, etc.
*/
getSingleSpaceBuildMode: builder.query<any, string>({
queryFn: async (spaceId) => {
const supabase = createSupabaseBrowserClient();

// Nested select with joins for scenes, entities, and components
const { data, error } = await supabase
.from("spaces")
.select(`
*,
scenes (
*,
entities (
*,
components (*)
)
)
`)
.eq("id", spaceId)
.single();

if (error) {
return { error: error.message };
}

return { data };
},
providesTags: (result, error, spaceId) => {
if (result) {
// Extract scene, entity, and component ids for proper tag management
const sceneIds = result.scenes?.map(scene => ({ type: 'Scenes', id: scene.id })) || [];
const entityIds = result.scenes?.flatMap(scene =>
scene.entities?.map(entity => ({ type: 'Entities', id: entity.id }))
) || [];
const componentIds = result.scenes?.flatMap(scene =>
scene.entities?.flatMap(entity =>
entity.components?.map(component => ({ type: 'Components', id: component.id }))
)
) || [];

// Return tags for space, scenes, entities, and components
return [
{ type: 'Spaces', id: spaceId },
...sceneIds,
...entityIds,
...componentIds
];
}
return [{ type: 'Spaces', id: spaceId }];
}
}),

Expand All @@ -74,7 +131,8 @@ export const supabaseApi = createApi({
return { error: error.message };
}
return { data };
}
},
invalidatesTags: (result, error, { spaceId }) => [{ type: 'Spaces', id: spaceId }], // Invalidate tag for spaceId
}),


Expand Down Expand Up @@ -270,6 +328,10 @@ export const supabaseApi = createApi({
return { error: 'User not found' };
}

if (!space_id) {
return { error: 'No spaceId provided' };
}

const { data, error } = await supabase
.from("scenes")
.insert([{
Expand All @@ -286,7 +348,7 @@ export const supabaseApi = createApi({
}
return { data };
},
invalidatesTags: (result, error, { space_id }) => [{ type: 'Scenes', id: space_id }], // Invalidate the tag for the specific space_id
invalidatesTags: (result, error, { space_id }) => [{ type: 'Scenes', id: space_id }], // Invalidate the tag for the specific space_id. TODO check this tag logic
}),

/**
Expand Down Expand Up @@ -385,6 +447,10 @@ export const supabaseApi = createApi({
return { error: 'User not found' };
}

if (!scene_id) {
return { error: 'No scene_id provided' };
}

const { data, error } = await supabase
.from("entities")
.insert([{
Expand All @@ -401,7 +467,7 @@ export const supabaseApi = createApi({
}
return { data };
},
invalidatesTags: (result, error, { scene_id }) => [{ type: 'Entities', id: scene_id }], // Invalidate the tag for the specific scene_id
invalidatesTags: ['Entities'] // TODO optimize this
}),

getAllEntities: builder.query<any, string>({
Expand All @@ -418,8 +484,8 @@ export const supabaseApi = createApi({
}
return { data };
},
providesTags: (result, error, sceneId) =>
result ? [{ type: 'Entities', id: sceneId }] : [], // Provide tag for sceneId
providesTags: (result, error, entityId) =>
result ? [{ type: 'Entities', id: entityId }] : [], // Provide tag for entityId
}),

getSingleEntity: builder.query<any, string>({
Expand Down Expand Up @@ -486,7 +552,7 @@ export const {
/**
* Spaces
*/
useGetSingleSpaceQuery, useUpdateSpaceMutation, useCreateSpaceMutation,
useGetSingleSpaceQuery, useUpdateSpaceMutation, useCreateSpaceMutation, useGetSingleSpaceBuildModeQuery,


/**
Expand Down