This commit is contained in:
Janet Vorobyeva 2023-09-12 00:50:54 -07:00
parent 598b8260b6
commit e0fa76530a
2 changed files with 11 additions and 8 deletions

View File

@ -156,7 +156,8 @@ export class Cursor extends Disposable {
public setCursorPos(cursorPos: CursorPos, silentUpdate: boolean = false): void { public setCursorPos(cursorPos: CursorPos, silentUpdate: boolean = false): void {
//If updating as a result of links, we want to NOT update lastEditedAt //If updating as a result of links, we want to NOT update lastEditedAt
if(silentUpdate) { this._silentUpdatesFlag = true; } if(silentUpdate) { this._silentUpdatesFlag = true; }
//console.log(`CURSOR: ${silentUpdate}, silentUpdate=${this._silentUpdatesFlag}, lastUpdated = ${this.lastUpdated.peek()}`) //TODO JV DEBUG TEMP //console.log(`CURSOR: ${silentUpdate}, silentUpdate=${this._silentUpdatesFlag},
// lastUpdated = ${this.lastUpdated.peek()}`) //TODO JV DEBUG TEMP
if (cursorPos.rowId !== undefined && this.viewData.getRowIndex(cursorPos.rowId) >= 0) { if (cursorPos.rowId !== undefined && this.viewData.getRowIndex(cursorPos.rowId) >= 0) {
this.rowIndex(this.viewData.getRowIndex(cursorPos.rowId) ); this.rowIndex(this.viewData.getRowIndex(cursorPos.rowId) );
@ -170,7 +171,8 @@ export class Cursor extends Disposable {
this.fieldIndex(cursorPos.fieldIndex); this.fieldIndex(cursorPos.fieldIndex);
} }
//console.log(`CURSOR-END: silentUpdate=${this._silentUpdatesFlag}, lastEditedAt = ${this._lastEditedAt.peek()} `); //TODO JV DEBUG TEMP //console.log(`CURSOR-END: silentUpdate=${this._silentUpdatesFlag},
// lastEditedAt = ${this._lastEditedAt.peek()} `); //TODO JV DEBUG TEMP
this._silentUpdatesFlag = false; this._silentUpdatesFlag = false;
} }

View File

@ -78,7 +78,7 @@ export class LinkingState extends Disposable {
private _docModel: DocModel; private _docModel: DocModel;
private _srcSection: ViewSectionRec; private _srcSection: ViewSectionRec;
private _tgtSection: ViewSectionRec; //private _tgtSection: ViewSectionRec;
private _srcTableModel: DataTableModel; private _srcTableModel: DataTableModel;
private _srcColId: string | undefined; private _srcColId: string | undefined;
@ -87,12 +87,13 @@ export class LinkingState extends Disposable {
const {srcSection, srcCol, srcColId, tgtSection, tgtCol, tgtColId} = linkConfig; const {srcSection, srcCol, srcColId, tgtSection, tgtCol, tgtColId} = linkConfig;
this._docModel = docModel; this._docModel = docModel;
this._srcSection = srcSection; this._srcSection = srcSection;
this._tgtSection = tgtSection; //this._tgtSection = tgtSection;
this._srcColId = srcColId; this._srcColId = srcColId;
this._srcTableModel = docModel.dataTables[srcSection.table().tableId()]; this._srcTableModel = docModel.dataTables[srcSection.table().tableId()];
const srcTableData = this._srcTableModel.tableData; const srcTableData = this._srcTableModel.tableData;
console.log(`============ LinkingState: Re-running constructor; tgtSec:${tgtSection.id()}: ${tgtSection.titleDef()}`); //TODO JV TEMP; //TODO JV TEMP;
console.log(`======= LinkingState: Re-running constructor; tgtSec:${tgtSection.id()}: ${tgtSection.titleDef()}`);
// === IMPORTANT NOTE! (this applies throughout this file) // === IMPORTANT NOTE! (this applies throughout this file)
@ -221,7 +222,8 @@ export class LinkingState extends Disposable {
(prevLink.linkTypeDescription() == "Cursor:Same-Table" || (prevLink.linkTypeDescription() == "Cursor:Same-Table" ||
prevLink.linkTypeDescription() == "Cursor:Reference"); prevLink.linkTypeDescription() == "Cursor:Reference");
const [prevLinkedPos, prevLinkedVersion] = prevLinkHasCursor ? prevLink.incomingCursorPos(): [null, SequenceNEVER]; const [prevLinkedPos, prevLinkedVersion] = prevLinkHasCursor ? prevLink.incomingCursorPos() :
[null, SequenceNEVER];
const srcSecPos = this._srcSection.activeRowId.peek(); //we don't depend on this, only on its cursor version const srcSecPos = this._srcSection.activeRowId.peek(); //we don't depend on this, only on its cursor version
const srcSecVersion = this._srcSection.lastCursorEdit(); const srcSecVersion = this._srcSection.lastCursorEdit();
@ -258,8 +260,7 @@ export class LinkingState extends Disposable {
//This is the cursorPos that's directly applied to tgtSection, should be null if incoming link is outdated //This is the cursorPos that's directly applied to tgtSection, should be null if incoming link is outdated
//where null means "cursorPos does not apply to tgtSection and should be ignored" //where null means "cursorPos does not apply to tgtSection and should be ignored"
this.cursorPos = this.autoDispose(ko.computed(() => { this.cursorPos = this.autoDispose(ko.computed(() => {
const [incomingPos, _]: [UIRowId|null, SequenceNum] = this.incomingCursorPos(); return this.incomingCursorPos()[0]; //TODO JV: this is ugly and probably not needed
return incomingPos;
// TODO JV: old code only accepted incomingPos if it was newer than tgtSec. // TODO JV: old code only accepted incomingPos if it was newer than tgtSec.
// However I think we'll be ok with always taking incomingPos. I think the only weird case // However I think we'll be ok with always taking incomingPos. I think the only weird case