New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-26655] fix(ios): fix application shortcuts parity #10539
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some notes about the mutating enumerations and param naming. cc @vijaysingh-axway
[shortcuts removeObject:item]; | ||
[shortcuts enumerateObjectsUsingBlock:^(UIApplicationShortcutItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
if ([obj.type isEqualToString:key]) { | ||
[shortcuts removeObject:obj]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good idea to mutate an array while enumerating it. Consider storing the indices that need to be removed in a NSMutableIndexSet
and then remove them using removeObjectsAtIndexes
. I know it was already wrong in the first place but since you are touching it here anyway let's make it right ;)
Also any particular reason you switched to enumerating using block instead of for (... in ...)
. I don't see any benefit but instead it makes it more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, you're right with the mutation, I oversaw that! Regarding the enumerateObjectsUsingBlock
: It's the faster and more ObjC'ish way of iterating. Some inspiring words can be found here.
[shortcuts removeObject:item]; | ||
[shortcuts enumerateObjectsUsingBlock:^(UIApplicationShortcutItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
if ([obj.type isEqualToString:key]) { | ||
[shortcuts removeObject:obj]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, do not mutate the array while enumerating it.
[args objectForKey:@"identifier"]); | ||
return; | ||
} | ||
|
||
UIApplicationShortcutItem *shortcut = [[[UIApplicationShortcutItem alloc] initWithType:[args objectForKey:@"identifier"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to rename this to itemtype
too? Not sure why it's named identifier
here and itemtype
in the other place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDK 7.5.0 renamed it to identifier
for the new API on the Ti.UI namespace which uses identifier
for better parity with Android. I don't exactly remember why the old one wasn't just used here as well.
@hansemannn please fix the linting errors too, thanks! |
@janvennemann PR updated. EDIT: Linting still fails, but |
@hansemannn
I think we should use ‘identifier’ (unique string to identify the shortcut) and ‘itemtype’ (app-defined type). Backward compatibility is also we have to take care . |
@vijaysingh-axway Going back to this one, can you provide an example on how that API ( |
I found a better way around it by actually making the identifiers unique. By using a prefix like Still, I would keep the doc-changes as those have been a regression in 7.5+. |
@mukherjee2 @vijaysingh-axway Can this please be integrated into 8.0.0? We're patching the SDK with this change since 7.4.1 and it's getting messy to update to newer SDK's without this being included. Regarding the sensibility of this change: The fix is isolated to one SDK component and does not influence others. Also, it's more of a objc language-specific change than a change to the native layer or proxy. It is always reproducible and can easily be tested. If you need more test plans, we can provide those asap. Thank you. One note regarding the removal of the EDIT: Also added a backport in #10631 in case this receives traction. |
c0f2a53
to
e524216
Compare
7658e15
to
a6d5568
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR passed.
FR Passed. Studio Ver: 5.1.2.201812191831 |
JIRA: https://jira.appcelerator.org/browse/TIMOB-26655