File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ protocol ExtraApplicationActionable: ApplicationActionable {
1616
1717extension ExtraApplicationActionable {
1818
19- private var appPath : String ? {
19+ var appPath : String ? {
2020 return NSWorkspace . shared ( ) . absolutePathForApplication ( withBundleIdentifier: appBundleIdentifier)
2121 }
2222
Original file line number Diff line number Diff line change @@ -12,16 +12,33 @@ final class OpenRealmAction: ExtraApplicationActionable {
1212
1313 var application : Application ?
1414
15- let appBundleIdentifier = " io.realm.Realm-Browser "
15+ let appBundleIdentifier = " io.realm.realmbrowser "
1616
1717 let title = " Open Realm Database "
1818
19+ var isAvailable : Bool {
20+ return appPath != nil && realmPath != nil
21+ }
22+
23+ var realmPath : String ?
24+
1925 init ( application: Application ) {
2026 self . application = application
27+
28+ if let sandboxUrl = application. sandboxUrl,
29+ let enumerator = FileManager . default. enumerator ( at: sandboxUrl, includingPropertiesForKeys: nil ) {
30+ while let fileUrl = enumerator. nextObject ( ) as? URL {
31+ if fileUrl. pathExtension. lowercased ( ) == " realm " {
32+ realmPath = fileUrl. path
33+ }
34+ }
35+ }
2136 }
2237
2338 func perform( ) {
24-
39+ if let realmPath = realmPath {
40+ NSWorkspace . shared ( ) . openFile ( realmPath, withApplication: " Realm Browser " )
41+ }
2542 }
2643
2744}
You can’t perform that action at this time.
0 commit comments