Using correct plugn repository using fake plugin count

This commit is contained in:
Michael Starke
2018-10-24 17:06:24 +02:00
parent 3cd8d07552
commit 5912f613cb
4 changed files with 23 additions and 19 deletions

View File

@@ -51,6 +51,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com.
self = [super init]; self = [super init];
if(self) { if(self) {
_isInitialized = NO; _isInitialized = NO;
_lastDataFetchTime = NSDate.distantPast.timeIntervalSinceReferenceDate;
[self fetchRepositoryDataCompletionHandler:^(NSArray<MPPluginRepositoryItem *> * _Nonnull availablePlugins) { [self fetchRepositoryDataCompletionHandler:^(NSArray<MPPluginRepositoryItem *> * _Nonnull availablePlugins) {
self.availablePlugins = availablePlugins; self.availablePlugins = availablePlugins;
self.isInitialized = YES; self.isInitialized = YES;

View File

@@ -47,12 +47,12 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
} }
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return self.repositoryItems.count > 0 ? 100 : 0; return self.repositoryItems.count;
} }
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *view = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; NSTableCellView *view = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
MPPluginRepositoryItem *item = self.repositoryItems.firstObject; MPPluginRepositoryItem *item = self.repositoryItems[row];
NSUInteger column = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn]; NSUInteger column = [tableView.tableColumns indexOfObjectIdenticalTo:tableColumn];
@@ -64,8 +64,8 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
} }
else if(column == MPPluginTableColumnStatus) { else if(column == MPPluginTableColumnStatus) {
MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier]; MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier];
if(!plugin) { if(plugin) {
switch([plugin.shortVersionString compare:item.currentVersion]) { switch([MPPluginVersionComparator compareVersion:plugin.shortVersionString toVersion:item.currentVersion]) {
case NSOrderedSame: case NSOrderedSame:
view.textField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"PLUGIN_BROWSER_LATEST_VERSION_INSTALLED", "Status for an up-to-date plugin in the plugin browser")]; view.textField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"PLUGIN_BROWSER_LATEST_VERSION_INSTALLED", "Status for an up-to-date plugin in the plugin browser")];
break; break;

View File

@@ -5,12 +5,16 @@
// Created by Michael Starke on 05.10.18. // Created by Michael Starke on 05.10.18.
// Copyright © 2018 HicknHack Software GmbH. All rights reserved. // Copyright © 2018 HicknHack Software GmbH. All rights reserved.
// //
// Code is based upon SUStandardVersionComparator.h from Sparkle
// Changes include:
// * wildcard matching
// * correct handling of trailing parts (e.g. 3. == 3.0 == 3.0.0)
//
#import "MPPluginVersionComparator.h" #import "MPPluginVersionComparator.h"
@implementation MPPluginVersionComparator @implementation MPPluginVersionComparator
+ (MPVersionCharacterType)typeOfCharacter:(NSString *)character { + (MPVersionCharacterType)typeOfCharacter:(NSString *)character {
if([character isEqualToString:@"."]) { if([character isEqualToString:@"."]) {
return kMPVersionCharacterTypeSeparator; return kMPVersionCharacterTypeSeparator;
@@ -114,7 +118,7 @@
longerResult = NSOrderedAscending; longerResult = NSOrderedAscending;
} }
/* check if wildcard was last part, then the rest does not matter */ /* check if wildcard was last part of shorter version, then the rest does not matter */
if(lastShortType == kMPVersionCharacterTypeWildcard) { if(lastShortType == kMPVersionCharacterTypeWildcard) {
return NSOrderedSame; return NSOrderedSame;
} }
@@ -131,13 +135,12 @@
return longerResult; return longerResult;
} }
} }
// versions are considered the same as long as 0, separators or wildcards follow /* Any separator or widlcard that is in the longer version is skippes since we do not have to match components anymore */
} }
} }
return NSOrderedSame; return NSOrderedSame;
} }
+ (NSArray<NSString *> *)splitVersionString:(NSString *)versionString { + (NSArray<NSString *> *)splitVersionString:(NSString *)versionString {
if(versionString.length == 0) { if(versionString.length == 0) {
return @[]; return @[];

View File

@@ -25,7 +25,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="sequential" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="systemDefault" headerView="uVe-04-Now" viewBased="YES" id="gDR-Fx-c0h"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="sequential" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="systemDefault" headerView="uVe-04-Now" viewBased="YES" id="gDR-Fx-c0h">
<rect key="frame" x="0.0" y="0.0" width="596" height="408"/> <rect key="frame" x="0.0" y="0.0" width="599" height="408"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -64,8 +64,8 @@
</tableCellView> </tableCellView>
</prototypeCellViews> </prototypeCellViews>
</tableColumn> </tableColumn>
<tableColumn width="64" minWidth="10" maxWidth="3.4028234663852886e+38" id="hFg-AD-SqD"> <tableColumn width="88" minWidth="10" maxWidth="3.4028234663852886e+38" id="hFg-AD-SqD">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Installed Version"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Latest Version">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -78,11 +78,11 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews> <prototypeCellViews>
<tableCellView id="AKl-7g-maS"> <tableCellView id="AKl-7g-maS">
<rect key="frame" x="149" y="1" width="64" height="17"/> <rect key="frame" x="149" y="1" width="88" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gZz-x5-KVH"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gZz-x5-KVH">
<rect key="frame" x="0.0" y="0.0" width="64" height="17"/> <rect key="frame" x="0.0" y="0.0" width="88" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="nc9-mo-2e5"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="nc9-mo-2e5">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@@ -97,7 +97,7 @@
</tableCellView> </tableCellView>
</prototypeCellViews> </prototypeCellViews>
</tableColumn> </tableColumn>
<tableColumn width="378" minWidth="10" maxWidth="3.4028234663852886e+38" id="g1Q-BS-vCR"> <tableColumn width="357" minWidth="10" maxWidth="3.4028234663852886e+38" id="g1Q-BS-vCR">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Status"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Status">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -111,11 +111,11 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews> <prototypeCellViews>
<tableCellView id="RMm-PO-UNp"> <tableCellView id="RMm-PO-UNp">
<rect key="frame" x="216" y="1" width="378" height="17"/> <rect key="frame" x="240" y="1" width="357" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RBa-0B-xVt"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RBa-0B-xVt">
<rect key="frame" x="0.0" y="0.0" width="378" height="17"/> <rect key="frame" x="0.0" y="0.0" width="357" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="ZIf-CU-gh7"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="ZIf-CU-gh7">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@@ -141,8 +141,8 @@
<constraints> <constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="400" id="gYM-eK-y5v"/> <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="400" id="gYM-eK-y5v"/>
</constraints> </constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="ajb-Vb-WhY"> <scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="ajb-Vb-WhY">
<rect key="frame" x="1" y="415" width="398" height="16"/> <rect key="frame" x="1" y="415" width="596" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="3eJ-oK-GNt"> <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="3eJ-oK-GNt">
@@ -150,7 +150,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<tableHeaderView key="headerView" id="uVe-04-Now"> <tableHeaderView key="headerView" id="uVe-04-Now">
<rect key="frame" x="0.0" y="0.0" width="596" height="23"/> <rect key="frame" x="0.0" y="0.0" width="599" height="23"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</tableHeaderView> </tableHeaderView>
</scrollView> </scrollView>