1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

️ Performance fixes

- Avoid preloading list of sites twice
- Avoid loading Valet info twice
- Preload list of sites if <= 10 sites linked + parked
- Added fallback for missing instructions
- Improved description
This commit is contained in:
2021-12-09 19:49:16 +01:00
parent 7feb13856d
commit eaf1423fb1
5 changed files with 36 additions and 20 deletions

View File

@ -771,7 +771,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 105;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = phpmon/Info.plist;
@ -780,7 +780,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = "4.1-beta4";
MARKETING_VERSION = "4.1-beta5";
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -796,7 +796,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 105;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = phpmon/Info.plist;
@ -805,7 +805,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = "4.1-beta4";
MARKETING_VERSION = "4.1-beta5";
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -36,6 +36,12 @@ class Valet {
Valet.Configuration.self,
from: try! String(contentsOf: file, encoding: .utf8).data(using: .utf8)!
)
if self.sites.count <= 10 {
// Preload the sites and their drivers
print("Fewer than or 11 sites found, preloading list of sites...")
self.reloadSites()
}
}
public func reloadSites() {

View File

@ -60,8 +60,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
installation.notifyAboutBrokenPhpFpm()
// Attempt to find out more info about Valet
let valet = Valet()
print("PHP Monitor has extracted the version number of Valet: \(valet.version)")
print("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version)")
print("PHP Monitor is ready to serve!")
// Schedule a request to fetch the PHP version every 60 seconds

View File

@ -71,7 +71,13 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
override func viewDidLoad() {
tableView.doubleAction = #selector(self.doubleClicked(sender:))
reloadSites()
if !Valet.shared.sites.isEmpty {
// Preloaded list
sites = Valet.shared.sites
searchedFor(text: lastSearchedFor)
} else {
reloadSites()
}
}
// MARK: - Async Operations
@ -308,21 +314,24 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
if editor.hasBinary() {
editor.openDirectory(file: selectedSite!.absolutePath!)
} else {
Alert.confirm(
onWindow: self.view.window!,
messageText: "editors.binary_missing.title"
.localized(
editor.pathToBinary
),
informativeText: editor.missingBinaryInstruction ?? "",
buttonTitle: "editors.alert.try_again".localized,
secondButtonTitle: "editors.alert.cancel".localized,
onFirstButtonPressed: {
self.openWithEditor(sender: sender)
}
)
presentAlertForMissingEditorBinary(editor, sender)
}
}
private func presentAlertForMissingEditorBinary(_ editor: Editor, _ sender: EditorMenuItem) {
Alert.confirm(
onWindow: self.view.window!,
messageText: "editors.binary_missing.title".localized(editor.pathToBinary),
informativeText:
editor.missingBinaryInstruction
?? "editors.binary_missing.desc".localized(editor.pathToBinary),
buttonTitle: "editors.alert.try_again".localized,
secondButtonTitle: "editors.alert.cancel".localized,
onFirstButtonPressed: {
self.openWithEditor(sender: sender)
}
)
}
// MARK: - Deinitialization

View File

@ -75,6 +75,7 @@
// EDITORS
"editors.binary_missing.title" = "`%@` missing";
"editors.binary_missing.desc" = "The associated binary (`%@`) is missing. Because of this, PHP Monitor cannot open the domains folder.";
"editors.alert.try_again" = "Try Again";
"editors.alert.cancel" = "Cancel";
@ -88,6 +89,7 @@ After this is done, PHP Monitor should be able to open the domains folder in
"PHP Monitor makes use of Visual Studio Codes helper binary, `code`, but it seems not to exist on your system.
You can fix this by selecting 'Install `code` command in PATH' in Visual Studio Codes command palette.
(Type `>code` to find it.)
After this is done, PHP Monitor should be able to open the domains folder in PhpStorm.";