fix(orders): load user center assets before panel navigation
This commit is contained in:
1 parent
01e9a0f4ca
commit
651c5f28f8
5 files changed
+265
-254
No files matched your search
@@ -77,6 +77,9 @@
|
||||
if (target._aksrtPanelRequest) return target._aksrtPanelRequest;
|
||||
var restUrl = (window.aksrtData && (window.aksrtData.restUrl || window.aksrtData.apiUrl)) || cfg.restUrl || '';
|
||||
if (!restUrl) return Promise.reject(new Error('rest-unavailable'));
|
||||
if (name === 'orders' && (!window.AKSRTOrderCenter || typeof window.AKSRTOrderCenter.init !== 'function')) {
|
||||
return Promise.reject(new Error('orders-initializer-unavailable'));
|
||||
}
|
||||
target.classList.add('is-loading');
|
||||
var url = restUrl.replace(/\/$/, '') + '/user-center/panel/' + encodeURIComponent(name);
|
||||
if (name === 'creator') {
|
||||
@@ -91,7 +94,13 @@
|
||||
}).then(function(response) {
|
||||
return response.json().then(function(payload) {
|
||||
if (!response.ok || !payload || !payload.success || !payload.data || typeof payload.data.html !== 'string') throw new Error('panel-load-failed');
|
||||
if (name === 'orders' && window.AKSRTOrderCenter && typeof window.AKSRTOrderCenter.destroy === 'function') {
|
||||
window.AKSRTOrderCenter.destroy(target);
|
||||
}
|
||||
target.innerHTML = payload.data.html;
|
||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.rehydrate === 'function') {
|
||||
window.AksrtFrontend.rehydrate(target, 'ajax');
|
||||
}
|
||||
target.dataset.panelLoaded = 'true';
|
||||
});
|
||||
}).finally(function() {
|
||||
|
||||
Reference in new issue
Block a user