Commit ec7999e1 authored by Carola Nitz's avatar Carola Nitz

Settings: Reindex all media when passcode is turned off again

closes $612
parent 007f39d7
......@@ -295,6 +295,10 @@ extension MediaLibraryService {
medialib.reload()
}
@objc func reindexAllMediaForSpotlight() {
media(ofType: .video).forEach { $0.updateCoreSpotlightEntry() }
media(ofType: .audio).forEach { $0.updateCoreSpotlightEntry() }
}
/// Returns number of *ALL* files(audio and video) present in the medialibrary database
func numberOfFiles() -> Int {
return (medialib.audioFiles()?.count ?? 0) + (medialib.videoFiles()?.count ?? 0)
......
......@@ -12,6 +12,10 @@
*****************************************************************************/
#import "IASKAppSettingsViewController.h"
@class MediaLibraryService;
@interface VLCSettingsController : IASKAppSettingsViewController
- (instancetype)initWithMediaLibraryService:(MediaLibraryService *)medialibraryService NS_DESIGNATED_INITIALIZER;
@end
......@@ -24,16 +24,18 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
{
VLCActionSheet *actionSheet;
VLCSettingsSpecifierManager *specifierManager;
MediaLibraryService *_medialibraryService;
}
@end
@implementation VLCSettingsController
- (instancetype)initWithStyle:(UITableViewStyle)style
- (instancetype)initWithMediaLibraryService:(MediaLibraryService *)medialibraryService
{
self = [super initWithStyle:style];
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
[self setupUI];
_medialibraryService = medialibraryService;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(settingDidChange:) name:kIASKAppSettingChanged object:nil];
}
......@@ -182,6 +184,8 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
if (error == nil) {
if (passcode != nil) {
[[CSSearchableIndex defaultSearchableIndex] deleteAllSearchableItemsWithCompletionHandler:nil];
} else {
[_medialibraryService reindexAllMediaForSpotlight];
}
//Set manually the value to enable/disable the UISwitch.
[self filterCellsWithAnimation:YES];
......
......@@ -48,12 +48,12 @@ class VLCTabBarCoordinator: NSObject {
}
private func setupViewControllers() {
let controllers = [
let controllers: [UIViewController] = [
VLCVideoViewController(services: services),
VLCAudioViewController(services: services),
VLCPlaylistViewController(services: services),
VLCServerListViewController(nibName: nil, bundle: nil),
VLCSettingsController()
VLCSettingsController(mediaLibraryService: services.medialibraryService)
]
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment