move type check up to get one filter

pull/3685/head
David Sheldrick 2024-05-07 16:22:17 +01:00
rodzic 374882b9a6
commit 949d72aa6b
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -5056,14 +5056,18 @@ export class Editor extends EventEmitter<TLEventMap> {
type: Binding['type']
): Binding[] {
const id = typeof shape === 'string' ? shape : shape.id
return this.getBindingsInvolvingShape(id, type).filter((b) => b.fromId === id) as Binding[]
return this.getBindingsInvolvingShape(id).filter(
(b) => b.fromId === id && b.type === type
) as Binding[]
}
getBindingsToShape<Binding extends TLUnknownBinding = TLBinding>(
shape: TLShape | TLShapeId,
type: Binding['type']
): Binding[] {
const id = typeof shape === 'string' ? shape : shape.id
return this.getBindingsInvolvingShape(id, type).filter((b) => b.toId === id) as Binding[]
return this.getBindingsInvolvingShape(id).filter(
(b) => b.toId === id && b.type === type
) as Binding[]
}
getBindingsInvolvingShape<Binding extends TLUnknownBinding = TLBinding>(
shape: TLShape | TLShapeId,