@peers-app/peers-ui 0.16.6 → 0.17.0

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.
@@ -76,7 +76,7 @@ const AppearanceSettingsTab = () => {
76
76
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h5", { className: "mb-3", children: "Appearance" }), (0, jsx_runtime_1.jsx)(color_mode_dropdown_1.ColorModeDropdown, {})] }));
77
77
  };
78
78
  const AdvancedSettingsTab = () => {
79
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h5", { className: "mb-3", children: "Advanced Settings" }), (0, jsx_runtime_1.jsx)(PackagesRootDirectory, {}), (0, jsx_runtime_1.jsx)(ReloadPackagesOnPageRefresh, {}), (0, jsx_runtime_1.jsx)(AutoUpdatePeersCore, {}), (0, jsx_runtime_1.jsx)(ResetDeviceSyncInfos, {}), (0, jsx_runtime_1.jsx)(DeleteLocalDatabase, {}), (0, jsx_runtime_1.jsx)(ImportOldPeersData, {}), (0, jsx_runtime_1.jsx)(ResetChangeTracking, {})] }));
79
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h5", { className: "mb-3", children: "Advanced Settings" }), (0, jsx_runtime_1.jsx)(PackagesRootDirectory, {}), (0, jsx_runtime_1.jsx)(ReloadPackagesOnPageRefresh, {}), (0, jsx_runtime_1.jsx)(AutoUpdatePeersCore, {}), (0, jsx_runtime_1.jsx)(ResetDeviceSyncInfos, {}), (0, jsx_runtime_1.jsx)(DeleteLocalDatabase, {}), (0, jsx_runtime_1.jsx)(CleanupOldDataDir, {}), (0, jsx_runtime_1.jsx)(ImportOldPeersData, {}), (0, jsx_runtime_1.jsx)(ResetChangeTracking, {})] }));
80
80
  };
81
81
  const ProfileSection = () => {
82
82
  const [deviceId] = (0, hooks_1.useObservable)(peers_sdk_1.thisDeviceId);
@@ -185,6 +185,35 @@ const DeleteLocalDatabase = () => {
185
185
  }
186
186
  }, children: "Delete Local Database" }) }));
187
187
  };
188
+ const CleanupOldDataDir = () => {
189
+ const [info, setInfo] = (0, react_1.useState)(undefined);
190
+ const [busy, setBusy] = (0, react_1.useState)(false);
191
+ (0, react_1.useEffect)(() => {
192
+ peers_sdk_1.rpcServerCalls
193
+ .getOldDataDirInfo()
194
+ .then(setInfo)
195
+ .catch(() => setInfo(null));
196
+ }, []);
197
+ if (info === undefined || info === null)
198
+ return null;
199
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 pt-3 border-top", children: [(0, jsx_runtime_1.jsx)("h6", { className: "mb-2", children: "Clean up old data directory" }), (0, jsx_runtime_1.jsxs)("small", { className: "text-muted d-block mb-2", children: ["Your data has been migrated to ", (0, jsx_runtime_1.jsx)("code", { children: "~/peers/data" }), ". The old copy below can be deleted once you've confirmed everything works."] }), (0, jsx_runtime_1.jsxs)("small", { className: "text-muted d-block mb-2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Old location:" }), " ", (0, jsx_runtime_1.jsx)("code", { children: info.path }), " (", info.sizeMB, " MB)"] }), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-danger btn-sm", disabled: busy, onClick: async () => {
200
+ const confirmed = confirm(`Delete the old data directory? This will free ~${info.sizeMB} MB.\n\n${info.path}\n\nThis cannot be undone.`);
201
+ if (!confirmed)
202
+ return;
203
+ setBusy(true);
204
+ try {
205
+ await peers_sdk_1.rpcServerCalls.cleanupOldDataDir();
206
+ setInfo(null);
207
+ alert("Old data directory deleted.");
208
+ }
209
+ catch (err) {
210
+ alert(`Failed to delete: ${err.message}`);
211
+ }
212
+ finally {
213
+ setBusy(false);
214
+ }
215
+ }, children: busy ? "Deleting..." : "Delete Old Data Directory" })] }));
216
+ };
188
217
  const ResetChangeTracking = () => {
189
218
  const [busy, setBusy] = (0, react_1.useState)(false);
190
219
  return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 pt-3 border-top", children: [(0, jsx_runtime_1.jsx)("h6", { className: "mb-2", children: "Change tracking" }), (0, jsx_runtime_1.jsx)("small", { className: "text-muted d-block mb-2", children: "Clears all change history for the current group and rebuilds it from your current database rows. Device sync cursors are cleared; a full resync with peers may follow. Use when debugging sync issues." }), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-warning btn-sm", disabled: busy, onClick: async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.16.6",
3
+ "version": "0.17.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-ui.git"
@@ -28,7 +28,7 @@
28
28
  "lint:fix": "biome check --write ."
29
29
  },
30
30
  "peerDependencies": {
31
- "@peers-app/peers-sdk": "^0.16.6",
31
+ "@peers-app/peers-sdk": "^0.17.0",
32
32
  "bootstrap": "^5.3.3",
33
33
  "react": "^18.0.0",
34
34
  "react-dom": "^18.0.0"
@@ -39,7 +39,7 @@
39
39
  "@babel/preset-env": "^7.24.5",
40
40
  "@babel/preset-react": "^7.24.1",
41
41
  "@babel/preset-typescript": "^7.27.1",
42
- "@peers-app/peers-sdk": "0.16.6",
42
+ "@peers-app/peers-sdk": "0.17.0",
43
43
  "@testing-library/dom": "^10.4.0",
44
44
  "@testing-library/jest-dom": "^6.6.3",
45
45
  "@testing-library/react": "^16.3.0",
@@ -91,6 +91,7 @@ const AdvancedSettingsTab: React.FC = () => {
91
91
  <AutoUpdatePeersCore />
92
92
  <ResetDeviceSyncInfos />
93
93
  <DeleteLocalDatabase />
94
+ <CleanupOldDataDir />
94
95
  <ImportOldPeersData />
95
96
  <ResetChangeTracking />
96
97
  </>
@@ -328,6 +329,55 @@ const DeleteLocalDatabase: React.FC = () => {
328
329
  );
329
330
  };
330
331
 
332
+ const CleanupOldDataDir: React.FC = () => {
333
+ const [info, setInfo] = useState<{ path: string; sizeMB: number } | null | undefined>(undefined);
334
+ const [busy, setBusy] = useState(false);
335
+
336
+ useEffect(() => {
337
+ rpcServerCalls
338
+ .getOldDataDirInfo()
339
+ .then(setInfo)
340
+ .catch(() => setInfo(null));
341
+ }, []);
342
+
343
+ if (info === undefined || info === null) return null;
344
+
345
+ return (
346
+ <div className="mt-4 pt-3 border-top">
347
+ <h6 className="mb-2">Clean up old data directory</h6>
348
+ <small className="text-muted d-block mb-2">
349
+ Your data has been migrated to <code>~/peers/data</code>. The old copy below can be deleted
350
+ once you've confirmed everything works.
351
+ </small>
352
+ <small className="text-muted d-block mb-2">
353
+ <strong>Old location:</strong> <code>{info.path}</code> ({info.sizeMB} MB)
354
+ </small>
355
+ <button
356
+ className="btn btn-danger btn-sm"
357
+ disabled={busy}
358
+ onClick={async () => {
359
+ const confirmed = confirm(
360
+ `Delete the old data directory? This will free ~${info.sizeMB} MB.\n\n${info.path}\n\nThis cannot be undone.`,
361
+ );
362
+ if (!confirmed) return;
363
+ setBusy(true);
364
+ try {
365
+ await rpcServerCalls.cleanupOldDataDir();
366
+ setInfo(null);
367
+ alert("Old data directory deleted.");
368
+ } catch (err) {
369
+ alert(`Failed to delete: ${(err as Error).message}`);
370
+ } finally {
371
+ setBusy(false);
372
+ }
373
+ }}
374
+ >
375
+ {busy ? "Deleting..." : "Delete Old Data Directory"}
376
+ </button>
377
+ </div>
378
+ );
379
+ };
380
+
331
381
  const ResetChangeTracking: React.FC = () => {
332
382
  const [busy, setBusy] = useState(false);
333
383
  return (