@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.modern.js
CHANGED
|
@@ -4105,7 +4105,18 @@ function subject(token) {
|
|
|
4105
4105
|
return undefined;
|
|
4106
4106
|
}
|
|
4107
4107
|
}
|
|
4108
|
-
|
|
4108
|
+
const minting = new Map();
|
|
4109
|
+
function mintToken(personId) {
|
|
4110
|
+
const running = minting.get(personId);
|
|
4111
|
+
if (running) {
|
|
4112
|
+
return running;
|
|
4113
|
+
} else {
|
|
4114
|
+
const run = mint(personId).finally(() => minting.delete(personId));
|
|
4115
|
+
minting.set(personId, run);
|
|
4116
|
+
return run;
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
async function mint(personId) {
|
|
4109
4120
|
const {
|
|
4110
4121
|
json,
|
|
4111
4122
|
ok,
|
|
@@ -4129,6 +4140,10 @@ async function mintToken(personId) {
|
|
|
4129
4140
|
}
|
|
4130
4141
|
return token;
|
|
4131
4142
|
}
|
|
4143
|
+
function currentToken(personId) {
|
|
4144
|
+
var _a;
|
|
4145
|
+
return (_a = cachedToken(personId)) !== null && _a !== void 0 ? _a : mintToken(personId).catch(() => null);
|
|
4146
|
+
}
|
|
4132
4147
|
async function request(personId, key, init = {}, isRetry = false) {
|
|
4133
4148
|
var _a;
|
|
4134
4149
|
const token = isRetry ? await mintToken(personId) : (_a = cachedToken(personId)) !== null && _a !== void 0 ? _a : await mintToken(personId);
|
|
@@ -4164,8 +4179,8 @@ function ifMatch(version) {
|
|
|
4164
4179
|
// retrying when another tab or device wrote in between. `change` returns null
|
|
4165
4180
|
// when there's nothing to write. A read-only token (staff impersonating
|
|
4166
4181
|
// someone) only reads, so nothing is written into the person's history.
|
|
4167
|
-
// Resolves to the value now stored,
|
|
4168
|
-
// reached.
|
|
4182
|
+
// Resolves to the value now stored, with whether the token was read-only, or
|
|
4183
|
+
// null when the service couldn't be reached.
|
|
4169
4184
|
async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEMPTS) {
|
|
4170
4185
|
const read = await request(personId, key);
|
|
4171
4186
|
if (read === null || read === void 0 ? void 0 : read.response.ok) {
|
|
@@ -4173,9 +4188,15 @@ async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEM
|
|
|
4173
4188
|
value,
|
|
4174
4189
|
version
|
|
4175
4190
|
} = await read.response.json();
|
|
4176
|
-
const
|
|
4191
|
+
const {
|
|
4192
|
+
readOnly
|
|
4193
|
+
} = read.token;
|
|
4194
|
+
const next = readOnly ? null : change(value);
|
|
4177
4195
|
if (next === null) {
|
|
4178
|
-
return
|
|
4196
|
+
return {
|
|
4197
|
+
readOnly,
|
|
4198
|
+
value: Array.isArray(value) ? value : []
|
|
4199
|
+
};
|
|
4179
4200
|
} else {
|
|
4180
4201
|
const write = await request(personId, key, {
|
|
4181
4202
|
body: JSON.stringify({
|
|
@@ -4188,7 +4209,10 @@ async function updateStoredValue(personId, key, change, attemptsLeft = MAX_ATTEM
|
|
|
4188
4209
|
method: "PUT"
|
|
4189
4210
|
});
|
|
4190
4211
|
if (write === null || write === void 0 ? void 0 : write.response.ok) {
|
|
4191
|
-
return
|
|
4212
|
+
return {
|
|
4213
|
+
readOnly,
|
|
4214
|
+
value: next
|
|
4215
|
+
};
|
|
4192
4216
|
} else if ((write === null || write === void 0 ? void 0 : write.response.status) === 409 && attemptsLeft > 1) {
|
|
4193
4217
|
return updateStoredValue(personId, key, change, attemptsLeft - 1);
|
|
4194
4218
|
} else {
|
|
@@ -4240,7 +4264,8 @@ async function syncOnce(scope) {
|
|
|
4240
4264
|
return isSameList(mergeEntries(shared, local), shared) ? null : mergeStored(stored, local);
|
|
4241
4265
|
});
|
|
4242
4266
|
if (synced) {
|
|
4243
|
-
|
|
4267
|
+
const shared = entriesFrom(synced.value);
|
|
4268
|
+
writeRecentlyVisited(scope, synced.readOnly ? shared : mergeEntries(shared, readRecentlyVisited(scope)));
|
|
4244
4269
|
}
|
|
4245
4270
|
} catch {
|
|
4246
4271
|
// The service is best-effort; the local copy stands on its own.
|
|
@@ -4271,11 +4296,23 @@ function sync(scope, followUp) {
|
|
|
4271
4296
|
function syncRecentlyVisited(scope) {
|
|
4272
4297
|
return sync(scope, false);
|
|
4273
4298
|
}
|
|
4299
|
+
function record(entry, scope, token) {
|
|
4300
|
+
if (!(token === null || token === void 0 ? void 0 : token.readOnly)) {
|
|
4301
|
+
writeRecentlyVisited(scope, addVisit(readRecentlyVisited(scope), entry));
|
|
4302
|
+
if (token) sync(scope, true);
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4274
4305
|
function recordVisit(visit, scope) {
|
|
4275
4306
|
const entry = toEntry(visit, new Date());
|
|
4276
|
-
if (isEntry(entry)) {
|
|
4277
|
-
|
|
4278
|
-
|
|
4307
|
+
if (!isEntry(entry)) {
|
|
4308
|
+
return Promise.resolve();
|
|
4309
|
+
}
|
|
4310
|
+
const token = isUserStoreSyncUnavailable() ? null : currentToken(scope.personId);
|
|
4311
|
+
if (token instanceof Promise) {
|
|
4312
|
+
return token.then(minted => record(entry, scope, minted));
|
|
4313
|
+
} else {
|
|
4314
|
+
record(entry, scope, token);
|
|
4315
|
+
return Promise.resolve();
|
|
4279
4316
|
}
|
|
4280
4317
|
}
|
|
4281
4318
|
function useRecentlyVisited({
|