fix(modal): close rollout and async lifecycle gaps
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5375ad6429
commit
aa865e24e1
8 files changed
+86
-31
No files matched your search
@@ -10,11 +10,15 @@
|
||||
var DEFAULT_TTL = 15000;
|
||||
var entries = Object.create(null);
|
||||
var flights = Object.create(null);
|
||||
var lastScope = "";
|
||||
|
||||
function scope() {
|
||||
var config = window.aksrtData || window.aksrt || {};
|
||||
var userId = parseInt(config.userId || 0, 10) || 0;
|
||||
return (config.isLoggedIn && userId > 0 ? "user:" + userId : "guest") + ":v1";
|
||||
var current = (config.isLoggedIn && userId > 0 ? "user:" + userId : "guest") + ":v1";
|
||||
if (lastScope && lastScope !== current) clear();
|
||||
lastScope = current;
|
||||
return current;
|
||||
}
|
||||
|
||||
function token(key) {
|
||||
|
||||
@@ -342,11 +342,12 @@
|
||||
},
|
||||
};
|
||||
|
||||
session.flight = cacheable
|
||||
var flight = cacheable
|
||||
? cache.acquire(cacheKey, request, acquireOptions)
|
||||
: { promise: request(), release: function () {} };
|
||||
session.flight = flight;
|
||||
|
||||
return session.flight.promise.then(function (result) {
|
||||
return flight.promise.then(function (result) {
|
||||
if (!session.closed && active === session) renderResult(session, result);
|
||||
return session.shell;
|
||||
}).catch(function (error) {
|
||||
@@ -354,8 +355,12 @@
|
||||
if (!aborted && !session.closed && active === session) renderError(session, error);
|
||||
return session.shell;
|
||||
}).then(function (shell) {
|
||||
if (session.flight && typeof session.flight.release === "function") session.flight.release();
|
||||
session.flight = null;
|
||||
// A refresh/replacement may have installed a newer flight on this session.
|
||||
// Only the owner of this promise may release and clear the slot.
|
||||
if (session.flight === flight) {
|
||||
if (flight && typeof flight.release === "function") flight.release();
|
||||
session.flight = null;
|
||||
}
|
||||
return shell;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user