@peers-app/peers-sdk 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.
|
@@ -16,6 +16,7 @@ export declare class UserContext {
|
|
|
16
16
|
readonly defaultDataContext: Observable<DataContext>;
|
|
17
17
|
readonly loadingPromise: Promise<UserContext>;
|
|
18
18
|
private personalUserSubscription?;
|
|
19
|
+
private _currentlyActiveGroupIdPVar?;
|
|
19
20
|
constructor(userId: string, dataSourceFactory: DataSourceFactory, ephemeral?: boolean | undefined);
|
|
20
21
|
private init;
|
|
21
22
|
/**
|
|
@@ -25,6 +26,8 @@ export declare class UserContext {
|
|
|
25
26
|
private loadAllPackages;
|
|
26
27
|
private loadGroupContexts;
|
|
27
28
|
getDataContext(groupId: string): DataContext;
|
|
29
|
+
/** Wait for any pending `currentlyActiveGroupId` pvar write to be flushed to the DB. */
|
|
30
|
+
waitForActiveGroupPersistence(): Promise<void>;
|
|
28
31
|
/**
|
|
29
32
|
* Load observables from the database
|
|
30
33
|
* This is pretty ugly but get's around guards on the default logic which is waiting
|
|
@@ -21,6 +21,7 @@ class UserContext {
|
|
|
21
21
|
defaultDataContext;
|
|
22
22
|
loadingPromise;
|
|
23
23
|
personalUserSubscription;
|
|
24
|
+
_currentlyActiveGroupIdPVar;
|
|
24
25
|
constructor(userId, dataSourceFactory, ephemeral) {
|
|
25
26
|
this.userId = userId;
|
|
26
27
|
this.dataSourceFactory = dataSourceFactory;
|
|
@@ -112,6 +113,12 @@ class UserContext {
|
|
|
112
113
|
}
|
|
113
114
|
return this.groupDataContexts.get(groupId);
|
|
114
115
|
}
|
|
116
|
+
/** Wait for any pending `currentlyActiveGroupId` pvar write to be flushed to the DB. */
|
|
117
|
+
async waitForActiveGroupPersistence() {
|
|
118
|
+
if (this._currentlyActiveGroupIdPVar) {
|
|
119
|
+
await this._currentlyActiveGroupIdPVar.loadingPromise;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
115
122
|
/**
|
|
116
123
|
* Load observables from the database
|
|
117
124
|
* This is pretty ugly but get's around guards on the default logic which is waiting
|
|
@@ -130,6 +137,7 @@ class UserContext {
|
|
|
130
137
|
this.deviceId(deviceIdPVar());
|
|
131
138
|
(0, observable_1.linkObservables)(deviceIdPVar, this.deviceId);
|
|
132
139
|
const currentlyActiveGroupIdPVar = (0, data_1.deviceVar)('currentlyActiveGroupId', { dbValue: varDbValues['currentlyActiveGroupId'], defaultValue: '', userContext: this });
|
|
140
|
+
this._currentlyActiveGroupIdPVar = currentlyActiveGroupIdPVar;
|
|
133
141
|
this.currentlyActiveGroupId(currentlyActiveGroupIdPVar());
|
|
134
142
|
(0, observable_1.linkObservables)(currentlyActiveGroupIdPVar, this.currentlyActiveGroupId);
|
|
135
143
|
const reloadPackagesOnPageRefreshPVar = (0, data_1.deviceVar)('reloadPackagesOnPageRefresh', { defaultValue: false, dbValue: varDbValues['reloadPackagesOnPageRefresh'], userContext: this });
|
|
@@ -137,6 +145,7 @@ class UserContext {
|
|
|
137
145
|
(0, observable_1.linkObservables)(reloadPackagesOnPageRefreshPVar, this.reloadPackagesOnPageRefresh);
|
|
138
146
|
await Promise.all([
|
|
139
147
|
deviceIdPVar.loadingPromise,
|
|
148
|
+
currentlyActiveGroupIdPVar.loadingPromise,
|
|
140
149
|
reloadPackagesOnPageRefreshPVar.loadingPromise,
|
|
141
150
|
]);
|
|
142
151
|
}
|
package/dist/rpc-types.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export declare const rpcServerCalls: {
|
|
|
112
112
|
voiceNotifyTextActivity: (() => Promise<void>);
|
|
113
113
|
voiceDisable: (() => Promise<void>);
|
|
114
114
|
voiceEnable: (() => Promise<void>);
|
|
115
|
+
flushDatabases: (() => Promise<void>);
|
|
115
116
|
};
|
|
116
117
|
export declare const rpcClientCalls: {
|
|
117
118
|
ping: (msg: string) => Promise<string>;
|
package/dist/rpc-types.js
CHANGED
|
@@ -59,6 +59,9 @@ exports.rpcServerCalls = {
|
|
|
59
59
|
voiceNotifyTextActivity: rpcStub('voiceNotifyTextActivity'),
|
|
60
60
|
voiceDisable: rpcStub('voiceDisable'),
|
|
61
61
|
voiceEnable: rpcStub('voiceEnable'),
|
|
62
|
+
// Flush all in-memory database snapshots to durable storage (IndexedDB in PWA).
|
|
63
|
+
// No-op on Electron where better-sqlite3 writes are synchronous to disk.
|
|
64
|
+
flushDatabases: (async () => { }),
|
|
62
65
|
// TODO try to get rid of this and rely on the client-side table and server-side table individually emitting events
|
|
63
66
|
// TODO TODO before deleting this, check if we can stop client-side tables from emitting events and rely solely on server-side tables
|
|
64
67
|
// propagating events with rpcClientCalls.emitEvent. It's very likely we're currently seeing two events for every one write originating from the UI
|