Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update folder data even when the feed has no articles #1814

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Vienna/Interfaces/Base.lproj/InfoWindow.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -31,7 +31,7 @@
<windowCollectionBehavior key="collectionBehavior" moveToActiveSpace="YES" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="120" y="530" width="270" height="388"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1025"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<view key="contentView" id="6">
<rect key="frame" x="0.0" y="0.0" width="270" height="388"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -61,15 +61,15 @@
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="150" translatesAutoresizingMaskIntoConstraints="NO" id="33">
<rect key="frame" x="46" y="346" width="87" height="14"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Last Refreshed:" id="105">
<rect key="frame" x="46" y="346" width="78" height="14"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Last Updated:" id="105">
<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 focusRingType="none" verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="34">
<rect key="frame" x="134" y="346" width="123" height="14"/>
<rect key="frame" x="125" y="346" width="132" height="14"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" id="106">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
Expand Down
44 changes: 22 additions & 22 deletions Vienna/Interfaces/mul.lproj/InfoWindow.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2,132 +2,132 @@
"sourceLanguage" : "en",
"strings" : {
"105.title" : {
"comment" : "Class = \"NSTextFieldCell\"; title = \"Last Refreshed:\"; ObjectID = \"105\";",
"comment" : "Class = \"NSTextFieldCell\"; title = \"Last Updated:\"; ObjectID = \"105\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Obnoveno:"
}
},
"da" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Sidst opdateret:"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Letzte Aktualisierung:"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Last Refreshed:"
"value" : "Last Updated:"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Última actualización:"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Azken Eguneratuak:"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Dernière actualisation :"
}
},
"gl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Última actualización:"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Ultimo Aggiornamento:"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "最後の更新:"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "최종 갱신일:"
}
},
"lt" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Paskutinį kartą atnaujinta:"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Laatste keer vernieuwd:"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Última atualização:"
}
},
"pt-PT" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Última actualização:"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Последние обновленные:"
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Senaste uppdaterad:"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "En son yenilendi:"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Останнє оновлення:"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "上次更新:"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "上次重新整理:"
}
}
Expand Down
74 changes: 34 additions & 40 deletions Vienna/Sources/Fetching/RefreshManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,6 @@ -(void)folderRefreshCompleted:(NSMutableURLRequest *)connector response:(NSURLRe

if (responseStatusCode == 304) {
// No modification from last check

[dbManager setLastUpdate:[NSDate date] forFolder:folderId];

[self setFolderErrorFlag:folder flag:NO];
[connectorItem appendDetail:NSLocalizedString(@"Got HTTP status 304 - No news from last check", nil)];
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down Expand Up @@ -729,14 +726,6 @@ -(void)finalizeFolderRefresh:(NSDictionary *)parameters
@"Number of bytes received, e.g. 1 MB received"),
byteCount]];

if (newFeed.items.count == 0) {
// Mark the feed as empty
dispatch_async(dispatch_get_main_queue(), ^{
[connectorItem setStatus:NSLocalizedString(@"No articles in feed", nil)];
});
return;
}

// Extract the latest title and description
NSString * feedTitle = newFeed.title;
NSString * feedDescription = newFeed.feedDescription;
Expand All @@ -750,6 +739,38 @@ -(void)finalizeFolderRefresh:(NSDictionary *)parameters
feedLink = [NSURL URLWithString:feedLink relativeToURL:url].absoluteString;
}

if (feedTitle != nil && !feedTitle.vna_isBlank && [folder.name hasPrefix:[Database untitledFeedFolderName]]) {
// If there's an existing feed with this title, make ours unique
// BUGBUG: This duplicates logic in database.m so consider moving it there.
NSString * oldFeedTitle = feedTitle;
NSString * newFeedTitle = feedTitle;
NSUInteger index = 1;

while (([dbManager folderFromName:newFeedTitle]) != nil) {
newFeedTitle = [NSString stringWithFormat:@"%@ (%lu)", oldFeedTitle, (unsigned long)index++];
}

connectorItem.name = newFeedTitle;
[dbManager setName:newFeedTitle forFolder:folderId];
}
if (feedDescription != nil) {
[dbManager setDescription:feedDescription forFolder:folderId];
}
if (feedLink != nil) {
[dbManager setHomePage:feedLink forFolder:folderId];
}
// Remember the last modified date
if (lastModifiedString != nil && lastModifiedString.length > 0) {
[dbManager setLastUpdateString:lastModifiedString forFolder:folderId];
}

if (newFeed.items.count == 0) {
// Mark the feed as empty
dispatch_async(dispatch_get_main_queue(), ^{
[connectorItem setStatus:NSLocalizedString(@"No articles in feed", nil)];
});
return;
}

// We'll be collecting articles into this array
NSMutableArray *articleArray = [NSMutableArray array];
Expand Down Expand Up @@ -865,36 +886,9 @@ -(void)finalizeFolderRefresh:(NSDictionary *)parameters
}
}


// A notify is only needed if we added any new articles.
if (feedTitle != nil && !feedTitle.vna_isBlank && [folder.name hasPrefix:[Database untitledFeedFolderName]]) {
// If there's an existing feed with this title, make ours unique
// BUGBUG: This duplicates logic in database.m so consider moving it there.
NSString * oldFeedTitle = feedTitle;
NSString * newFeedTitle = feedTitle;
NSUInteger index = 1;

while (([dbManager folderFromName:newFeedTitle]) != nil) {
newFeedTitle = [NSString stringWithFormat:@"%@ (%lu)", oldFeedTitle, (unsigned long)index++];
}

connectorItem.name = newFeedTitle;
[dbManager setName:newFeedTitle forFolder:folderId];
}
if (feedDescription != nil) {
[dbManager setDescription:feedDescription forFolder:folderId];
}
if (feedLink != nil) {
[dbManager setHomePage:feedLink forFolder:folderId];
}

// Remember the last modified date
if (lastModifiedString != nil && lastModifiedString.length > 0) {
[dbManager setLastUpdateString:lastModifiedString forFolder:folderId];
if (newArticlesFromFeed > 0u) {
[dbManager setLastUpdate:[NSDate date] forFolder:folderId];
}
// Set the last update date for this folder.
[dbManager setLastUpdate:[NSDate date] forFolder:folderId];


// Mark the feed as succeeded
[self setFolderErrorFlag:folder flag:NO];
Expand Down