Update as per feedback
authorSamuel Attard <samuel.r.attard@gmail.com>
Wed, 29 Mar 2017 04:01:14 +0000 (15:01 +1100)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 4 Apr 2017 20:51:38 +0000 (13:51 -0700)
atom/browser/ui/cocoa/atom_touch_bar.mm
lib/browser/api/touch-bar.js

index 4b60627..674f572 100644 (file)
@@ -115,8 +115,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 
 - (void)refreshTouchBarItem:(NSTouchBar*)touchBar
                          id:(NSTouchBarItemIdentifier)identifier
-                         withType:(std::string)item_type
-                         withSettings:(mate::PersistentDictionary)settings {
+                   withType:(std::string)item_type
+               withSettings:(mate::PersistentDictionary)settings {
   NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
   if (!item) return;
 
@@ -126,7 +126,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
     [self updateLabel:(NSCustomTouchBarItem*)item withSettings:settings];
   } else if (item_type == "colorpicker") {
     [self updateColorPicker:(NSColorPickerTouchBarItem*)item
-              withSettings:settings];
+               withSettings:settings];
   } else if (item_type == "slider") {
     [self updateSlider:(NSSliderTouchBarItem*)item withSettings:settings];
   } else if (item_type == "popover") {
@@ -171,11 +171,9 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 
   std::vector<std::string> popover_ids;
   if (settings.Get("_popover", &popover_ids)) {
-    for (size_t i = 0; i < popover_ids.size(); ++i) {
-      std::string popover_id = popover_ids[i];
+    for (auto& popover_id : popover_ids) {
       NSPopoverTouchBarItem* popoverItem = [touchBar itemForIdentifier:[self identifierFromID:popover_id type:"popover"]];
-      NSTouchBar* targetTouchBar = popoverItem.popoverTouchBar;
-      [self refreshTouchBarItem:targetTouchBar id:identifier withType:item_type withSettings:settings];
+      [self refreshTouchBarItem:popoverItem.popoverTouchBar id:identifier withType:item_type withSettings:settings];
     }
   }
   [self refreshTouchBarItem:touchBar id:identifier withType:item_type withSettings:settings];
index d0b7d54..1a9c323 100644 (file)
@@ -225,7 +225,7 @@ TouchBar.TouchBarPopover = class TouchBarPopover extends TouchBarItem {
     }
     this.child.ordereredItems.forEach((item) => {
       item._popover = item._popover || []
-      if (!item._popover.find(itemID => itemID === this.id)) item._popover.push(this.id)
+      if (!item._popover.includes(this.id)) item._popover.push(this.id)
     })
   }
 }