(
relationshipId: Id,
localTableId: Id,
remoteTableId: Id,
getRemoteRowId: Id | ((getCell: GetCell, localRowId: Id) => Id),
)
| 100 | ); |
| 101 | |
| 102 | const setRelationshipDefinition = ( |
| 103 | relationshipId: Id, |
| 104 | localTableId: Id, |
| 105 | remoteTableId: Id, |
| 106 | getRemoteRowId: Id | ((getCell: GetCell, localRowId: Id) => Id), |
| 107 | ): Relationships => { |
| 108 | mapSet(remoteTableIds, relationshipId, remoteTableId); |
| 109 | |
| 110 | setDefinitionAndListen( |
| 111 | relationshipId, |
| 112 | localTableId, |
| 113 | ( |
| 114 | change: () => void, |
| 115 | changedRemoteRowIds: IdMap<[Id | undefined, Id | undefined]>, |
| 116 | ) => { |
| 117 | const changedLocalRows: IdSet = setNew(); |
| 118 | const changedRemoteRows: IdSet = setNew(); |
| 119 | const changedLinkedRows: IdSet = setNew(); |
| 120 | const [localRows, remoteRows] = getRelationship( |
| 121 | relationshipId, |
| 122 | ) as Relationship; |
| 123 | |
| 124 | collForEach( |
| 125 | changedRemoteRowIds, |
| 126 | ([oldRemoteRowId, newRemoteRowId], localRowId) => { |
| 127 | if (!isUndefined(oldRemoteRowId)) { |
| 128 | setAdd(changedRemoteRows, oldRemoteRowId); |
| 129 | ifNotUndefined( |
| 130 | mapGet(remoteRows, oldRemoteRowId), |
| 131 | (oldRemoteRow) => { |
| 132 | collDel(oldRemoteRow, localRowId); |
| 133 | if (collIsEmpty(oldRemoteRow)) { |
| 134 | mapSet(remoteRows, oldRemoteRowId); |
| 135 | } |
| 136 | }, |
| 137 | ); |
| 138 | } |
| 139 | if (!isUndefined(newRemoteRowId)) { |
| 140 | setAdd(changedRemoteRows, newRemoteRowId); |
| 141 | if (!collHas(remoteRows, newRemoteRowId)) { |
| 142 | mapSet(remoteRows, newRemoteRowId, setNew()); |
| 143 | } |
| 144 | setAdd(mapGet(remoteRows, newRemoteRowId), localRowId); |
| 145 | } |
| 146 | setAdd(changedLocalRows, localRowId); |
| 147 | mapSet(localRows, localRowId, newRemoteRowId); |
| 148 | mapForEach( |
| 149 | mapGet(linkedRowIdsListeners, relationshipId), |
| 150 | (firstRowId) => { |
| 151 | if ( |
| 152 | collHas( |
| 153 | getLinkedRowIdsCache(relationshipId, firstRowId), |
| 154 | localRowId, |
| 155 | ) |
| 156 | ) { |
| 157 | setAdd(changedLinkedRows, firstRowId); |
| 158 | } |
| 159 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…