Skip to content

Commit

Permalink
Minor touches to improve inbox list subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
richardguerre committed Oct 18, 2024
1 parent 9216fb1 commit 2faf93c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "echo \"⚠️ This is still a development server. In production, the server is bundled and served by Bun.\" && echo \"⚠️ This simulates running in production.\" && NODE_ENV=production bun run src/index.ts",
"type-check": "bun run db:gen && tsc --noEmit && echo '✅ Type checking passed!'",
"build": "bun build ./src/index.ts --outdir dist --target bun && bun run copy-web && bun run copy-mobile-pwa",
"build-push": "bun run build && cd ../.. && bun run cp-build && bun run push-build",
"preview": "cd dist && NODE_ENV=production PORT=4040 DATABASE_URL=postgres://postgres:postgres@localhost:5432/flow ORIGIN=https://lamporchestra.isflow.in PATH_TO_PLUGINS=../plugins BUN_JSC_forceRAMSize=180000000 bun run index.js",
"copy-web": "rm -rf ./dist/web && cp -r ../web/dist ./dist/web && echo '✅ apps/web/dist copied to apps/server/dist/web'",
"copy-mobile-pwa": "rm -rf ./dist/mobile-pwa && cp -r ../mobile-pwa/dist ./dist/mobile-pwa && echo '✅ apps/mobile-pwa/dist copied to apps/server/dist/mobile-pwa'",
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/graphql/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Pass the \`where\` argument to override these defaults.`,
resolve: (query, _, args) => {
return prisma.item.findMany({
...query,
take: undefined, // prevents `query` from overriding `take` and return all items
where: args.where ?? undefined,
orderBy: args.orderBy ?? undefined,
});
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/graphql/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ export const builder = new SchemaBuilder<{
smartSubscriptions: {
subscribe: async ($name, context, callback) => {
const name = $name as PubSubKeys;
console.log("subscribing", name);
if (!context.subscriptions[name]) context.subscriptions[name] = pubsub.subscribe(name);
for await (const data of context.subscriptions[name]) {
callback(undefined, data);
}
},
unsubscribe: ($name, context) => {
const name = $name as PubSubKeys;
console.log("unsubscribing", name);
context.subscriptions[name]?.return?.();
delete context.subscriptions[name];
},
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/InboxList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const InboxListItems = (props: {
tasks: { none: { status: { equals: TODO } } }
}
orderBy: { inboxPoints: Desc }
first: 30
) {
...InboxListItems_itemsConnection
}
Expand Down

0 comments on commit 2faf93c

Please sign in to comment.