From 47fa714714ca520bbb512a6374464ab66565b341 Mon Sep 17 00:00:00 2001 From: Daniel Lundqvist Date: Sat, 27 Dec 2008 01:58:37 +0800 Subject: [PATCH] Properly handle deselection in file lists. --- PBWebChangesController.m | 20 +++++++++++++------- html/views/commit/commit.js | 6 +++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/PBWebChangesController.m b/PBWebChangesController.m index 7afc1b6..7de0f71 100644 --- a/PBWebChangesController.m +++ b/PBWebChangesController.m @@ -38,15 +38,20 @@ change:(NSDictionary *)change context:(void *)context { + NSArrayController *otherController; + otherController = object == unstagedFilesController ? cachedFilesController : unstagedFilesController; int count = [[object selectedObjects] count]; - if (count == 0) + if (count == 0) { + if([[otherController selectedObjects] count] == 0) { + selectedFile = nil; + selectedFileIsCached = NO; + [self refresh]; + } return; + } // TODO: Move this to commitcontroller - if (object == unstagedFilesController) - [cachedFilesController setSelectionIndexes:[NSIndexSet indexSet]]; - else - [unstagedFilesController setSelectionIndexes:[NSIndexSet indexSet]]; + [otherController setSelectionIndexes:[NSIndexSet indexSet]]; if (count > 1) { [self showMultiple: [object selectedObjects]]; @@ -66,12 +71,13 @@ - (void) refresh { - if (!finishedLoading || !selectedFile) + if (!finishedLoading) return; id script = [view windowScriptObject]; [script callWebScriptMethod:@"showFileChanges" - withArguments:[NSArray arrayWithObjects:selectedFile, [NSNumber numberWithBool:selectedFileIsCached], nil]]; + withArguments:[NSArray arrayWithObjects:selectedFile ?: (id)[NSNull null], + [NSNumber numberWithBool:selectedFileIsCached], nil]]; } - (void) stageHunk:(NSString *)hunk reverse:(BOOL)reverse diff --git a/html/views/commit/commit.js b/html/views/commit/commit.js index 99e8d47..bcae7f7 100644 --- a/html/views/commit/commit.js +++ b/html/views/commit/commit.js @@ -23,8 +23,12 @@ var setState = function(state) { } var showFileChanges = function(file, cached) { - if (!file) + if (!file) { + $("title").innerHTML = "No file selected"; + hideNotification(); + setState("No file selected"); return; + } hideNotification(); hideState();