rita-workspace 0.5.15 → 0.5.17

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.d.mts CHANGED
@@ -116,6 +116,8 @@ interface Translations {
116
116
  moveToFolder: string;
117
117
  moveToRoot: string;
118
118
  newFolderName: string;
119
+ backupReminder: string;
120
+ days: string;
119
121
  shortcutNewDrawing: string;
120
122
  }
121
123
  declare function getTranslations(langCode?: string): Translations;
package/dist/index.d.ts CHANGED
@@ -116,6 +116,8 @@ interface Translations {
116
116
  moveToFolder: string;
117
117
  moveToRoot: string;
118
118
  newFolderName: string;
119
+ backupReminder: string;
120
+ days: string;
119
121
  shortcutNewDrawing: string;
120
122
  }
121
123
  declare function getTranslations(langCode?: string): Translations;
package/dist/index.js CHANGED
@@ -318,6 +318,9 @@ var sv = {
318
318
  moveToFolder: "Flytta till mapp",
319
319
  moveToRoot: "Ingen mapp",
320
320
  newFolderName: "Ny mapp",
321
+ // Backup reminder
322
+ backupReminder: "Senaste backup:",
323
+ days: "dagar sedan",
321
324
  // Shortcuts
322
325
  shortcutNewDrawing: "Ctrl+Alt+N"
323
326
  };
@@ -365,6 +368,9 @@ var en = {
365
368
  moveToFolder: "Move to folder",
366
369
  moveToRoot: "No folder",
367
370
  newFolderName: "New folder",
371
+ // Backup reminder
372
+ backupReminder: "Last backup:",
373
+ days: "days ago",
368
374
  // Shortcuts
369
375
  shortcutNewDrawing: "Ctrl+Alt+N"
370
376
  };
@@ -542,9 +548,11 @@ function WorkspaceProvider({ children, lang = "en" }) {
542
548
  channel?.close();
543
549
  };
544
550
  }, []);
551
+ const hasCleanedUpRef = (0, import_react.useRef)(false);
545
552
  (0, import_react.useEffect)(() => {
546
553
  cleanupStaleTabs();
547
554
  const timer = setTimeout(() => {
555
+ hasCleanedUpRef.current = true;
548
556
  const drawingId = activeDrawingIdRef.current;
549
557
  if (drawingId) {
550
558
  setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
@@ -555,10 +563,12 @@ function WorkspaceProvider({ children, lang = "en" }) {
555
563
  (0, import_react.useEffect)(() => {
556
564
  const drawingId = activeDrawing?.id || null;
557
565
  setTabDrawing(drawingId);
558
- if (drawingId) {
559
- setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
560
- } else {
561
- setIsDrawingConflict(false);
566
+ if (hasCleanedUpRef.current) {
567
+ if (drawingId) {
568
+ setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
569
+ } else {
570
+ setIsDrawingConflict(false);
571
+ }
562
572
  }
563
573
  const recheckConflict = () => {
564
574
  if (drawingId) {
@@ -1553,6 +1563,11 @@ var DrawingsDialog = ({
1553
1563
  minute: "2-digit"
1554
1564
  });
1555
1565
  };
1566
+ const daysSinceBackup = (0, import_react5.useMemo)(() => {
1567
+ const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1568
+ if (!lastBackup) return drawings.length > 0 ? 999 : null;
1569
+ return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1570
+ }, [drawings.length, open]);
1556
1571
  const { rootDrawings, drawingsByFolder, filteredFolders } = (0, import_react5.useMemo)(() => {
1557
1572
  const query = searchQuery.toLowerCase().trim();
1558
1573
  const filtered = query ? drawings.filter((d) => d.name.toLowerCase().includes(query)) : drawings;
@@ -2073,7 +2088,7 @@ var DrawingsDialog = ({
2073
2088
  }
2074
2089
  },
2075
2090
  children: [
2076
- isRefreshing && drawings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { padding: "24px 20px", textAlign: "center", color: "var(--text-secondary-color, #666)" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { display: "inline-block", animation: "spin 1s linear infinite", fontSize: "24px" }, children: "\u23F3" }) }) : drawings.length > 0 || folders.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "8px 20px 0" }, onClick: () => setSelectedId(null), children: [
2091
+ isRefreshing ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { padding: "24px 20px", textAlign: "center", color: "var(--text-secondary-color, #666)" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { display: "inline-block", animation: "spin 1s linear infinite", fontSize: "24px" }, children: "\u23F3" }) }) : drawings.length > 0 || folders.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "8px 20px 0" }, onClick: () => setSelectedId(null), children: [
2077
2092
  filteredFolders.map(renderFolderGroup),
2078
2093
  draggingDrawingId && folders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2079
2094
  "div",
@@ -2190,6 +2205,7 @@ var DrawingsDialog = ({
2190
2205
  )
2191
2206
  ] }),
2192
2207
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2208
+ daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { padding: "0 20px 8px", fontSize: "12px", color: "var(--text-secondary-color, #888)" }, children: daysSinceBackup >= 30 ? `\u26A0\uFE0F ${t.backupReminder || "Ingen backup p\xE5"} ${daysSinceBackup} ${t.days || "dagar"}` : `${t.backupReminder || "Senaste backup:"} ${daysSinceBackup} ${t.days || "dagar sedan"}` }),
2193
2209
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2194
2210
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2195
2211
  ActionButton,
@@ -2197,7 +2213,10 @@ var DrawingsDialog = ({
2197
2213
  icon: "\u{1F4BE}",
2198
2214
  label: t.saveAllBackup,
2199
2215
  description: t.saveAllBackupDesc,
2200
- onClick: exportWorkspace
2216
+ onClick: () => {
2217
+ localStorage.setItem("rita-workspace-last-backup", Date.now().toString());
2218
+ exportWorkspace();
2219
+ }
2201
2220
  }
2202
2221
  ),
2203
2222
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
package/dist/index.mjs CHANGED
@@ -250,6 +250,9 @@ var sv = {
250
250
  moveToFolder: "Flytta till mapp",
251
251
  moveToRoot: "Ingen mapp",
252
252
  newFolderName: "Ny mapp",
253
+ // Backup reminder
254
+ backupReminder: "Senaste backup:",
255
+ days: "dagar sedan",
253
256
  // Shortcuts
254
257
  shortcutNewDrawing: "Ctrl+Alt+N"
255
258
  };
@@ -297,6 +300,9 @@ var en = {
297
300
  moveToFolder: "Move to folder",
298
301
  moveToRoot: "No folder",
299
302
  newFolderName: "New folder",
303
+ // Backup reminder
304
+ backupReminder: "Last backup:",
305
+ days: "days ago",
300
306
  // Shortcuts
301
307
  shortcutNewDrawing: "Ctrl+Alt+N"
302
308
  };
@@ -474,9 +480,11 @@ function WorkspaceProvider({ children, lang = "en" }) {
474
480
  channel?.close();
475
481
  };
476
482
  }, []);
483
+ const hasCleanedUpRef = useRef(false);
477
484
  useEffect(() => {
478
485
  cleanupStaleTabs();
479
486
  const timer = setTimeout(() => {
487
+ hasCleanedUpRef.current = true;
480
488
  const drawingId = activeDrawingIdRef.current;
481
489
  if (drawingId) {
482
490
  setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
@@ -487,10 +495,12 @@ function WorkspaceProvider({ children, lang = "en" }) {
487
495
  useEffect(() => {
488
496
  const drawingId = activeDrawing?.id || null;
489
497
  setTabDrawing(drawingId);
490
- if (drawingId) {
491
- setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
492
- } else {
493
- setIsDrawingConflict(false);
498
+ if (hasCleanedUpRef.current) {
499
+ if (drawingId) {
500
+ setIsDrawingConflict(isDrawingOpenedEarlierInOtherTab(drawingId));
501
+ } else {
502
+ setIsDrawingConflict(false);
503
+ }
494
504
  }
495
505
  const recheckConflict = () => {
496
506
  if (drawingId) {
@@ -1485,6 +1495,11 @@ var DrawingsDialog = ({
1485
1495
  minute: "2-digit"
1486
1496
  });
1487
1497
  };
1498
+ const daysSinceBackup = useMemo(() => {
1499
+ const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1500
+ if (!lastBackup) return drawings.length > 0 ? 999 : null;
1501
+ return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1502
+ }, [drawings.length, open]);
1488
1503
  const { rootDrawings, drawingsByFolder, filteredFolders } = useMemo(() => {
1489
1504
  const query = searchQuery.toLowerCase().trim();
1490
1505
  const filtered = query ? drawings.filter((d) => d.name.toLowerCase().includes(query)) : drawings;
@@ -2005,7 +2020,7 @@ var DrawingsDialog = ({
2005
2020
  }
2006
2021
  },
2007
2022
  children: [
2008
- isRefreshing && drawings.length === 0 ? /* @__PURE__ */ jsx6("div", { style: { padding: "24px 20px", textAlign: "center", color: "var(--text-secondary-color, #666)" }, children: /* @__PURE__ */ jsx6("span", { style: { display: "inline-block", animation: "spin 1s linear infinite", fontSize: "24px" }, children: "\u23F3" }) }) : drawings.length > 0 || folders.length > 0 ? /* @__PURE__ */ jsxs4("div", { style: { padding: "8px 20px 0" }, onClick: () => setSelectedId(null), children: [
2023
+ isRefreshing ? /* @__PURE__ */ jsx6("div", { style: { padding: "24px 20px", textAlign: "center", color: "var(--text-secondary-color, #666)" }, children: /* @__PURE__ */ jsx6("span", { style: { display: "inline-block", animation: "spin 1s linear infinite", fontSize: "24px" }, children: "\u23F3" }) }) : drawings.length > 0 || folders.length > 0 ? /* @__PURE__ */ jsxs4("div", { style: { padding: "8px 20px 0" }, onClick: () => setSelectedId(null), children: [
2009
2024
  filteredFolders.map(renderFolderGroup),
2010
2025
  draggingDrawingId && folders.length > 0 && /* @__PURE__ */ jsx6(
2011
2026
  "div",
@@ -2122,6 +2137,7 @@ var DrawingsDialog = ({
2122
2137
  )
2123
2138
  ] }),
2124
2139
  /* @__PURE__ */ jsx6("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2140
+ daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ jsx6("div", { style: { padding: "0 20px 8px", fontSize: "12px", color: "var(--text-secondary-color, #888)" }, children: daysSinceBackup >= 30 ? `\u26A0\uFE0F ${t.backupReminder || "Ingen backup p\xE5"} ${daysSinceBackup} ${t.days || "dagar"}` : `${t.backupReminder || "Senaste backup:"} ${daysSinceBackup} ${t.days || "dagar sedan"}` }),
2125
2141
  /* @__PURE__ */ jsxs4("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2126
2142
  /* @__PURE__ */ jsx6(
2127
2143
  ActionButton,
@@ -2129,7 +2145,10 @@ var DrawingsDialog = ({
2129
2145
  icon: "\u{1F4BE}",
2130
2146
  label: t.saveAllBackup,
2131
2147
  description: t.saveAllBackupDesc,
2132
- onClick: exportWorkspace
2148
+ onClick: () => {
2149
+ localStorage.setItem("rita-workspace-last-backup", Date.now().toString());
2150
+ exportWorkspace();
2151
+ }
2133
2152
  }
2134
2153
  ),
2135
2154
  /* @__PURE__ */ jsx6(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rita-workspace",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "Multi-drawing workspace feature for Rita (Excalidraw fork)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",