rita-workspace 0.5.43 → 0.5.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1894,10 +1894,19 @@ var DrawingsDialog = ({
1894
1894
  minute: "2-digit"
1895
1895
  });
1896
1896
  };
1897
- const daysSinceBackup = (0, import_react5.useMemo)(() => {
1897
+ const { daysSinceBackup, lastBackupTimestamp } = (0, import_react5.useMemo)(() => {
1898
1898
  const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1899
- if (!lastBackup) return drawings.length > 0 ? 999 : null;
1900
- return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1899
+ if (!lastBackup) {
1900
+ return {
1901
+ daysSinceBackup: drawings.length > 0 ? 999 : null,
1902
+ lastBackupTimestamp: null
1903
+ };
1904
+ }
1905
+ const ts = parseInt(lastBackup, 10);
1906
+ return {
1907
+ daysSinceBackup: Math.floor((Date.now() - ts) / (1e3 * 60 * 60 * 24)),
1908
+ lastBackupTimestamp: ts
1909
+ };
1901
1910
  }, [drawings.length, open]);
1902
1911
  const { rootDrawings, drawingsByFolder, filteredFolders } = (0, import_react5.useMemo)(() => {
1903
1912
  const query = searchQuery.toLowerCase().trim();
@@ -2572,42 +2581,66 @@ var DrawingsDialog = ({
2572
2581
  )
2573
2582
  ] }),
2574
2583
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2575
- daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2576
- "div",
2577
- {
2578
- style: {
2579
- margin: "0 20px 12px",
2580
- padding: "10px 14px",
2581
- backgroundColor: daysSinceBackup >= 30 ? "#f8d7da" : "#fff3cd",
2582
- color: daysSinceBackup >= 30 ? "#721c24" : "#856404",
2583
- fontSize: "13px",
2584
- fontWeight: 500,
2585
- border: `1px solid ${daysSinceBackup >= 30 ? "#dc3545" : "#ffc107"}`,
2586
- borderRadius: "6px",
2587
- display: "flex",
2588
- alignItems: "center",
2589
- gap: "8px"
2590
- },
2591
- children: [
2592
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px" }, children: daysSinceBackup >= 30 ? "\u{1F6A8}" : "\u26A0\uFE0F" }),
2593
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: daysSinceBackup >= 999 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2594
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Ingen backup gjord \xE4nnu." }),
2595
- ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2596
- ] }) : daysSinceBackup >= 30 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2597
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("strong", { children: [
2598
- "Ingen backup p\xE5 ",
2599
- daysSinceBackup,
2600
- " dagar."
2601
- ] }),
2602
- " Det \xE4r dags att spara en kopia av dina ritningar."
2603
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2604
- "Senaste backup f\xF6r ",
2605
- daysSinceBackup,
2606
- " dagar sedan. \xD6verv\xE4g att spara en ny."
2607
- ] }) })
2608
- ]
2609
- }
2610
- ),
2584
+ daysSinceBackup !== null && (() => {
2585
+ const isNever = daysSinceBackup >= 999;
2586
+ const isCritical = !isNever && daysSinceBackup >= 30;
2587
+ const isWarning = !isNever && !isCritical && daysSinceBackup >= 7;
2588
+ const isInfo = !isNever && !isCritical && !isWarning;
2589
+ const dateStr = lastBackupTimestamp ? new Date(lastBackupTimestamp).toLocaleString(effectiveLang || "sv", {
2590
+ year: "numeric",
2591
+ month: "short",
2592
+ day: "numeric",
2593
+ hour: "2-digit",
2594
+ minute: "2-digit"
2595
+ }) : null;
2596
+ const ageStr = daysSinceBackup === 0 ? "idag" : `f\xF6r ${daysSinceBackup} dagar sedan`;
2597
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2598
+ "div",
2599
+ {
2600
+ style: {
2601
+ margin: "0 20px 12px",
2602
+ padding: "10px 14px",
2603
+ backgroundColor: isCritical || isNever ? "#f8d7da" : isWarning ? "#fff3cd" : "transparent",
2604
+ color: isCritical || isNever ? "#721c24" : isWarning ? "#856404" : "var(--text-secondary-color, #888)",
2605
+ fontSize: "13px",
2606
+ fontWeight: isInfo ? 400 : 500,
2607
+ border: isInfo ? "1px solid var(--default-border-color, #e0e0e0)" : `1px solid ${isCritical || isNever ? "#dc3545" : "#ffc107"}`,
2608
+ borderRadius: "6px",
2609
+ display: "flex",
2610
+ alignItems: "center",
2611
+ gap: "8px"
2612
+ },
2613
+ children: [
2614
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px" }, children: isNever || isCritical ? "\u{1F6A8}" : isWarning ? "\u26A0\uFE0F" : "\u{1F4BE}" }),
2615
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: isNever ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2616
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Ingen backup gjord \xE4nnu." }),
2617
+ ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2618
+ ] }) : isCritical ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2619
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("strong", { children: [
2620
+ "Ingen backup p\xE5 ",
2621
+ daysSinceBackup,
2622
+ " dagar."
2623
+ ] }),
2624
+ " Senast: ",
2625
+ dateStr,
2626
+ "."
2627
+ ] }) : isWarning ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2628
+ "Senaste backup ",
2629
+ ageStr,
2630
+ " (",
2631
+ dateStr,
2632
+ "). \xD6verv\xE4g att spara en ny."
2633
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2634
+ "Senaste backup ",
2635
+ ageStr,
2636
+ " (",
2637
+ dateStr,
2638
+ ")."
2639
+ ] }) })
2640
+ ]
2641
+ }
2642
+ );
2643
+ })(),
2611
2644
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2612
2645
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2613
2646
  ActionButton,
package/dist/index.mjs CHANGED
@@ -1822,10 +1822,19 @@ var DrawingsDialog = ({
1822
1822
  minute: "2-digit"
1823
1823
  });
1824
1824
  };
1825
- const daysSinceBackup = useMemo(() => {
1825
+ const { daysSinceBackup, lastBackupTimestamp } = useMemo(() => {
1826
1826
  const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1827
- if (!lastBackup) return drawings.length > 0 ? 999 : null;
1828
- return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1827
+ if (!lastBackup) {
1828
+ return {
1829
+ daysSinceBackup: drawings.length > 0 ? 999 : null,
1830
+ lastBackupTimestamp: null
1831
+ };
1832
+ }
1833
+ const ts = parseInt(lastBackup, 10);
1834
+ return {
1835
+ daysSinceBackup: Math.floor((Date.now() - ts) / (1e3 * 60 * 60 * 24)),
1836
+ lastBackupTimestamp: ts
1837
+ };
1829
1838
  }, [drawings.length, open]);
1830
1839
  const { rootDrawings, drawingsByFolder, filteredFolders } = useMemo(() => {
1831
1840
  const query = searchQuery.toLowerCase().trim();
@@ -2500,42 +2509,66 @@ var DrawingsDialog = ({
2500
2509
  )
2501
2510
  ] }),
2502
2511
  /* @__PURE__ */ jsx6("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2503
- daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ jsxs4(
2504
- "div",
2505
- {
2506
- style: {
2507
- margin: "0 20px 12px",
2508
- padding: "10px 14px",
2509
- backgroundColor: daysSinceBackup >= 30 ? "#f8d7da" : "#fff3cd",
2510
- color: daysSinceBackup >= 30 ? "#721c24" : "#856404",
2511
- fontSize: "13px",
2512
- fontWeight: 500,
2513
- border: `1px solid ${daysSinceBackup >= 30 ? "#dc3545" : "#ffc107"}`,
2514
- borderRadius: "6px",
2515
- display: "flex",
2516
- alignItems: "center",
2517
- gap: "8px"
2518
- },
2519
- children: [
2520
- /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px" }, children: daysSinceBackup >= 30 ? "\u{1F6A8}" : "\u26A0\uFE0F" }),
2521
- /* @__PURE__ */ jsx6("span", { children: daysSinceBackup >= 999 ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2522
- /* @__PURE__ */ jsx6("strong", { children: "Ingen backup gjord \xE4nnu." }),
2523
- ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2524
- ] }) : daysSinceBackup >= 30 ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2525
- /* @__PURE__ */ jsxs4("strong", { children: [
2526
- "Ingen backup p\xE5 ",
2527
- daysSinceBackup,
2528
- " dagar."
2529
- ] }),
2530
- " Det \xE4r dags att spara en kopia av dina ritningar."
2531
- ] }) : /* @__PURE__ */ jsxs4(Fragment3, { children: [
2532
- "Senaste backup f\xF6r ",
2533
- daysSinceBackup,
2534
- " dagar sedan. \xD6verv\xE4g att spara en ny."
2535
- ] }) })
2536
- ]
2537
- }
2538
- ),
2512
+ daysSinceBackup !== null && (() => {
2513
+ const isNever = daysSinceBackup >= 999;
2514
+ const isCritical = !isNever && daysSinceBackup >= 30;
2515
+ const isWarning = !isNever && !isCritical && daysSinceBackup >= 7;
2516
+ const isInfo = !isNever && !isCritical && !isWarning;
2517
+ const dateStr = lastBackupTimestamp ? new Date(lastBackupTimestamp).toLocaleString(effectiveLang || "sv", {
2518
+ year: "numeric",
2519
+ month: "short",
2520
+ day: "numeric",
2521
+ hour: "2-digit",
2522
+ minute: "2-digit"
2523
+ }) : null;
2524
+ const ageStr = daysSinceBackup === 0 ? "idag" : `f\xF6r ${daysSinceBackup} dagar sedan`;
2525
+ return /* @__PURE__ */ jsxs4(
2526
+ "div",
2527
+ {
2528
+ style: {
2529
+ margin: "0 20px 12px",
2530
+ padding: "10px 14px",
2531
+ backgroundColor: isCritical || isNever ? "#f8d7da" : isWarning ? "#fff3cd" : "transparent",
2532
+ color: isCritical || isNever ? "#721c24" : isWarning ? "#856404" : "var(--text-secondary-color, #888)",
2533
+ fontSize: "13px",
2534
+ fontWeight: isInfo ? 400 : 500,
2535
+ border: isInfo ? "1px solid var(--default-border-color, #e0e0e0)" : `1px solid ${isCritical || isNever ? "#dc3545" : "#ffc107"}`,
2536
+ borderRadius: "6px",
2537
+ display: "flex",
2538
+ alignItems: "center",
2539
+ gap: "8px"
2540
+ },
2541
+ children: [
2542
+ /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px" }, children: isNever || isCritical ? "\u{1F6A8}" : isWarning ? "\u26A0\uFE0F" : "\u{1F4BE}" }),
2543
+ /* @__PURE__ */ jsx6("span", { children: isNever ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2544
+ /* @__PURE__ */ jsx6("strong", { children: "Ingen backup gjord \xE4nnu." }),
2545
+ ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2546
+ ] }) : isCritical ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2547
+ /* @__PURE__ */ jsxs4("strong", { children: [
2548
+ "Ingen backup p\xE5 ",
2549
+ daysSinceBackup,
2550
+ " dagar."
2551
+ ] }),
2552
+ " Senast: ",
2553
+ dateStr,
2554
+ "."
2555
+ ] }) : isWarning ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2556
+ "Senaste backup ",
2557
+ ageStr,
2558
+ " (",
2559
+ dateStr,
2560
+ "). \xD6verv\xE4g att spara en ny."
2561
+ ] }) : /* @__PURE__ */ jsxs4(Fragment3, { children: [
2562
+ "Senaste backup ",
2563
+ ageStr,
2564
+ " (",
2565
+ dateStr,
2566
+ ")."
2567
+ ] }) })
2568
+ ]
2569
+ }
2570
+ );
2571
+ })(),
2539
2572
  /* @__PURE__ */ jsxs4("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2540
2573
  /* @__PURE__ */ jsx6(
2541
2574
  ActionButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rita-workspace",
3
- "version": "0.5.43",
3
+ "version": "0.5.44",
4
4
  "description": "Multi-drawing workspace feature for Rita (Excalidraw fork)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",