Skip to content
Snippets Groups Projects
Commit aa03df49 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

history: fix history limit

Since history is now handled by LRC, set the history limit instead
of storing it client side.

There is a race condition in LRC, we need to make sure daemon is
started before creating the history, otherwise dring.yml is not
parsed when we ask what is the currently set historyLimit and returns
default value.

Change-Id: I433a37ab559721df82225a6fe2695525ed85fcd0
Tuleap: #103
parent 19a1230d
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,4 @@ namespace Preferences { ...@@ -31,6 +31,4 @@ namespace Preferences {
NSString * const WindowBehaviour = @"window_behaviour"; NSString * const WindowBehaviour = @"window_behaviour";
/* KVO compliant */ /* KVO compliant */
NSString * const Notifications = @"enable_notifications"; NSString * const Notifications = @"enable_notifications";
NSString * const ShowAdvanced = @"show_advanced";
} }
...@@ -28,30 +28,41 @@ ...@@ -28,30 +28,41 @@
@interface GeneralPrefsVC () @interface GeneralPrefsVC ()
@property (unsafe_unretained) IBOutlet NSTextField* historyChangedLabel; @property (unsafe_unretained) IBOutlet NSTextField* historyChangedLabel;
@property (unsafe_unretained) IBOutlet NSView *advancedGeneralSettings;
@property (unsafe_unretained) IBOutlet NSButton* startUpButton; @property (unsafe_unretained) IBOutlet NSButton* startUpButton;
@property (unsafe_unretained) IBOutlet NSButton* toggleAutomaticUpdateCheck; @property (unsafe_unretained) IBOutlet NSButton* toggleAutomaticUpdateCheck;
@property (unsafe_unretained) IBOutlet NSPopUpButton* checkIntervalPopUp; @property (unsafe_unretained) IBOutlet NSPopUpButton* checkIntervalPopUp;
@property (unsafe_unretained) IBOutlet NSView* sparkleContainer; @property (unsafe_unretained) IBOutlet NSView* sparkleContainer;
@property (unsafe_unretained) IBOutlet NSTextField* historyTextField;
@property (unsafe_unretained) IBOutlet NSStepper* historyStepper;
@property (unsafe_unretained) IBOutlet NSButton* historySwitch;
@end @end
@implementation GeneralPrefsVC @implementation GeneralPrefsVC
@synthesize historyChangedLabel; @synthesize historyChangedLabel;
@synthesize advancedGeneralSettings;
@synthesize startUpButton; @synthesize startUpButton;
@synthesize toggleAutomaticUpdateCheck; @synthesize toggleAutomaticUpdateCheck;
@synthesize checkIntervalPopUp; @synthesize checkIntervalPopUp;
@synthesize sparkleContainer; @synthesize sparkleContainer;
@synthesize historyTextField;
@synthesize historyStepper;
@synthesize historySwitch;
- (void)loadView - (void)loadView
{ {
[super loadView]; [super loadView];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::HistoryLimit options:NSKeyValueObservingOptionNew context:NULL]; [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::HistoryLimit options:NSKeyValueObservingOptionNew context:NULL];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::ShowAdvanced options:NSKeyValueObservingOptionNew context:NULL];
[startUpButton setState:[self isLaunchAtStartup]]; [startUpButton setState:[self isLaunchAtStartup]];
int historyLimit = CategorizedHistoryModel::instance().historyLimit();
[historyTextField setStringValue:[NSString stringWithFormat:@"%d", historyLimit]];
[historyStepper setIntValue:historyLimit];
BOOL limited = CategorizedHistoryModel::instance().isHistoryLimited();
[historySwitch setState:limited];
[historyStepper setEnabled:limited];
[historyTextField setEnabled:limited];
#if ENABLE_SPARKLE #if ENABLE_SPARKLE
[sparkleContainer setHidden:NO]; [sparkleContainer setHidden:NO];
SUUpdater *updater = [SUUpdater sharedUpdater]; SUUpdater *updater = [SUUpdater sharedUpdater];
...@@ -63,13 +74,11 @@ ...@@ -63,13 +74,11 @@
[sparkleContainer setHidden:YES]; [sparkleContainer setHidden:YES];
#endif #endif
//[advancedGeneralSettings setHidden:![[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced]];
} }
- (void) dealloc - (void) dealloc
{ {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:Preferences::HistoryLimit]; [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:Preferences::HistoryLimit];
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:Preferences::ShowAdvanced];
} }
- (IBAction)clearHistory:(id)sender { - (IBAction)clearHistory:(id)sender {
...@@ -77,14 +86,23 @@ ...@@ -77,14 +86,23 @@
[historyChangedLabel setHidden:NO]; [historyChangedLabel setHidden:NO];
} }
- (IBAction)toggleHistory:(id)sender {
CategorizedHistoryModel::instance().setHistoryLimited([sender state]);
int historyLimit = CategorizedHistoryModel::instance().historyLimit();
[historyTextField setStringValue:[NSString stringWithFormat:@"%d", historyLimit]];
[historyStepper setIntValue:historyLimit];
[historyChangedLabel setHidden:NO];
[historyStepper setEnabled:[sender state]];
[historyTextField setEnabled:[sender state]];
}
// KVO handler // KVO handler
-(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject -(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject
change:(NSDictionary *)aChange context:(void *)aContext change:(NSDictionary *)aChange context:(void *)aContext
{ {
if (aKeyPath == Preferences::HistoryLimit) { if ([aKeyPath isEqualToString:Preferences::HistoryLimit]) {
CategorizedHistoryModel::instance().setHistoryLimit([[aChange objectForKey: NSKeyValueChangeNewKey] integerValue]);
[historyChangedLabel setHidden:NO]; [historyChangedLabel setHidden:NO];
} else if (aKeyPath == Preferences::ShowAdvanced) {
//[advancedGeneralSettings setHidden:[[aChange objectForKey: NSKeyValueChangeNewKey] boolValue]];
} }
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#import <categorizedhistorymodel.h> #import <categorizedhistorymodel.h>
#import <localhistorycollection.h> #import <localhistorycollection.h>
#import <numbercategorymodel.h> #import <numbercategorymodel.h>
#import <callmodel.h>
#import "backends/AddressBookBackend.h" #import "backends/AddressBookBackend.h"
#import "delegates/ImageManipulationDelegate.h" #import "delegates/ImageManipulationDelegate.h"
...@@ -62,6 +63,7 @@ int main(int argc, const char *argv[]) { ...@@ -62,6 +63,7 @@ int main(int argc, const char *argv[]) {
} }
} }
CallModel::instance();
CategorizedHistoryModel::instance().addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED); CategorizedHistoryModel::instance().addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
/* make sure basic number categories exist, in case user has no contacts /* make sure basic number categories exist, in case user has no contacts
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="GeneralPrefsVC"> <customObject id="-2" userLabel="File's Owner" customClass="GeneralPrefsVC">
<connections> <connections>
<outlet property="checkIntervalPopUp" destination="RYP-3d-PCa" id="JNO-GR-CV8"/> <outlet property="checkIntervalPopUp" destination="RYP-3d-PCa" id="JNO-GR-CV8"/>
<outlet property="historyChangedLabel" destination="Gyi-ID-Z3v" id="aoO-Fh-UCQ"/> <outlet property="historyChangedLabel" destination="Gyi-ID-Z3v" id="aoO-Fh-UCQ"/>
<outlet property="historyStepper" destination="QmA-ZI-ZL5" id="dDV-1G-rZs"/>
<outlet property="historySwitch" destination="DgD-2y-4g5" id="GYk-pz-jGT"/>
<outlet property="historyTextField" destination="tHZ-7Q-5iP" id="keP-y2-7Pg"/>
<outlet property="sparkleContainer" destination="yVO-jk-ay3" id="zni-hI-88D"/> <outlet property="sparkleContainer" destination="yVO-jk-ay3" id="zni-hI-88D"/>
<outlet property="startUpButton" destination="1Nr-L4-fcd" id="veu-Hi-c7L"/> <outlet property="startUpButton" destination="1Nr-L4-fcd" id="veu-Hi-c7L"/>
<outlet property="toggleAutomaticUpdateCheck" destination="MCd-PD-kd7" id="rSB-ac-Nm2"/> <outlet property="toggleAutomaticUpdateCheck" destination="MCd-PD-kd7" id="rSB-ac-Nm2"/>
...@@ -68,6 +71,9 @@ ...@@ -68,6 +71,9 @@
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections>
<action selector="toggleHistory:" target="-2" id="TiP-Pw-MFu"/>
</connections>
</button> </button>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QmA-ZI-ZL5"> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QmA-ZI-ZL5">
<rect key="frame" x="251" y="141" width="19" height="27"/> <rect key="frame" x="251" y="141" width="19" height="27"/>
...@@ -87,7 +93,11 @@ ...@@ -87,7 +93,11 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
<binding destination="Sz0-vm-i3t" name="value" keyPath="values.history_limit" id="O2j-lT-MbR"/> <binding destination="Sz0-vm-i3t" name="value" keyPath="values.history_limit" id="4us-N3-vCf">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
</dictionary>
</binding>
</connections> </connections>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nah-Jm-ZYB"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nah-Jm-ZYB">
...@@ -111,14 +121,6 @@ ...@@ -111,14 +121,6 @@
<action selector="clearHistory:" target="-2" id="yN7-bB-7EY"/> <action selector="clearHistory:" target="-2" id="yN7-bB-7EY"/>
</connections> </connections>
</button> </button>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Gyi-ID-Z3v">
<rect key="frame" x="361" y="144" width="167" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="(Applied on application restart)" id="OTl-vx-S43">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j3T-5j-Fom"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j3T-5j-Fom">
<rect key="frame" x="38" y="303" width="94" height="17"/> <rect key="frame" x="38" y="303" width="94" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Interruptions" id="Rzy-Gh-3wQ"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Interruptions" id="Rzy-Gh-3wQ">
...@@ -192,9 +194,21 @@ ...@@ -192,9 +194,21 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Gyi-ID-Z3v">
<rect key="frame" x="310" y="148" width="169" height="14"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="165" id="wfZ-X2-WX8"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="(Applied on application restart)" id="OTl-vx-S43">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="Is4-pD-LOT" firstAttribute="leading" secondItem="lIm-zX-RIV" secondAttribute="trailing" constant="8" id="Apx-HB-LIX"/> <constraint firstItem="Is4-pD-LOT" firstAttribute="leading" secondItem="lIm-zX-RIV" secondAttribute="trailing" constant="8" id="Apx-HB-LIX"/>
<constraint firstItem="Gyi-ID-Z3v" firstAttribute="leading" secondItem="nah-Jm-ZYB" secondAttribute="trailing" constant="8" id="EYY-WC-fCM"/>
<constraint firstItem="Oth-up-2k2" firstAttribute="leading" secondItem="Is4-pD-LOT" secondAttribute="leading" id="Fdb-2p-ULe"/> <constraint firstItem="Oth-up-2k2" firstAttribute="leading" secondItem="Is4-pD-LOT" secondAttribute="leading" id="Fdb-2p-ULe"/>
<constraint firstItem="nah-Jm-ZYB" firstAttribute="leading" secondItem="QmA-ZI-ZL5" secondAttribute="trailing" constant="8" id="JJi-0O-nUi"/> <constraint firstItem="nah-Jm-ZYB" firstAttribute="leading" secondItem="QmA-ZI-ZL5" secondAttribute="trailing" constant="8" id="JJi-0O-nUi"/>
<constraint firstItem="QmA-ZI-ZL5" firstAttribute="leading" secondItem="tHZ-7Q-5iP" secondAttribute="trailing" constant="8" id="YPs-UE-IFi"/> <constraint firstItem="QmA-ZI-ZL5" firstAttribute="leading" secondItem="tHZ-7Q-5iP" secondAttribute="trailing" constant="8" id="YPs-UE-IFi"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment