Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Minor fixes for server config url generation and file preview (#50)
Hakan Shehu30bdd2dce2f5
diff --git a/apps/server/src/api/home.ts b/apps/server/src/api/home.tsindex 15ae9599..ddbd08c1 100644--- a/apps/server/src/api/home.ts+++ b/apps/server/src/api/home.ts@@ -9,7 +9,9 @@ export const homeRoute: FastifyPluginCallback = (instance, _, done) => {url: '/',handler: async (request, reply) => {const port =- request.port != 80 && request.port != 443 ? `:${request.port}` : '';+ request.port && request.port != 80 && request.port != 443+ ? `:${request.port}`+ : '';const prefix = config.server.pathPrefix? `/${config.server.pathPrefix}`diff --git a/apps/server/src/app.ts b/apps/server/src/app.tsindex 6cdbba8b..61afe2dc 100644--- a/apps/server/src/app.ts+++ b/apps/server/src/app.ts@@ -17,6 +17,7 @@ const debug = createDebugger('server:app');export const initApp = () => {const server = fastify({bodyLimit: 10 * 1024 * 1024, // 10MB+ trustProxy: true,});server.register(errorHandler);diff --git a/packages/ui/src/components/files/file-preview.tsx b/packages/ui/src/components/files/file-preview.tsxindex 501d6bf7..ef490db4 100644--- a/packages/ui/src/components/files/file-preview.tsx+++ b/packages/ui/src/components/files/file-preview.tsx@@ -22,6 +22,8 @@ export const FilePreview = ({ file }: FilePreviewProps) => {workspaceId: workspace.id,});+ const shouldFetchFileUrl = fileStateQuery.data?.downloadProgress === 100;+const fileUrlGetQuery = useQuery({type: 'file.url.get',@@ -31,11 +33,14 @@ export const FilePreview = ({ file }: FilePreviewProps) => {workspaceId: workspace.id,},{- enabled: fileStateQuery.data?.downloadProgress === 100,+ enabled: shouldFetchFileUrl,});- if (fileStateQuery.isPending || fileUrlGetQuery.isPending) {+ if (+ fileStateQuery.isPending ||+ (shouldFetchFileUrl && fileUrlGetQuery.isPending)+ ) {return null;}diff --git a/packages/ui/src/hooks/use-query.tsx b/packages/ui/src/hooks/use-query.tsxindex 58d14f73..a3f62dcb 100644--- a/packages/ui/src/hooks/use-query.tsx+++ b/packages/ui/src/hooks/use-query.tsx@@ -18,14 +18,11 @@ export const useQuery = <T extends QueryInput>(const inputJson = JSON.stringify(input);const hash = sha256(inputJson);- const { data, isPending } = useTanstackQuery({+ const result = useTanstackQuery({queryKey: [hash],queryFn: () => window.colanode.executeQueryAndSubscribe(hash, input),...options,});- return {- isPending,- data,- };+ return result;};