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

Reflect #32

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
77e030b
wip reflect implementation
jaredpereira Oct 9, 2023
a0885a9
Merge branch 'main' into reflect
jaredpereira Oct 18, 2023
f181cc6
more wip reflect implementation
jaredpereira Nov 2, 2023
1fc5252
update replicache, add initial space setup
jaredpereira Nov 16, 2023
f429789
update reflect
jaredpereira Nov 28, 2023
67f51e4
Merge branch 'main' into reflect
jaredpereira Nov 28, 2023
0efcdf0
fix rep.clientID no longer async
jaredpereira Nov 28, 2023
a99e7ff
fix index prefixes
jaredpereira Dec 4, 2023
f6323f3
get everything basically working
jaredpereira Dec 5, 2023
d78f433
tweaks to invite modal copy
bschlagel Nov 28, 2023
1447d6f
edited search placeholder to include keyboard shortcut hint
cyberspaceline Nov 28, 2023
6573002
reworked the people panel, did a bunch of stuff sorry i should've bro…
cyberspaceline Nov 29, 2023
60ba2eb
made rooms inside bar change style to indicate when they are in editi…
cyberspaceline Nov 29, 2023
3fc5398
fixed some minor spacing inconsistencies in room header
cyberspaceline Nov 29, 2023
db119ac
added chat room header back, also futzed with padding in room to make…
cyberspaceline Nov 29, 2023
762d81a
fix incorrect drag preview sizing
jaredpereira Nov 29, 2023
190a344
tiny cleanup for card date editing
bschlagel Nov 29, 2023
af80d17
don't lose focus in textarea when you switch windows
jaredpereira Nov 29, 2023
6296d67
added click on room description or name to edit them. moved card coun…
cyberspaceline Nov 30, 2023
9d57313
replaced find and create on double tap in canvas to create new card i…
cyberspaceline Nov 30, 2023
8ec73ad
fixed remove card from room logic
cyberspaceline Nov 30, 2023
3104dc4
fixed a bug where if card is dragged into card with no other linked c…
cyberspaceline Nov 30, 2023
124d08b
fixed an issue with dragging new small card where drag indicator was …
cyberspaceline Nov 30, 2023
3fc22c4
add an indicator to cards in you drag them onto a room on the sidebar
cyberspaceline Nov 30, 2023
cc477f3
made the room in sidebar highlight if you drag a card over it, adjust…
cyberspaceline Nov 30, 2023
3bd571f
made it such that cards created by new card button and cards dragged …
cyberspaceline Nov 30, 2023
e936ac2
fixed some typecheck issues
cyberspaceline Nov 30, 2023
9a05b07
fixed bug where removed card from linked card section was closing the…
cyberspaceline Dec 1, 2023
e6e3a03
scroll linked card section into view if card is dragged into card viewer
cyberspaceline Dec 1, 2023
6fa35bd
remove old console log
cyberspaceline Dec 1, 2023
8101603
fixed issue where collection dropzone id was conflicting, causing col…
cyberspaceline Dec 1, 2023
016acfa
made it so that when you drag a card out of search and then change yo…
cyberspaceline Dec 1, 2023
b4697a8
replaced the add card thing with a new icon and added a help text if …
cyberspaceline Dec 1, 2023
0e5e6e1
add on delete cascade constraint to space_events
jaredpereira Nov 30, 2023
e8f5b07
move message input state to global ui state
jaredpereira Dec 1, 2023
447df16
disabled dragged card indicator when dragging over room list item, al…
cyberspaceline Dec 1, 2023
b8761ff
if new card is dragged with new card button, the dragged card is now …
cyberspaceline Dec 1, 2023
5b9af1a
fixed an issue with addcard button help text where the help text was …
cyberspaceline Dec 1, 2023
ac8603f
fixed issue where invite button didn't show if no one was offline
cyberspaceline Dec 1, 2023
1d66d4b
fixed a big where cntl z with conflicting with browser shortcuts, fix…
cyberspaceline Dec 2, 2023
1419faf
fixed a small padding issue with chat message input
cyberspaceline Dec 2, 2023
dc6d964
reorganized card list options to mirror the options in card collectio…
cyberspaceline Dec 2, 2023
80dfc4d
fixed empty card view state to show on desktop and not show on mobile
cyberspaceline Dec 2, 2023
ad46e99
fixed relace new card with existing card to be not case specific
cyberspaceline Dec 2, 2023
b785b2e
fixed issue with unreliable title focusing when new card is created b…
cyberspaceline Dec 2, 2023
edf5ebc
tweak RoomDescription: render Textarea rather than RenderedText so te…
bschlagel Dec 4, 2023
88fd48e
bug: move drag type handling to switch in draggable card on desktop
cyberspaceline Dec 5, 2023
bb220df
make single request to postgres to update unreads
jaredpereira Dec 5, 2023
7288afb
validate env
jaredpereira Dec 5, 2023
2ae0d95
WIP
jaredpereira Dec 7, 2023
a1b7235
make space_unreads optional
jaredpereira Dec 7, 2023
4db6af2
use proper env in authHandler
jaredpereira Dec 7, 2023
8ed99bf
add message id to indexes
jaredpereira Dec 7, 2023
49496ac
store roomID in reflect
jaredpereira Dec 13, 2023
29da4bb
fix vae index
jaredpereira Dec 13, 2023
93e7d80
Merge branch 'main' into reflect
jaredpereira Dec 17, 2023
9c969d9
remove sync_notifications and internal_routes
jaredpereira Dec 17, 2023
a1495cd
delete get_card_data route
jaredpereira Dec 17, 2023
06da040
add back mistakenly removed mutation
jaredpereira Dec 17, 2023
0ef3458
validate user on join and leave, make run on server args obj
jaredpereira Dec 17, 2023
c3025ea
Merge branch 'main' into reflect
jaredpereira Jan 29, 2024
eb780d6
use user id not studio
jaredpereira Jan 31, 2024
2fe0a95
reorg env object for mutations
jaredpereira Jan 31, 2024
d66ac79
fix is authorized
jaredpereira Jan 31, 2024
a126512
publish reflect app
jaredpereira Jan 31, 2024
80a6c18
narrow types
jaredpereira Jan 31, 2024
3776abb
use idb for reflect
jaredpereira Jan 31, 2024
91ca3c9
remove comment
jaredpereira Jan 31, 2024
9cbc830
add deploy-reflect workflow
jaredpereira Jan 31, 2024
f3859e3
Merge branch 'main' into reflect
jaredpereira Feb 21, 2024
6fafc13
fix some things post merge idk
jaredpereira Feb 21, 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
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,23 @@ jobs:
- uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
deploy-reflect:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: npm install
run: |
npm install

- name: publish
env:
REFLECT_AUTH_KEY: ${{ secrets.REFLECT_AUTH_KEY }}
run: |
npx reflect publish --auth-key-from-env=REFLECT_AUTH_KEY
16 changes: 15 additions & 1 deletion app/s/[studio]/s/[space]/[display_name]/join/JoinSpace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { SpaceCard, SpaceData } from "components/SpacesList";
import { Divider } from "components/Layout";
import { WORKER_URL } from "src/constants";
import { useSearchParams } from "next/dist/client/components/navigation";
import { makeReflect } from "components/ReplicacheProvider";
import { ulid } from "src/ulid";

export function JoinSpace({ space_id }: { space_id: string }) {
let id = useSpaceID();
let { session, authToken } = useAuth();
Expand All @@ -22,12 +25,23 @@ export function JoinSpace({ space_id }: { space_id: string }) {
let { data } = useSpaceData({ space_id });

const onClick = async () => {
if (!authToken || !code || !id) return;
if (!authToken || !code || !id || !session.user) return;
let data = await spaceAPI(`${WORKER_URL}/space/${id}`, "join", {
authToken,
code,
});
if (data.success) {
let reflect = makeReflect({
roomID: id,
authToken,
userID: session.user.id,
});
if (session.session)
await reflect.mutate.joinSpace({
memberEntity: ulid(),
username: session.session.username,
studio: session.session.studio,
});
router.push(`/s/${query?.studio}/s/${query?.space}`);
}
};
Expand Down
15 changes: 14 additions & 1 deletion app/setup/SetupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { WORKER_URL } from "src/constants";
import { supabaseBrowserClient } from "supabase/clients";
import Image from "next/image";
import spotIllo from "public/img/spotIllustration/welcome.png";
import { makeReflect } from "components/ReplicacheProvider";
import { ulid } from "src/ulid";

export function SignupPageForm() {
let router = useRouter();
Expand Down Expand Up @@ -59,9 +61,20 @@ export function SignupPageForm() {
else router.push(`/s/${data.username}`);
}
}

if (res.success) {
let { data } = await supabase.auth.refreshSession();
if (data.session) {
if (data.user && data.session) {
let reflect = makeReflect({
roomID: data.user?.user_metadata.studio,
authToken: tokens,
userID: data.user.id,
});
reflect.mutate.joinSpace({
memberEntity: ulid(),
username: data.user?.user_metadata.username,
studio: data.user?.user_metadata.studio,
});
await supabase.auth.setSession(data?.session);
if (redirectTo) router.push(redirectTo);
else router.push(`/s/${data.user?.user_metadata.username}`);
Expand Down
25 changes: 9 additions & 16 deletions app/studio/[studio_id]/space/StudioPresenceHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"use client";
import { useMeetingState } from "@daily-co/daily-react";
import { ref } from "data/Facts";
import { useMutations } from "hooks/useReplicache";
import { useRoom } from "hooks/useUIState";
import { useAtomValue } from "jotai";
import { useEffect } from "react";
import { ulid } from "src/ulid";
import { SpaceProvider, socketStateAtom } from "components/ReplicacheProvider";
import { SpaceProvider } from "components/ReplicacheProvider";
import { SpaceData } from "components/SpacesList";
import { useParams } from "next/navigation";

Expand Down Expand Up @@ -46,22 +43,18 @@ export const SpacePageStudioPresenceHandler = (props: { space: SpaceData }) => {
);
};
export const PresenceHandler = (props: { space_do_id: string }) => {
let { rep, mutate, authorized, memberEntity, client, permissions } =
useMutations();
let { rep, mutate, authorized, memberEntity, client } = useMutations();
let room = useRoom();
let socketState = useAtomValue(socketStateAtom);

useEffect(() => {
if (!authorized || !rep || !memberEntity || socketState !== "connected")
return;
rep.clientID.then((clientID) => {
mutate("initializeClient", {
clientID,
clientEntity: ulid(),
memberEntity: memberEntity as string,
});
if (!authorized || !rep || !memberEntity) return;

mutate("initializeClient", {
clientID: rep.clientID,
clientEntity: ulid(),
memberEntity: memberEntity as string,
});
}, [rep, authorized, memberEntity, socketState, mutate]);
}, [rep, authorized, memberEntity, mutate]);

useEffect(() => {
if (!client?.entity || !authorized) return;
Expand Down
2 changes: 1 addition & 1 deletion backend/SpaceDurableObject/fact_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const store = (storage: BasicStorage, ctx: { id: string }) => {
},
};

let context: Omit<MutationContext, "runOnServer"> = {
let context: Omit<MutationContext, "runOnServer" | "tx"> = {
scanIndex,
updateFact: async (id, data) => {
return lock.withLock(async () => {
Expand Down
7 changes: 0 additions & 7 deletions backend/SpaceDurableObject/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ import { delete_file_upload_route } from "./routes/delete_file_upload";
import { get_share_code_route } from "./routes/get_share_code";
import { join_route } from "./routes/join";
import { pullRoute } from "./routes/pull";
import { push_route } from "./routes/push";
import { connect } from "./socket";
import { handleFileUpload } from "./upload_file";
import { migrations } from "./migrations";
import { delete_self_route } from "./routes/delete_self";
import { get_daily_token_route } from "./routes/get_daily_token";
import { post_feed_route } from "./routes/post_feed";
import { get_card_data_route } from "./routes/get_card_data";
import type { WebSocket as DOWebSocket } from "@cloudflare/workers-types";
import { createClient } from "backend/lib/supabase";

export type Env = {
factStore: ReturnType<typeof store>;
storage: DurableObjectStorage;
state: DurableObjectState;
poke: () => void;
Expand All @@ -30,16 +26,13 @@ export type Env = {
};

let routes = [
get_card_data_route,
pullRoute,
push_route,
claimRoute,
get_share_code_route,
join_route,
delete_file_upload_route,
delete_self_route,
get_daily_token_route,
post_feed_route,
];
export type SpaceRoutes = typeof routes;
let router = makeRouter(routes);
Expand Down
4 changes: 4 additions & 0 deletions backend/SpaceDurableObject/lib/isMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ export async function isUserMember(
isMember.members_in_studios.length > 0)
);
}

export function isAuthorized(env: Env, userID: string) {
return env.id === userID;
}
1 change: 1 addition & 0 deletions backend/SpaceDurableObject/migrations/2023-02-02.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
let promptRoom = rooms.find((r) => r.value === "prompts");
if (promptRoom) {
await fact_store.updateFact(promptRoom.id, {
//@ts-ignore
attribute: "promptroom/name",
value: "Prompt Pool",
});
Expand Down
1 change: 1 addition & 0 deletions backend/SpaceDurableObject/migrations/2023-09-04.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
let fact_store = store(storage, { id: "" });
let members = await fact_store.scanIndex.aev("space/member");
for (let member of members) {
//@ts-ignore
let color = await getMemberColor(fact_store);
await fact_store.assertFact({
entity: member.entity,
Expand Down
Loading