Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions .idea/git_toolbox_blame.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion convex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function handleButtonPress() {
// OR
// use the result once the mutation has completed
mutation({ first: "Hello!", second: "me" }).then((result) =>
console.log(result),
console.log(result)
);
}
```
Expand Down
16 changes: 8 additions & 8 deletions convex/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export const createChat = mutation({

if (!user1) {
throw new ConvexError(
"User not found: " + args.friendsUsername + args.friendsUsernameId,
"User not found: " + args.friendsUsername + args.friendsUsernameId
);
}

if (!user2) {
throw new ConvexError(
"Mismatch between Clerk and Convex. This is an error by us.",
"Mismatch between Clerk and Convex. This is an error by us."
);
} else if (user1.clerkId === identity.tokenIdentifier) {
throw new ConvexError("Cannot create a chat with yourself.");
Expand Down Expand Up @@ -65,10 +65,10 @@ export const initialConvexSetup = mutation({
if (!identity.nickname) {
console.error(
"Username is not defined. This is likely an error by us",
identity,
identity
);
throw new ConvexError(
"Username is not defined. This is likely an error by us.",
"Username is not defined. This is likely an error by us."
);
}

Expand Down Expand Up @@ -134,7 +134,7 @@ export const getChats = query({
const allMessages = [...textMessages, ...requests];

const sortedMessages = allMessages.sort(
(a, b) => b._creationTime - a._creationTime,
(a, b) => b._creationTime - a._creationTime
);
const latestMessage = sortedMessages[0];

Expand All @@ -149,7 +149,7 @@ export const getChats = query({
}
const isReadMessage =
message.readBy.some(
(user) => user.clerkId === identity.tokenIdentifier,
(user) => user.clerkId === identity.tokenIdentifier
) &&
(message.type !== "message" || !message.deleted);
if (isReadMessage) {
Expand Down Expand Up @@ -201,14 +201,14 @@ export const getChatInfoFromId = query({
!usersInChat.some((user) => user.clerkId === identity.tokenIdentifier)
) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User requested chat info from a chat in which he is not in.",
"UNAUTHORIZED REQUEST: User requested chat info from a chat in which he is not in."
);
}

return {
basicChatInfo: chat,
otherUser: usersInChat.filter(
(user) => user.clerkId !== identity.tokenIdentifier,
(user) => user.clerkId !== identity.tokenIdentifier
),
};
},
Expand Down
14 changes: 7 additions & 7 deletions convex/clearRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createClearRequest = mutation({

if (!convexUser) {
throw new ConvexError(
"Mismatch between Clerk and Convex. This is an error by us.",
"Mismatch between Clerk and Convex. This is an error by us."
);
}

Expand All @@ -36,7 +36,7 @@ export const createClearRequest = mutation({
!usersInChat.some((user) => user.clerkId === identity.tokenIdentifier)
) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User tried to create a request in a chat in which he is not in.",
"UNAUTHORIZED REQUEST: User tried to create a request in a chat in which he is not in."
);
}

Expand Down Expand Up @@ -91,13 +91,13 @@ export const rejectClearRequest = mutation({
!usersInChat.some((user) => user.clerkId === identity.tokenIdentifier)
) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User tried to reject a clear request in a chat in which he is not in.",
"UNAUTHORIZED REQUEST: User tried to reject a clear request in a chat in which he is not in."
);
}

if ((await request.edge("user")).clerkId === identity.tokenIdentifier) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User tried to reject his own clear request.",
"UNAUTHORIZED REQUEST: User tried to reject his own clear request."
);
}

Expand Down Expand Up @@ -136,13 +136,13 @@ export const acceptClearRequest = mutation({
!usersInChat.some((user) => user.clerkId === identity.tokenIdentifier)
) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User tried to accept a clear request in a chat in which he is not in.",
"UNAUTHORIZED REQUEST: User tried to accept a clear request in a chat in which he is not in."
);
}

if ((await request.edge("user")).clerkId === identity.tokenIdentifier) {
throw new ConvexError(
"UNAUTHORIZED REQUEST: User tried to accept his own clear request.",
"UNAUTHORIZED REQUEST: User tried to accept his own clear request."
);
}

Expand All @@ -164,7 +164,7 @@ export const expirePendingRequests = internalMutation({
handler: async (ctx) => {
for (const q1 of await ctx
.table("clearRequests", "by_creation_time", (q) =>
q.lte("_creationTime", Date.now() - 24 * 60 * 60 * 1000),
q.lte("_creationTime", Date.now() - 24 * 60 * 60 * 1000)
)
.filter((q) => q.eq(q.field("status"), "pending"))) {
if (q1) {
Expand Down
2 changes: 1 addition & 1 deletion convex/crons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const crons = cronJobs();
crons.interval(
"expire open requests",
{ minutes: 1 },
internal.clearRequests.expirePendingRequests,
internal.clearRequests.expirePendingRequests
);

export default crons;
8 changes: 4 additions & 4 deletions convex/lib/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const query = customQuery(
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
}),
})
);

export const internalQuery = customQuery(
Expand All @@ -29,7 +29,7 @@ export const internalQuery = customQuery(
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
}),
})
);

export const mutation = customMutation(
Expand All @@ -39,7 +39,7 @@ export const mutation = customMutation(
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
}),
})
);

export const internalMutation = customMutation(
Expand All @@ -49,5 +49,5 @@ export const internalMutation = customMutation(
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
}),
})
);
6 changes: 3 additions & 3 deletions convex/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ export const reactToMessage = mutation({
throw new ConvexError("messageId was invalid");
}

// Check if user already reacted to this message
// Check if the user already reacted to this message
const existingReaction = await ctx
.table("reactions", "messageId", (q) => q.eq("messageId", messageId))
.filter((q) => q.eq(q.field("userId"), convexUser._id))
.first();

if (existingReaction && existingReaction.emoji === trimmedReaction) {
// Remove existing reaction
// Remove the existing reaction
await existingReaction.delete();
return null;
} else if (existingReaction) {
Expand All @@ -425,7 +425,7 @@ export const reactToMessage = mutation({
return existingReaction;
}

// Create new reaction if none exists
// Create a new reaction if none exists
const reaction = await ctx.table("reactions").insert({
emoji: trimmedReaction,
userId: convexUser._id,
Expand Down
6 changes: 1 addition & 5 deletions convex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ const schema = defineEntSchema({
clearRequests: defineEnt({})
.field(
"status",
v.union(
v.literal("pending"),
v.literal("rejected"),
v.literal("expired"),
),
v.union(v.literal("pending"), v.literal("rejected"), v.literal("expired"))
)
.edges("readBy", {
to: "users",
Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react-hooks/recommended",
),
"plugin:react-hooks/recommended"
)
),
{
languageOptions: {
Expand Down
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const baseConfig = withAxiom(
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return config;
},
}),
})
);

const config = withSentryConfig(baseConfig, {
Expand Down
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@icons-pack/react-simple-icons": "^12.0.0",
"@legendapp/state": "^3.0.0-beta.16",
"@radix-ui/react-alert-dialog": "^1.1.11",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-checkbox": "^1.1.4",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.1.13",
"@radix-ui/react-avatar": "^1.1.9",
"@radix-ui/react-checkbox": "^1.3.1",
"@radix-ui/react-dialog": "^1.1.13",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.4",
"@radix-ui/react-label": "^2.1.6",
"@radix-ui/react-popover": "^1.1.13",
"@radix-ui/react-progress": "^1.1.6",
"@radix-ui/react-select": "^2.2.4",
"@radix-ui/react-slot": "^1.2.2",
"@radix-ui/react-tooltip": "^1.2.6",
"@reactuses/core": "^6.0.0",
"@sentry/nextjs": "^9.0.0",
"@serwist/next": "9.0.14",
"@t3-oss/env-nextjs": "^0.13.0",
"@tailwindcss/postcss": "^4.1.6",
"babel-plugin-react-compiler": "19.0.0-beta-e993439-20250328",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -65,8 +66,8 @@
"react-responsive": "^10.0.0",
"react-scan": "^0.3.0",
"sonner": "^2.0.0",
"tailwind-merge": "^3.0.0",
"tailwindcss-animate": "^1.0.7",
"tailwind-merge": "^3.3.0",
"tw-animate-css": "^1.2.9",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -86,9 +87,9 @@
"eslint-plugin-react-hooks": "^5.0.0",
"postcss": "^8.4.49",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"prettier-plugin-tailwindcss": "^0.6.11",
"serwist": "^9.0.10",
"tailwindcss": "^3.4.15",
"tailwindcss": "^4.1.6",
"typescript": "^5.6.3"
},
"ct3aMetadata": {
Expand All @@ -103,6 +104,7 @@
"onlyBuiltDependencies": [
"@clerk/shared",
"@sentry/cli",
"@tailwindcss/oxide",
"core-js",
"esbuild",
"sharp",
Expand Down
Loading
Loading