@planningcenter/topbar 12.5.0-rc.4 → 12.5.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.
- package/dist/topbar.js +47 -10
- package/dist/topbar.js.map +1 -1
- package/dist/topbar.modern.js +47 -10
- package/dist/topbar.modern.js.map +1 -1
- package/dist/topbar.module.js +47 -10
- package/dist/topbar.module.js.map +1 -1
- package/dist/topbar.umd.js +47 -10
- package/dist/topbar.umd.js.map +1 -1
- package/package.json +3 -4
package/dist/topbar.js
CHANGED
|
@@ -4130,7 +4130,18 @@ function subject(token) {
|
|
|
4130
4130
|
return undefined;
|
|
4131
4131
|
}
|
|
4132
4132
|
}
|
|
4133
|
-
|
|
4133
|
+
const minting = new Map();
|
|
4134
|
+
function mintToken(personId) {
|
|
4135
|
+
const running = minting.get(personId);
|
|
4136
|
+
if (running) {
|
|
4137
|
+
return running;
|
|
4138
|
+
} else {
|
|
4139
|
+
const run = mint(personId).finally(() => minting.delete(personId));
|
|
4140
|
+
minting.set(personId, run);
|
|
4141
|
+
return run;
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
async function mint(personId) {
|
|
4134
4145
|
const {
|
|
4135
4146
|
json,
|
|
4136
4147
|
ok,
|
|
@@ -4154,6 +4165,10 @@ async function mintToken(personId) {
|
|
|
4154
4165
|
}
|
|
4155
4166
|
return token;
|
|
4156
4167
|
}
|
|
4168
|
+
function currentToken(personId) {
|
|
4169
|
+
var _a;
|
|
4170
|
+
return (_a = cachedToken(personId)) !== null && _a !== void 0 ? _a : mintToken(personId).catch(() => null);
|
|
4171
|
+
}
|
|
4157
4172
|
async function request(personId, key, init = {}, isRetry = false) {
|
|
4158
4173
|
var _a;
|
|
4159
4174
|
const token = isRetry ? await mintToken(personId) : (_a = cachedToken(personId)) !== null && _a !== void 0 ? _a : await mintToken(personId);
|
|
@@ -4189,8 +4204,8 @@ function ifMatch(version) {
|
|
|
4189
4204
|
// retrying when another tab or device wrote in between. `change` returns null
|
|
4190
4205
|
// when there's nothing to write. A read-only token (staff impersonating
|
|
4191
4206
|
// someone) only reads, so nothing is written into the person's history.
|
|
4192
|
-
// Resolves to the value now stored,
|
|
4193
|
-
// reached.
|
|
4207
|
+
// Resolves to the value now stored, with whether the token was read-only, or
|
|
4208
|
+
// null when the service couldn't be reached.
|
|
4194
4209
|
async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEMPTS) {
|
|
4195
4210
|
const read = await request(personId, key);
|
|
4196
4211
|
if (read === null || read === void 0 ? void 0 : read.response.ok) {
|
|
@@ -4198,9 +4213,15 @@ async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEM
|
|
|
4198
4213
|
value,
|
|
4199
4214
|
version
|
|
4200
4215
|
} = await read.response.json();
|
|
4201
|
-
const
|
|
4216
|
+
const {
|
|
4217
|
+
readOnly
|
|
4218
|
+
} = read.token;
|
|
4219
|
+
const next = readOnly ? null : change(value);
|
|
4202
4220
|
if (next === null) {
|
|
4203
|
-
return
|
|
4221
|
+
return {
|
|
4222
|
+
readOnly,
|
|
4223
|
+
value: Array.isArray(value) ? value : []
|
|
4224
|
+
};
|
|
4204
4225
|
} else {
|
|
4205
4226
|
const write = await request(personId, key, {
|
|
4206
4227
|
body: JSON.stringify({
|
|
@@ -4213,7 +4234,10 @@ async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEM
|
|
|
4213
4234
|
method: "PUT"
|
|
4214
4235
|
});
|
|
4215
4236
|
if (write === null || write === void 0 ? void 0 : write.response.ok) {
|
|
4216
|
-
return
|
|
4237
|
+
return {
|
|
4238
|
+
readOnly,
|
|
4239
|
+
value: next
|
|
4240
|
+
};
|
|
4217
4241
|
} else if ((write === null || write === void 0 ? void 0 : write.response.status) === 409 && attemptsLeft > 1) {
|
|
4218
4242
|
return updateStoredValue(personId, key, change, attemptsLeft - 1);
|
|
4219
4243
|
} else {
|
|
@@ -4265,7 +4289,8 @@ async function syncOnce(scope) {
|
|
|
4265
4289
|
return isSameList(mergeEntries(shared, local), shared) ? null : mergeStored(stored, local);
|
|
4266
4290
|
});
|
|
4267
4291
|
if (synced) {
|
|
4268
|
-
|
|
4292
|
+
const shared = entriesFrom(synced.value);
|
|
4293
|
+
writeRecentlyVisited(scope, synced.readOnly ? shared : mergeEntries(shared, readRecentlyVisited(scope)));
|
|
4269
4294
|
}
|
|
4270
4295
|
} catch {
|
|
4271
4296
|
// The service is best-effort; the local copy stands on its own.
|
|
@@ -4296,11 +4321,23 @@ function sync(scope, followUp) {
|
|
|
4296
4321
|
function syncRecentlyVisited(scope) {
|
|
4297
4322
|
return sync(scope, false);
|
|
4298
4323
|
}
|
|
4324
|
+
function record(entry, scope, token) {
|
|
4325
|
+
if (!(token === null || token === void 0 ? void 0 : token.readOnly)) {
|
|
4326
|
+
writeRecentlyVisited(scope, addVisit(readRecentlyVisited(scope), entry));
|
|
4327
|
+
if (token) sync(scope, true);
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4299
4330
|
function recordVisit(visit, scope) {
|
|
4300
4331
|
const entry = toEntry(visit, new Date());
|
|
4301
|
-
if (isEntry(entry)) {
|
|
4302
|
-
|
|
4303
|
-
|
|
4332
|
+
if (!isEntry(entry)) {
|
|
4333
|
+
return Promise.resolve();
|
|
4334
|
+
}
|
|
4335
|
+
const token = isUserStoreSyncUnavailable() ? null : currentToken(scope.personId);
|
|
4336
|
+
if (token instanceof Promise) {
|
|
4337
|
+
return token.then(minted => record(entry, scope, minted));
|
|
4338
|
+
} else {
|
|
4339
|
+
record(entry, scope, token);
|
|
4340
|
+
return Promise.resolve();
|
|
4304
4341
|
}
|
|
4305
4342
|
}
|
|
4306
4343
|
function useRecentlyVisited({
|