aboutsummaryrefslogtreecommitdiff
path: root/QSThingsPlugin/Actions/ShowInThingsAction.m
blob: 91fe3ec3210f944d6e4c8a107e04bd10db5520b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#import "ShowInThingsAction.h"

NS_ASSUME_NONNULL_BEGIN

@implementation ShowInThingsAction

- (QSObject *)showObject:(QSObject *)directObject
{
  NSSet *validTypes = [NSSet setWithObjects:kAppSectionType, kTagType, kAreaType, kProjectType, kTaskType, nil];


  if ([validTypes containsObject:directObject.primaryType]) {
    NSDictionary *contents = [directObject objectForType:directObject.primaryType];
    if (contents) {
      NSString *uuid = [contents objectForKey:@"uuid"];
      if (uuid) {
        NSString *urlString = [NSString stringWithFormat:@"things:///show?id=%@", uuid];
        NSURL *url = [NSURL URLWithString:urlString];
                
        [[NSWorkspace sharedWorkspace] openURL:url];
      } else {
        NSLog(@"Things object did not have a uuid.");
      }
    } else {
      NSLog(@"Could not get the contents of the Things object.");
    }
  }
  return directObject;
}

@end

NS_ASSUME_NONNULL_END