Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit de50ced

Browse files
authored
Fixed adding extra servers in preferences/status view. (#6)
1 parent d321838 commit de50ced

4 files changed

Lines changed: 30 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# xcode-github Change Log
22

3-
## v1.1.1 - February 6, 2019
4-
* Fixed a bug where the PR branch was not checked out: Instead the template bot branch was used.
3+
## v1.1.1 - ???
4+
* Adding another server in the preferences wasn't always persisted.
5+
* If an Xcode server had no bots defined then no items appeared in the status window. Now items are always shown.
6+
* The wrong git branch was used when a new PR bot was created from the template bot.
57

68
## v1.1.0 - January 29, 2019
79
* Fixed Xcode server login.

xcode-github-app.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
/* Begin PBXFileReference section */
5555
2BB6F4D221F9E3FF001E8693 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = Base; path = Base.lproj/Credits.rtf; sourceTree = "<group>"; };
5656
2BC31A1222041978003B0EE4 /* xcode-github-cli.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = "xcode-github-cli.md"; path = "Documentation/xcode-github-cli.md"; sourceTree = "<group>"; };
57+
2BFD78962216A06E00E63692 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
5758
4D0DD54420597FE6001721C1 /* xcode-github-app.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = "xcode-github-app.md"; path = "Documentation/xcode-github-app.md"; sourceTree = "<group>"; };
5859
4D12BA0A20A252CE00E5B1DB /* XGALogViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XGALogViewController.h; sourceTree = "<group>"; };
5960
4D12BA0B20A252CE00E5B1DB /* XGALogViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XGALogViewController.m; sourceTree = "<group>"; };
@@ -114,6 +115,7 @@
114115
4D76615F2057565200216B72 = {
115116
isa = PBXGroup;
116117
children = (
118+
2BFD78962216A06E00E63692 /* CHANGELOG.md */,
117119
4D0DD54420597FE6001721C1 /* xcode-github-app.md */,
118120
2BC31A1222041978003B0EE4 /* xcode-github-cli.md */,
119121
4DC9E5C4216DCD6700F1F4EE /* XcodeGitHub.xcodeproj */,

xcode-github-app/XGAPreferencesViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ - (IBAction)addServerAction:(id)sender {
6666
- (IBAction)serverDoubleAction:(id)sender {
6767
NSInteger idx = self.tableView.selectedRow;
6868
if (idx >= 0 && idx < [self.serverDictionaryController.arrangedObjects count]) {
69-
XGAServer*server = [self.serverDictionaryController.arrangedObjects objectAtIndex:idx];
69+
NSDictionaryControllerKeyValuePair*pair =
70+
[self.serverDictionaryController.arrangedObjects objectAtIndex:idx];
71+
XGAServer*server = pair.value;
7072
[self showServer:server];
7173
}
7274
}
@@ -79,6 +81,8 @@ - (void) showServer:(XGAServer*)server {
7981
if (returnCode == NSModalResponseOK &&
8082
result.server.length &&
8183
self.settings.servers[result.server] == nil) {
84+
self.settings.servers[result.server] = result;
85+
[self.settings save];
8286
NSDictionaryControllerKeyValuePair*pair = [self.serverDictionaryController newObject];
8387
pair.key = result.server;
8488
pair.value = result;

xcode-github-app/XGAStatusViewController.m

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -386,26 +386,30 @@ - (void) updateStatus {
386386

387387
BNCLogDebug(@"Start updateStatus.");
388388
BNCPerformBlockOnMainThreadAsync(^{ self.statusTextField.stringValue = @""; });
389-
/*
390-
NSMutableDictionary<NSString*, XGServer*>*statusServers = [NSMutableDictionary new];
391-
for (XGAServer*server in XGASettings.shared.servers.objectEnumerator) {
392-
if (server.server.length > 0)
393-
statusServers[server.server] = server;
394-
}
395-
*/
389+
390+
// Create new bots as needed:
396391
NSArray<XGAGitHubSyncTask*>* syncTasks = XGASettings.shared.gitHubSyncTasks;
397392
NSDictionary<NSString*, XGServer*>*statusServers = XGASettings.shared.servers;
398393
for (XGAGitHubSyncTask*task in syncTasks) {
399394
if (task.xcodeServer.length != 0 && statusServers[task.xcodeServer] != nil)
400395
[self updateSyncBots:task];
401396
}
397+
398+
// Update the status:
399+
NSMutableArray *statusArray = [NSMutableArray new];
402400
for (XGAServer*server in statusServers.objectEnumerator) {
403-
[self updateXcodeServerStatus:server];
401+
NSArray*a = [self updateXcodeServerStatus:server];
402+
if (a) [statusArray addObjectsFromArray:a];
404403
}
405-
if (syncTasks.count == 0 && statusServers.count == 0) {
406-
// Update with 'nil' to add content for an empty display:
407-
[self updateXcodeServerStatus:nil];
404+
if (statusArray.count == 0) {
405+
XGAStatusViewItem *status = [XGAStatusViewItem new];
406+
status.statusImage = [NSImage imageNamed:@"RoundBlue"];
407+
status.statusSummary = [APFormattedString boldText:@"< No Xcode servers added yet >"];
408+
[statusArray addObject:status];
408409
}
410+
BNCPerformBlockOnMainThreadAsync(^{
411+
self.arrayController.content = statusArray;
412+
});
409413
BNCLogDebug(@"End updateStatus.");
410414

411415
self.lastUpdateDate = [NSDate date];
@@ -446,7 +450,7 @@ - (void) updateSyncBots:(XGAGitHubSyncTask*)syncTask {
446450
}
447451
}
448452

449-
- (void) updateXcodeServerStatus:(XGServer*)server {
453+
- (NSArray*) updateXcodeServerStatus:(XGServer*)server {
450454
NSError*error = nil;
451455
NSMutableArray *statusArray = [NSMutableArray new];
452456
if (server.server.length > 0) {
@@ -468,17 +472,12 @@ - (void) updateXcodeServerStatus:(XGServer*)server {
468472
}
469473
if (statusArray.count == 0) {
470474
XGAStatusViewItem *status = [XGAStatusViewItem new];
475+
status.server = server.server;
471476
status.statusImage = [NSImage imageNamed:@"RoundBlue"];
472-
if (server.server.length > 0) {
473-
status.statusSummary = [APFormattedString boldText:@"< No Xcode bots found >"];
474-
} else {
475-
status.statusSummary = [APFormattedString boldText:@"< No Xcode servers added yet >"];
476-
}
477+
status.statusSummary = [APFormattedString boldText:@"< No Xcode bots found >"];
477478
[statusArray addObject:status];
478479
}
479-
BNCPerformBlockOnMainThreadAsync(^{
480-
self.arrayController.content = statusArray;
481-
});
480+
return statusArray;
482481
}
483482

484483
@end

0 commit comments

Comments
 (0)