Skip to content

Commit

Permalink
Fix it so the value of a reference successfully is applied.
Browse files Browse the repository at this point in the history
Made it so mayNotSetReferencesReason requires a value... before we forgot to supply it from another
callsite.

Part of #682.
  • Loading branch information
jkomoros committed Dec 9, 2023
1 parent a86dcf4 commit 18ef9a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@ export const addReferenceToCard = (cardID : CardID, referenceType : ReferenceTyp
return;
}

if (!value) value = '';

const reason = referencesNonModifying(editingCard).mayNotSetCardReferenceReason(state, cardID, referenceType, value);

if (reason) {
Expand Down
4 changes: 2 additions & 2 deletions src/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ReferencesAccessor {

_mayNotApplyEntryDiffItemReason(state : State, item : ReferencesEntriesDiffItem) : string {
if (isExpandedReferenceDelete(item)) return this.mayNotRemoveCardReferenceReason(state, item.cardID, item.referenceType);
return this.mayNotSetCardReferenceReason(state, item.cardID, item.referenceType);
return this.mayNotSetCardReferenceReason(state, item.cardID, item.referenceType, item.value);
}

//Removes all references for the given card.
Expand Down Expand Up @@ -341,7 +341,7 @@ class ReferencesAccessor {

//Returns a string describing why that reference may not be set, or '' if
//it's legal.
mayNotSetCardReferenceReason(state : State, cardID : CardID, referenceType : ReferenceType, value? : string) : string {
mayNotSetCardReferenceReason(state : State, cardID : CardID, referenceType : ReferenceType, value : string) : string {

if (!value) value = '';

Expand Down

0 comments on commit 18ef9a9

Please sign in to comment.