fix file new/open clearing and rebuilding state
This commit is contained in:
parent
9433cbf09a
commit
8c8afaba69
2 changed files with 22 additions and 1 deletions
|
|
@ -331,6 +331,7 @@ function createDocumentApi(getApi, cfg) {
|
||||||
createAndSelect() {
|
createAndSelect() {
|
||||||
this.create();
|
this.create();
|
||||||
this.hydrateRuntimeState(this.current);
|
this.hydrateRuntimeState(this.current);
|
||||||
|
getApi().solids?.onDocumentHydrated?.('document.new');
|
||||||
return this.save({
|
return this.save({
|
||||||
kind: 'major',
|
kind: 'major',
|
||||||
opType: 'snapshot',
|
opType: 'snapshot',
|
||||||
|
|
@ -360,6 +361,7 @@ function createDocumentApi(getApi, cfg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this._redoStack = [];
|
this._redoStack = [];
|
||||||
|
api.solids?.onDocumentHydrated?.('document.open');
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
api.db.admin.put(ADMIN_CURRENT_DOC_KEY, this.current.id),
|
api.db.admin.put(ADMIN_CURRENT_DOC_KEY, this.current.id),
|
||||||
api.db.admin.put(ADMIN_CURRENT_REV_KEY, this.current.head_rev || null)
|
api.db.admin.put(ADMIN_CURRENT_REV_KEY, this.current.head_rev || null)
|
||||||
|
|
@ -427,7 +429,7 @@ function createDocumentApi(getApi, cfg) {
|
||||||
this.current.head_rev = revision.rev_id || this.revisionKey(this.current.id, this.current.version);
|
this.current.head_rev = revision.rev_id || this.revisionKey(this.current.id, this.current.version);
|
||||||
this.current.modified_at = revision.created_at || this.current.modified_at || Date.now();
|
this.current.modified_at = revision.created_at || this.current.modified_at || Date.now();
|
||||||
this.hydrateRuntimeState(this.current);
|
this.hydrateRuntimeState(this.current);
|
||||||
api.solids?.scheduleRebuild?.('document.hydrate');
|
api.solids?.onDocumentHydrated?.('document.hydrate');
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
api.db.documents.put(this.current.id, this.current),
|
api.db.documents.put(this.current.id, this.current),
|
||||||
api.db.admin.put(ADMIN_CURRENT_DOC_KEY, this.current.id),
|
api.db.admin.put(ADMIN_CURRENT_DOC_KEY, this.current.id),
|
||||||
|
|
|
||||||
|
|
@ -1003,6 +1003,25 @@ function edgeKey(a, b) {
|
||||||
world?.add?.(this._root);
|
world?.add?.(this._root);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDocumentHydrated(reason = 'document.hydrate', options = {}) {
|
||||||
|
clearTimeout(this._rebuildTimer);
|
||||||
|
this._pendingReason = null;
|
||||||
|
// Invalidate any in-flight rebuild response from prior document state.
|
||||||
|
this._rebuildSeq++;
|
||||||
|
this._meshCache = new Map();
|
||||||
|
this._selectedIds.clear();
|
||||||
|
this._hoveredIds.clear();
|
||||||
|
this._selectedFaceKeys.clear();
|
||||||
|
this._hoveredFaceKey = null;
|
||||||
|
this._selectedEdgeKeys.clear();
|
||||||
|
this._hoveredEdgeKey = null;
|
||||||
|
this._frozenChamferEdges = null;
|
||||||
|
this.syncRuntime();
|
||||||
|
if (options?.rebuild !== false) {
|
||||||
|
this.scheduleRebuild(reason, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getSketchDerivedBoundarySegmentsForSolid(solid) {
|
getSketchDerivedBoundarySegmentsForSolid(solid) {
|
||||||
const api = getApi();
|
const api = getApi();
|
||||||
if (!solid || String(solid?.source?.feature_type || '') !== 'extrude') return [];
|
if (!solid || String(solid?.source?.feature_type || '') !== 'extrude') return [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue