Skip to content

Commit

Permalink
Automatically dismiss alerts when you start the application that thre…
Browse files Browse the repository at this point in the history
…w them.
  • Loading branch information
peterhajas committed May 10, 2011
1 parent 45c6850 commit 95032a5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions MNAlertManager.h
Expand Up @@ -87,6 +87,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-(void)reloadPreferences;
-(void)refreshAll;
-(void)removeAllPendingAlertsWithSender:(NSString *)sender;
-(void)removeAllPendingAlertsForBundleIdentifier:(NSString *)bundleID;
-(void)takeActionOnAlertWithData:(MNAlertData *)data;
-(void)clearPending;
-(void)alertShouldGoLaterTimerFired:(id)sender;
Expand Down
21 changes: 21 additions & 0 deletions MNAlertManager.m
Expand Up @@ -288,6 +288,27 @@ -(void)removeAllPendingAlertsWithSender:(NSString *)sender
[self refreshAll];
}

-(void)removeAllPendingAlertsForBundleIdentifier:(NSString *)bundleID
{
// Loop through all pending alerts, and remove
// all the ones that are from the bundle identifier
NSMutableArray *toRemove = [NSMutableArray array];

for (MNAlertData* dataObj in pendingAlerts)
{
if ([dataObj.bundleID isEqualToString:bundleID])
{
[dismissedAlerts addObject:dataObj];
[toRemove addObject:dataObj];
}
}

[pendingAlerts removeObjectsInArray:toRemove];

[self saveOut];
[self refreshAll];
}

-(void)refreshAll
{
[dashboard refresh];
Expand Down
20 changes: 19 additions & 1 deletion Tweak.xm
Expand Up @@ -544,7 +544,25 @@ PHACInterface *phacinterface;

%end

// ----------------------------
// ------------------------------
// Hook SBApplication to dismiss
// alerts automatically on launch
// ------------------------------

%hook SBApplication

-(void)launch
{
[manager removeAllPendingAlertsForBundleIdentifier:[self bundleIdentifier]];
}

-(void)activate
{
[manager removeAllPendingAlertsForBundleIdentifier:[self bundleIdentifier]];
}

%end

// Hook AutoFetchRequestPrivate
// for getting new mail
// ----------------------------
Expand Down

0 comments on commit 95032a5

Please sign in to comment.