Improve identification of preferred elements

Fixes #799
pull/237/head
Francis Lachapelle 2017-06-21 16:29:11 -04:00
parent 7f00afcef5
commit 9bde9b66ef
1 changed files with 11 additions and 1 deletions

View File

@ -458,12 +458,22 @@
elements = [self childrenWithTag: aTag];
if (elements && [elements count] > 0)
{
// First element of type "pref"
prefElements = [elements cardElementsWithAttribute: @"type"
havingValue: @"pref"];
if (prefElements && [prefElements count] > 0)
element = [prefElements objectAtIndex: 0];
else
element = [elements objectAtIndex: 0];
{
// First element of type "work"
prefElements = [elements cardElementsWithAttribute: @"type"
havingValue: @"work"];
if (prefElements && [prefElements count] > 0)
element = [prefElements objectAtIndex: 0];
else
// Fallback
element = [elements objectAtIndex: 0];
}
}
else
element = nil;