[macos] open 'recovery' files on app launch

This commit is contained in:
maxkadushkin
2025-09-18 18:30:43 +03:00
parent a357d2f7a7
commit 4f6ceade4e
3 changed files with 30 additions and 0 deletions

View File

@ -143,6 +143,7 @@
addObserverFor(CEFEventNameCertificatePreview, @selector(onCEFCertificatePreview:));
addObserverFor(ASCEventNameChangedUITheme, @selector(onUIThemeChanged:));
addObserverFor(ASCEventNameChangedSystemTheme, @selector(onSystemThemeChanged:));
addObserverFor(ASCEventNameRecoveryFiles, @selector(onRecoveryFiles:));
if (_externalDelegate && [_externalDelegate respondsToSelector:@selector(onCommonViewDidLoad:)]) {
[_externalDelegate onCommonViewDidLoad:self];
@ -1900,6 +1901,28 @@
}
}
-(void)onRecoveryFiles:(NSNotification *)notification {
if (notification && notification.userInfo) {
NSDictionary * params = (NSDictionary *)notification.userInfo;
NSString * sfiles = params[@"files"];
NSError * err = nil;
NSArray * arrfiles = [NSJSONSerialization JSONObjectWithData:[sfiles dataUsingEncoding:NSUTF8StringEncoding]
options:0
error:&err];
for (NSDictionary * f in arrfiles) {
NSNotification * n = [NSNotification notificationWithName:CEFEventNameCreateTab
object:nil
userInfo:@{
@"action" : @(ASCTabActionOpenLocalRecoverFile),
@"active" : @(YES),
@"fileId" : f[@"id"],
@"path" : f[@"path"]
}];
[self onCEFCreateTab:n];
}
}
}
#pragma mark -
#pragma mark ASCTabsControl Delegate

View File

@ -826,6 +826,12 @@ public:
@"path" : json[@"path"]
}];
}
} else if (cmd.find(L"recovery:update") != std::wstring::npos) {
[[NSNotificationCenter defaultCenter] postNotificationName:ASCEventNameRecoveryFiles
object:nil
userInfo:@{
@"files":[NSString stringWithstdwstring:param]
}];
} else if (cmd.find(L"webapps:features") != std::wstring::npos) {
CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager];
CCefView * pCefView = appManager->GetViewById(senderId);

View File

@ -99,6 +99,7 @@ static NSString * const ASCEventNameMainWindowLoaded = @"UI_mainWindowLoa
static NSString * const ASCEventNameOpenAppLinks = @"UI_openAppLinks";
static NSString * const ASCEventNameChangedUITheme = @"UI_changedUITheme";
static NSString * const ASCEventNameChangedSystemTheme = @"UI_changedSystemTheme";
static NSString * const ASCEventNameRecoveryFiles = @"UI_recoveryFiles";
// CEF types
static NSString * const CEFOpenFileFilterImage = @"images";