Skip to content

Commit c23deea

Browse files
committed
Deal w/ array values in toDocument
Sometimes, or always :-), this is an array. Who knows. Probably a gstep-base porting bug, where KVC does a map on the project id, while it would have returned nil w/ lF.
1 parent e5d4b9c commit c23deea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Logic/LSDocuments/LSGetAttachmentNameCommand.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,20 @@ - (NSString *)_newAttachmentNameForObj:(id)_obj inContext:(id)_ctx {
125125
: (NSNumber *)[_obj valueForKey:@"projectId"];
126126

127127
if (![pid isNotNull]) {
128-
pid = [[_obj valueForKey:@"toDocument"] valueForKey:@"projectId"];
129-
128+
/* toDocument is to-many on Notes */
129+
id toDoc = [_obj valueForKey:@"toDocument"];
130+
if ([toDoc isKindOfClass:[NSArray class]]) {
131+
NSEnumerator *e = [toDoc objectEnumerator];
132+
id doc;
133+
while ((doc = [e nextObject]) != nil) {
134+
pid = [doc valueForKey:@"projectId"];
135+
if ([pid isNotNull]) break;
136+
pid = nil;
137+
}
138+
}
139+
else
140+
pid = [toDoc valueForKey:@"projectId"];
141+
130142
if (![pid isNotNull]) {
131143
pid = [self _getProjectIdForDocId:[_obj valueForKey:@"documentId"]
132144
inContext:_ctx];

0 commit comments

Comments
 (0)