Sfoglia il codice sorgente

feat: improve upload flow for logged-in users

- Hide expiry and download toggle for authenticated users
- Skip auto short link generation for logged-in users (they manage manually)
- Add version display in footer (v1.1.0 with build timestamp)
Fszontagh 2 giorni fa
parent
commit
b5d4c3a54b
5 ha cambiato i file con 40 aggiunte e 25 eliminazioni
  1. 4 1
      src/components/Layout.tsx
  2. 25 24
      src/hooks/useImages.ts
  3. 2 0
      src/pages/DashboardPage.tsx
  4. 4 0
      src/vite-env.d.ts
  5. 5 0
      vite.config.ts

+ 4 - 1
src/components/Layout.tsx

@@ -11,7 +11,7 @@ export default function Layout() {
       <footer className="border-t py-6 transition-colors duration-200" style={{ backgroundColor: 'var(--bg-secondary)', borderColor: 'var(--border)' }}>
         <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
           <p className="text-sm text-center" style={{ color: 'var(--text-muted)' }}>
-            ImageDrop - Powered by{' '}
+            ImageDrop v{__APP_VERSION__} - Powered by{' '}
             <a
               href="https://picobaas.eu"
               target="_blank"
@@ -22,6 +22,9 @@ export default function Layout() {
               PicoBaaS
             </a>
           </p>
+          <p className="text-xs text-center mt-1" style={{ color: 'var(--text-muted)', opacity: 0.6 }}>
+            Built: {__BUILD_TIME__}
+          </p>
         </div>
       </footer>
     </div>

+ 25 - 24
src/hooks/useImages.ts

@@ -109,36 +109,37 @@ export function useImages(bucket: string = PUBLIC_BUCKET) {
 
         if (uploadError) throw uploadError;
 
-        // Register with image API for short URL and tracking using SDK
-        const sessionToken = getSessionToken();
-        const apiResponse = await client.request<{ short_code: string }>(
-          '/api/images',
-          {
-            method: 'POST',
-            headers: { 'X-Session-Token': sessionToken },
-            body: JSON.stringify({
-              bucket,
-              path,
-              storage_object_id: data?.id,
-              download_allowed: options.downloadAllowed,
-              expires_at: expiresAt,
-            }),
-          }
-        );
-
         let shortCode: string | undefined;
         let shortUrl: string | undefined;
 
-        if (!apiResponse.error && apiResponse.data) {
-          shortCode = apiResponse.data.short_code;
-          shortUrl = `/i/${shortCode}`;
+        // Only register with image API for anonymous users (auto short link generation)
+        // Logged-in users manage share links manually via the dashboard
+        if (!isAuthenticated) {
+          const sessionToken = getSessionToken();
+          const apiResponse = await client.request<{ short_code: string }>(
+            '/api/images',
+            {
+              method: 'POST',
+              headers: { 'X-Session-Token': sessionToken },
+              body: JSON.stringify({
+                bucket,
+                path,
+                storage_object_id: data?.id,
+                download_allowed: options.downloadAllowed,
+                expires_at: expiresAt,
+              }),
+            }
+          );
+
+          if (!apiResponse.error && apiResponse.data) {
+            shortCode = apiResponse.data.short_code;
+            shortUrl = `/i/${shortCode}`;
 
-          // Track anonymous uploads for deletion capability
-          if (!isAuthenticated && shortCode) {
+            // Track anonymous uploads for deletion capability
             trackUpload(shortCode);
+          } else {
+            console.warn('Failed to register image with API:', apiResponse.error);
           }
-        } else {
-          console.warn('Failed to register image with API:', apiResponse.error);
         }
 
         const newImage: ImageFile = {

+ 2 - 0
src/pages/DashboardPage.tsx

@@ -98,6 +98,8 @@ export default function DashboardPage() {
           <ImageUploader
             onUpload={handleUpload}
             isUploading={isUploading}
+            showExpiry={false}
+            showDownloadToggle={false}
             compact
           />
         </div>

+ 4 - 0
src/vite-env.d.ts

@@ -0,0 +1,4 @@
+/// <reference types="vite/client" />
+
+declare const __APP_VERSION__: string;
+declare const __BUILD_TIME__: string;

+ 5 - 0
vite.config.ts

@@ -1,8 +1,13 @@
 import { defineConfig } from 'vite';
 import react from '@vitejs/plugin-react';
+import packageJson from './package.json';
 
 export default defineConfig({
   plugins: [react()],
+  define: {
+    __APP_VERSION__: JSON.stringify(packageJson.version),
+    __BUILD_TIME__: JSON.stringify(new Date().toISOString()),
+  },
   // Use relative paths so the app works when served from any subdirectory
   base: './',
   build: {