@peers-app/peers-ui 0.13.5 → 0.13.6

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.
@@ -70,6 +70,7 @@ const GroupDetails = (props) => {
70
70
  const deleteResult = await originalDelete();
71
71
  userContext.defaultDataContext(userContext.userDataContext);
72
72
  await (0, peers_sdk_1.sleep)(100);
73
+ await peers_sdk_1.rpcServerCalls.flushDatabases();
73
74
  window.location.reload();
74
75
  return deleteResult;
75
76
  };
@@ -128,14 +128,16 @@ function TabsLayoutInternal() {
128
128
  const [tabs] = (0, hooks_1.useObservable)(tabs_state_1.activeTabs);
129
129
  const [activeTab] = (0, hooks_1.useObservable)(tabs_state_1.activeTabId);
130
130
  const [currentlyActiveGroupId, setCurrentlyActiveGroupId] = (0, react_1.useState)('');
131
+ const [switchingGroup, setSwitchingGroup] = (0, react_1.useState)(false);
131
132
  (0, react_1.useEffect)(() => {
132
133
  let sub;
133
134
  (0, peers_sdk_1.getUserContext)().then(userContext => {
134
135
  setCurrentlyActiveGroupId(userContext.currentlyActiveGroupId() || userContext.userId);
135
136
  sub = userContext.currentlyActiveGroupId.subscribe(async (groupId) => {
136
137
  setCurrentlyActiveGroupId(userContext.currentlyActiveGroupId() || userContext.userId);
137
- // below reloading logic is a kludge to deal with different groups having different packages installed
138
- await (0, peers_sdk_1.sleep)(250);
138
+ setSwitchingGroup(true);
139
+ await userContext.waitForActiveGroupPersistence();
140
+ await peers_sdk_1.rpcServerCalls.flushDatabases();
139
141
  window.location.reload();
140
142
  });
141
143
  });
@@ -172,6 +174,14 @@ function TabsLayoutInternal() {
172
174
  (0, tabs_state_1.activeTabId)(tabId);
173
175
  };
174
176
  return (react_1.default.createElement("div", { key: currentlyActiveGroupId, className: "d-flex flex-column", style: { height: 'calc(100vh - 25px)', overflow: 'hidden' } },
177
+ switchingGroup && (react_1.default.createElement("div", { style: {
178
+ position: 'fixed', inset: 0, zIndex: 9999,
179
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
180
+ backgroundColor: _colorMode === 'light' ? 'rgba(255,255,255,0.85)' : 'rgba(0,0,0,0.85)',
181
+ } },
182
+ react_1.default.createElement("div", { className: "text-center" },
183
+ react_1.default.createElement("div", { className: "spinner-border text-secondary mb-3", role: "status" }),
184
+ react_1.default.createElement("div", { className: `small ${_colorMode === 'light' ? 'text-muted' : 'text-secondary'}` }, "Switching group...")))),
175
185
  react_1.default.createElement("div", { className: `border-bottom ${_colorMode === 'light' ? 'bg-light' : 'bg-dark'}`, style: {
176
186
  borderBottomWidth: '1px',
177
187
  borderBottomColor: _colorMode === 'light' ? '#dee2e6' : '#495057'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-ui.git"
@@ -26,7 +26,7 @@
26
26
  "test:coverage": "jest --coverage"
27
27
  },
28
28
  "peerDependencies": {
29
- "@peers-app/peers-sdk": "^0.13.5",
29
+ "@peers-app/peers-sdk": "^0.13.6",
30
30
  "bootstrap": "^5.3.3",
31
31
  "react": "^18.0.0",
32
32
  "react-dom": "^18.0.0"
@@ -36,7 +36,7 @@
36
36
  "@babel/preset-env": "^7.24.5",
37
37
  "@babel/preset-react": "^7.24.1",
38
38
  "@babel/preset-typescript": "^7.27.1",
39
- "@peers-app/peers-sdk": "0.13.5",
39
+ "@peers-app/peers-sdk": "0.13.6",
40
40
  "@testing-library/dom": "^10.4.0",
41
41
  "@testing-library/jest-dom": "^6.6.3",
42
42
  "@testing-library/react": "^16.3.0",
@@ -1,4 +1,4 @@
1
- import { getIconClassName, getUserContext, Groups, IDoc, IGroup, Observable, generateGroupShare, checkQRCodeCompatibility, copyToClipboard, sleep } from "@peers-app/peers-sdk";
1
+ import { getIconClassName, getUserContext, Groups, IDoc, IGroup, Observable, generateGroupShare, checkQRCodeCompatibility, copyToClipboard, rpcServerCalls, sleep } from "@peers-app/peers-sdk";
2
2
  import React, { useState } from "react";
3
3
  import { Checkbox } from "../../components/checkbox";
4
4
  import { Input } from "../../components/input";
@@ -40,6 +40,7 @@ export const GroupDetails = (props: IProps) => {
40
40
  const deleteResult = await originalDelete();
41
41
  userContext.defaultDataContext(userContext.userDataContext);
42
42
  await sleep(100);
43
+ await rpcServerCalls.flushDatabases();
43
44
  window.location.reload();
44
45
  return deleteResult;
45
46
  }
@@ -1,4 +1,4 @@
1
- import { getUserContext, hasShownWelcomeModal, IAppNav, rpcServerCalls, setDefaultClientUserContext, sleep, Subscription } from "@peers-app/peers-sdk";
1
+ import { getUserContext, hasShownWelcomeModal, IAppNav, rpcServerCalls, setDefaultClientUserContext, Subscription } from "@peers-app/peers-sdk";
2
2
  import React, { Component, useEffect, useState } from 'react';
3
3
  import { openCommandPalette } from '../command-palette/command-palette';
4
4
  import { CommandPaletteOverlay } from '../command-palette/command-palette-ui';
@@ -132,6 +132,7 @@ function TabsLayoutInternal() {
132
132
  const [tabs] = useObservable(activeTabs);
133
133
  const [activeTab] = useObservable(activeTabId);
134
134
  const [currentlyActiveGroupId, setCurrentlyActiveGroupId] = useState('');
135
+ const [switchingGroup, setSwitchingGroup] = useState(false);
135
136
 
136
137
  useEffect(() => {
137
138
  let sub: Subscription;
@@ -139,8 +140,9 @@ function TabsLayoutInternal() {
139
140
  setCurrentlyActiveGroupId(userContext.currentlyActiveGroupId() || userContext.userId)
140
141
  sub = userContext.currentlyActiveGroupId.subscribe(async groupId => {
141
142
  setCurrentlyActiveGroupId(userContext.currentlyActiveGroupId() || userContext.userId);
142
- // below reloading logic is a kludge to deal with different groups having different packages installed
143
- await sleep(250);
143
+ setSwitchingGroup(true);
144
+ await userContext.waitForActiveGroupPersistence();
145
+ await rpcServerCalls.flushDatabases();
144
146
  window.location.reload();
145
147
  });
146
148
  });
@@ -184,6 +186,18 @@ function TabsLayoutInternal() {
184
186
  <div
185
187
  key={currentlyActiveGroupId}
186
188
  className="d-flex flex-column" style={{ height: 'calc(100vh - 25px)', overflow: 'hidden' }}>
189
+ {switchingGroup && (
190
+ <div style={{
191
+ position: 'fixed', inset: 0, zIndex: 9999,
192
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
193
+ backgroundColor: _colorMode === 'light' ? 'rgba(255,255,255,0.85)' : 'rgba(0,0,0,0.85)',
194
+ }}>
195
+ <div className="text-center">
196
+ <div className="spinner-border text-secondary mb-3" role="status" />
197
+ <div className={`small ${_colorMode === 'light' ? 'text-muted' : 'text-secondary'}`}>Switching group...</div>
198
+ </div>
199
+ </div>
200
+ )}
187
201
  {/* Tabs Header */}
188
202
  <div
189
203
  className={`border-bottom ${_colorMode === 'light' ? 'bg-light' : 'bg-dark'}`}