Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit f3b7642

Browse files
committed
Remove statusbar controller support. Remove Edit menu, Add ability to create new address from File menu.
1 parent 9cc1359 commit f3b7642

File tree

6 files changed

+38
-135
lines changed

6 files changed

+38
-135
lines changed

TempBox.xcodeproj/project.pbxproj

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
75640F2A27063C3700C7BCF6 /* MessagesListenerServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75640F2927063C3700C7BCF6 /* MessagesListenerServiceTests.swift */; };
2828
75640F2C27063CD000C7BCF6 /* FakeAccountService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75640F2B27063CD000C7BCF6 /* FakeAccountService.swift */; };
2929
75640F2F2706459D00C7BCF6 /* AccountsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75640F2E2706459D00C7BCF6 /* AccountsTests.swift */; };
30+
756E473E2712C1E000E8A439 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756E473D2712C1E000E8A439 /* AppDelegate.swift */; };
3031
75752EFD26F39C3D004EA6C1 /* AppController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75752EFC26F39C3D004EA6C1 /* AppController.swift */; };
3132
75752EFF26F3A2B1004EA6C1 /* AddAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75752EFE26F3A2B1004EA6C1 /* AddAccountView.swift */; };
3233
75752F0226F3A9BC004EA6C1 /* AddAccountWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75752F0126F3A9BC004EA6C1 /* AddAccountWindow.swift */; };
@@ -37,6 +38,7 @@
3738
757EA599270CD4FD004793CA /* FileDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757EA598270CD4FD004793CA /* FileDownloadManager.swift */; };
3839
757EA59B270CE724004793CA /* AttachmentDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757EA59A270CE724004793CA /* AttachmentDownloadManager.swift */; };
3940
758050542700DE0C00C71EA6 /* AppControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 758050532700DE0C00C71EA6 /* AppControllerTests.swift */; };
41+
758467852712C5E50087D9AD /* Notifications+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 758467842712C5E50087D9AD /* Notifications+Extensions.swift */; };
4042
7584F26526FF009300C972DA /* AccountServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7584F26426FF009300C972DA /* AccountServiceTests.swift */; };
4143
7584F26726FF01D600C972DA /* MockAccountRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7584F26626FF01D600C972DA /* MockAccountRepository.swift */; };
4244
7584F26926FF208200C972DA /* MockAccountService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7584F26826FF208200C972DA /* MockAccountService.swift */; };
@@ -68,7 +70,6 @@
6870
75C3205D26FBACB2009AAB26 /* AccountRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C3205C26FBACB2009AAB26 /* AccountRepositoryTests.swift */; };
6971
75DE87472702D8D0008C089B /* MessagesListenerService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DE87462702D8D0008C089B /* MessagesListenerService.swift */; };
7072
75DF252526F3D9D9003F69FE /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DF252426F3D9D9003F69FE /* WebView.swift */; };
71-
75DF252826F3DBDA003F69FE /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DF252726F3DBDA003F69FE /* StatusBarController.swift */; };
7273
75DFF7632700E77200EE4B7A /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DFF7622700E77200EE4B7A /* Logger+Extensions.swift */; };
7374
75E03952270635B200650675 /* FakeMTLiveMessagesService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E03951270635B200650675 /* FakeMTLiveMessagesService.swift */; };
7475
75ED42AC270B83AE002161D3 /* AttachmentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75ED42AB270B83AE002161D3 /* AttachmentsView.swift */; };
@@ -113,6 +114,7 @@
113114
75640F2927063C3700C7BCF6 /* MessagesListenerServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesListenerServiceTests.swift; sourceTree = "<group>"; };
114115
75640F2B27063CD000C7BCF6 /* FakeAccountService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeAccountService.swift; sourceTree = "<group>"; };
115116
75640F2E2706459D00C7BCF6 /* AccountsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTests.swift; sourceTree = "<group>"; };
117+
756E473D2712C1E000E8A439 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
116118
75752EFC26F39C3D004EA6C1 /* AppController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppController.swift; sourceTree = "<group>"; };
117119
75752EFE26F3A2B1004EA6C1 /* AddAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountView.swift; sourceTree = "<group>"; };
118120
75752F0126F3A9BC004EA6C1 /* AddAccountWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountWindow.swift; sourceTree = "<group>"; };
@@ -123,6 +125,7 @@
123125
757EA598270CD4FD004793CA /* FileDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileDownloadManager.swift; sourceTree = "<group>"; };
124126
757EA59A270CE724004793CA /* AttachmentDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentDownloadManager.swift; sourceTree = "<group>"; };
125127
758050532700DE0C00C71EA6 /* AppControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppControllerTests.swift; sourceTree = "<group>"; };
128+
758467842712C5E50087D9AD /* Notifications+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Notifications+Extensions.swift"; sourceTree = "<group>"; };
126129
7584F26426FF009300C972DA /* AccountServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountServiceTests.swift; sourceTree = "<group>"; };
127130
7584F26626FF01D600C972DA /* MockAccountRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAccountRepository.swift; sourceTree = "<group>"; };
128131
7584F26826FF208200C972DA /* MockAccountService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAccountService.swift; sourceTree = "<group>"; };
@@ -154,7 +157,6 @@
154157
75C3205C26FBACB2009AAB26 /* AccountRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountRepositoryTests.swift; sourceTree = "<group>"; };
155158
75DE87462702D8D0008C089B /* MessagesListenerService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesListenerService.swift; sourceTree = "<group>"; };
156159
75DF252426F3D9D9003F69FE /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
157-
75DF252726F3DBDA003F69FE /* StatusBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
158160
75DFF7622700E77200EE4B7A /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = "<group>"; };
159161
75E03951270635B200650675 /* FakeMTLiveMessagesService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeMTLiveMessagesService.swift; sourceTree = "<group>"; };
160162
75E039562706369200650675 /* MailTMSwift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MailTMSwift; path = ../../work/personal/ios/MailTMSwift; sourceTree = "<group>"; };
@@ -213,9 +215,10 @@
213215
7501771026F38A9E00A47F7D /* macOS */ = {
214216
isa = PBXGroup;
215217
children = (
218+
750176FF26F38A9D00A47F7D /* TempBoxApp.swift */,
219+
756E473D2712C1E000E8A439 /* AppDelegate.swift */,
216220
75752EFC26F39C3D004EA6C1 /* AppController.swift */,
217221
7501772B26F38E0B00A47F7D /* RootNavigationView.swift */,
218-
750176FF26F38A9D00A47F7D /* TempBoxApp.swift */,
219222
752D570D27121DFD0015D26D /* Defaults.swift */,
220223
75C3204E26FBA25D009AAB26 /* App+Injection.swift */,
221224
75A3C4CB2708BDCE004ED1AB /* Models */,
@@ -225,7 +228,6 @@
225228
7575A2AD26F4710700A90CFE /* Repositories */,
226229
75C3204726FBA0D4009AAB26 /* Services */,
227230
7501772626F38C3A00A47F7D /* Shared Views */,
228-
75DF252626F3DBCD003F69FE /* StatusBar */,
229231
75C3204826FBA0F3009AAB26 /* Supporting files */,
230232
);
231233
path = macOS;
@@ -376,6 +378,7 @@
376378
755EB00E26FC4B8200846114 /* NSManagedObjectContext+Extensions.swift */,
377379
75640F2727063A1B00C7BCF6 /* MTLiveMessagesService+Extensions.swift */,
378380
7535D98E2708663300D39FAB /* MTMessage+Extensions.swift */,
381+
758467842712C5E50087D9AD /* Notifications+Extensions.swift */,
379382
);
380383
path = Extensions;
381384
sourceTree = "<group>";
@@ -479,14 +482,6 @@
479482
path = Repositories;
480483
sourceTree = "<group>";
481484
};
482-
75DF252626F3DBCD003F69FE /* StatusBar */ = {
483-
isa = PBXGroup;
484-
children = (
485-
75DF252726F3DBDA003F69FE /* StatusBarController.swift */,
486-
);
487-
path = StatusBar;
488-
sourceTree = "<group>";
489-
};
490485
/* End PBXGroup section */
491486

492487
/* Begin PBXNativeTarget section */
@@ -620,6 +615,7 @@
620615
75C3205326FBA4E5009AAB26 /* MTAccount+Extensions.swift in Sources */,
621616
75C3204F26FBA25D009AAB26 /* App+Injection.swift in Sources */,
622617
758601722709D6710071BAB2 /* AccountInfoViewController.swift in Sources */,
618+
756E473E2712C1E000E8A439 /* AppDelegate.swift in Sources */,
623619
75C3204626FB9FDB009AAB26 /* Account+CoreDataProperties.swift in Sources */,
624620
75C3205526FBA842009AAB26 /* Persistence+Injection.swift in Sources */,
625621
757EA599270CD4FD004793CA /* FileDownloadManager.swift in Sources */,
@@ -630,7 +626,6 @@
630626
75752EFF26F3A2B1004EA6C1 /* AddAccountView.swift in Sources */,
631627
752D57072711C61C0015D26D /* MessageDetailViewController.swift in Sources */,
632628
7575A2B126F4713F00A90CFE /* AccountRepository.swift in Sources */,
633-
75DF252826F3DBDA003F69FE /* StatusBarController.swift in Sources */,
634629
75529A8126F3916B00588FEA /* InboxView.swift in Sources */,
635630
75DFF7632700E77200EE4B7A /* Logger+Extensions.swift in Sources */,
636631
7586016F2709A60D0071BAB2 /* AccountInfoView.swift in Sources */,
@@ -650,6 +645,7 @@
650645
75C3205126FBA281009AAB26 /* Services+Injection.swift in Sources */,
651646
75C3204526FB9FDB009AAB26 /* Account+CoreDataClass.swift in Sources */,
652647
75529A8326F3917700588FEA /* MessageDetailView.swift in Sources */,
648+
758467852712C5E50087D9AD /* Notifications+Extensions.swift in Sources */,
653649
75C3202626FB5AEE009AAB26 /* String+Extensions.swift in Sources */,
654650
7575A2B426F472C200A90CFE /* TempBox.xcdatamodeld in Sources */,
655651
75C3205726FBA89D009AAB26 /* Respositories+Injection.swift in Sources */,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Notifications+Extensions.swift
3+
// TempBox (macOS)
4+
//
5+
// Created by Waseem Akram on 10/10/21.
6+
//
7+
8+
import Foundation
9+
10+
extension Notification.Name {
11+
static let newAddress = Notification.Name("NewAddress")
12+
}

macOS/Features/AddAccount/AddAccountViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class AddAccountViewController: ObservableObject {
7272
})
7373
.assign(to: \.availableDomains, on: self)
7474
.store(in: &subscriptions)
75+
76+
NotificationCenter.default.publisher(for: .newAddress)
77+
.sink { [weak self] _ in
78+
guard let self = self else { return }
79+
self.isAddAccountWindowOpen = true
80+
}
81+
.store(in: &subscriptions)
7582
}
7683

7784
func openAddAccountWindow() {

macOS/Services/FileDownloadManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ final class FileDownloadManager: NSObject {
6464
FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).first!
6565
}
6666

67-
func schedule(with request: URLRequest, fileName: String, saveLocation: URL? = nil, afterDownload: ((FileDownloadTask) -> Void)? = nil) -> FileDownloadTask {
67+
func schedule(with request: URLRequest, fileName: String, saveLocation: URL? = nil,
68+
afterDownload: ((FileDownloadTask) -> Void)? = nil) -> FileDownloadTask {
6869
let downloadTask = session.downloadTask(with: request)
6970
let fileURL: URL
7071
if let saveLocation = saveLocation {

macOS/StatusBar/StatusBarController.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.

macOS/TempBoxApp.swift

Lines changed: 8 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,6 @@ import SwiftUI
99
import Combine
1010
import Resolver
1111
import Defaults
12-
import UserNotifications
13-
14-
final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
15-
16-
@Injected var persistenceManager: PersistenceManager
17-
18-
var popover = NSPopover.init()
19-
var statusBar: StatusBarController?
20-
21-
func applicationDidFinishLaunching(_ notification: Notification) {
22-
23-
// popover.contentSize = NSSize(width: 360, height: 360)
24-
// popover.contentViewController = NSHostingController(rootView:
25-
// VStack{
26-
// List {
27-
// Text("1")
28-
// Text("2")
29-
// }
30-
// .listStyle(SidebarListStyle())
31-
// })
32-
// statusBar = StatusBarController(popover)
33-
registerNotifications()
34-
35-
}
36-
37-
func registerNotifications() {
38-
UNUserNotificationCenter.current().requestAuthorization(
39-
options: [.alert, .sound, .badge]
40-
) { accepted, error in
41-
if let error = error {
42-
print(error)
43-
return
44-
}
45-
Defaults[.isNotificationsEnabled] = accepted
46-
if !accepted {
47-
print("Notification access denied.")
48-
}
49-
}
50-
UNUserNotificationCenter.current().delegate = self
51-
}
52-
53-
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
54-
true
55-
}
56-
57-
func applicationWillTerminate(_ notification: Notification) {
58-
persistenceManager.saveMainContext()
59-
}
60-
61-
func userNotificationCenter(_ center: UNUserNotificationCenter,
62-
willPresent notification: UNNotification,
63-
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
64-
65-
completionHandler([.banner, .list])
66-
}
67-
68-
func userNotificationCenter(_ center: UNUserNotificationCenter,
69-
didReceive response: UNNotificationResponse,
70-
withCompletionHandler completionHandler: @escaping () -> Void) {
71-
let categoryIdentifier = response.notification.request.content.categoryIdentifier
72-
if categoryIdentifier == "openFileFromLocation" {
73-
let userInfo = response.notification.request.content.userInfo
74-
75-
if let fileLocation = userInfo["location"] as? String, let fileUrl = URL(string: fileLocation) {
76-
if response.actionIdentifier == "Open" {
77-
NSWorkspace.shared.open(fileUrl)
78-
}
79-
}
80-
}
81-
completionHandler()
82-
}
83-
84-
}
8512

8613
@main
8714
struct TempBoxApp: App {
@@ -113,6 +40,14 @@ struct TempBoxApp: App {
11340
NSWorkspace.shared.open(URL(string: "https://mail.tm/en/contact/")!)
11441
}
11542
}
43+
44+
CommandGroup(replacing: .newItem) {
45+
Button("New Address") {
46+
NotificationCenter.default.post(name: .newAddress, object: nil)
47+
}
48+
.keyboardShortcut("n")
49+
50+
}
11651
}
11752

11853
}

0 commit comments

Comments
 (0)