mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-05 03:37:41 +00:00
Merged main to branch.
This commit is contained in:
commit
5e39b569a7
340 files changed
+22510
-2624
No files matched your search
@@ -3,8 +3,24 @@
|
||||
"allow": [
|
||||
"Bash(find:*)",
|
||||
"Bash(grep:*)",
|
||||
"Bash(ls:*)"
|
||||
"Bash(ls:*)",
|
||||
"Bash(./buildscripts/quiet_build_and_test.sh:*)",
|
||||
"WebSearch",
|
||||
"WebFetch(domain:github.com)",
|
||||
"Bash(gh issue view:*)",
|
||||
"Bash(xcodebuild:*)",
|
||||
"Bash(swift test:*)",
|
||||
"WebFetch(domain:swiftlang.github.io)",
|
||||
"Bash(git log:*)",
|
||||
"Bash(gh pr list:*)",
|
||||
"Bash(gh issue list:*)",
|
||||
"Bash(xcbeautify:*)",
|
||||
"Bash(swift build:*)",
|
||||
"Bash(1)",
|
||||
"Bash(sed:*)",
|
||||
"Bash(cat:*)",
|
||||
"Bash(dd:*)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable → Regular
+18
-145
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
|
||||
<channel>
|
||||
<title>NetNewsWire Betas</title>
|
||||
<link>https://ranchero.com/downloads/netnewswire-beta.xml</link>
|
||||
@@ -7,158 +7,31 @@
|
||||
<language>en</language>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.1.10b3</title>
|
||||
<description><![CDATA[
|
||||
<ul>
|
||||
<li>Fixed bug, introduced in previous test build, that prevented choosing an OPML file to import</li>
|
||||
</ul>
|
||||
<title>NetNewsWire 6.2b4</title>
|
||||
<description><![CDATA[
|
||||
<p>Changes since 6.2b3:</p>
|
||||
<ul>
|
||||
<li>Changed Markdown behavior — it now prefers source:markdown, when present, over description and content:encoded, and renders the Markdown as HTML and uses it as the article body</li>
|
||||
<li>Added a dotted underline to links in the Sepia theme, to make links more visible</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Tue, 12 Aug 2025 10:10:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.10b3/NetNewsWire6.1.10b3.zip" sparkle:version="6138" sparkle:shortVersionString="6.1.10b3" length="9383040" type="application/zip" />
|
||||
<pubDate>Thu, 30 Oct 2025 14:15:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.2b4/NetNewsWire6.2b4.zip" sparkle:version="6145" sparkle:shortVersionString="6.2b4" length="10242407" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.1.10b2</title>
|
||||
<description><![CDATA[
|
||||
<ul>
|
||||
<li>Fixed bug, introduced in previous test build, that prevented adding a Feedly account</li>
|
||||
</ul>
|
||||
<title>NetNewsWire 6.2b3</title>
|
||||
<description><![CDATA[
|
||||
<p>Changes since 6.2b2:</p>
|
||||
<ul>
|
||||
<li>Added support for source:markdown to the RSS parser</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Tue, 13 May 2025 09:00:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.10b2/NetNewsWire6.1.10b2.zip" sparkle:version="6137" sparkle:shortVersionString="6.1.10b2" length="9382872" type="application/zip" />
|
||||
<pubDate>Wed, 29 Oct 2025 21:25:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.2b3/NetNewsWire6.2b3.zip" sparkle:version="6144" sparkle:shortVersionString="6.2b3" length="10242202" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.1.10b1</title>
|
||||
<description><![CDATA[
|
||||
<ul>
|
||||
<li>Added caching to the downloader (the one that downloads feed icons, favicons, etc.) — make fewer network requests</li>
|
||||
<li>Worked around The Verge’s bug with character encoding</li>
|
||||
<li>Fixed bug where links in footnotes — in light mode, using the default theme — would be invisible</li>
|
||||
<li>Fixed double-underlines on 404 Media links. (Fixed bug where using <u> tag inside an <a> would cause two underlines.)</li>
|
||||
<li>Added &smallcircle; to the entities decoder</li>
|
||||
<li>Synced the Mac default theme with the iOS version</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Wed, 07 May 2025 22:00:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.10b1/NetNewsWire6.1.10b1.zip" sparkle:version="6136" sparkle:shortVersionString="6.1.10b1" length="9382514" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.1b2</title>
|
||||
<description><![CDATA[
|
||||
<p>Article themes. Several themes ship with the app, and you can create your own. You can change the theme in Preferences or by adding the theme switcher to the toolbar.</p>
|
||||
<p>Copy URLs using repaired, rather than raw, feed links.</p>
|
||||
<p>Restore article scroll position on relaunching app.</p>
|
||||
<p>Added Copy Article URL and Copy External URL commands to the Edit menu.</p>
|
||||
<p>Fixed a bug where using cmd-Q wouldn’t always quit the app as quickly as one might prefer.</p>
|
||||
<p>Disallow creation of iCloud account in the app if iCloud and iCloud Drive aren’t both enabled.</p>
|
||||
<p>Fixed bug showing quote tweets that only included an image.</p>
|
||||
<p>Added a hidden pref to suppress downloading/syncing on start: `defaults write com.ranchero.NetNewsWire-Evergreen DevroeSuppressSyncOnLaunch -bool true`</p>
|
||||
<p>Video autoplay is now disallowed.</p>
|
||||
<p>Article view now supports RTL layout.</p>
|
||||
]]></description>
|
||||
<pubDate>Mon, 17 Jan 2022 17:45:00 -0800</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1b2/NetNewsWire6.1b2.zip" sparkle:version="6101" sparkle:shortVersionString="6.1b2" length="10841318" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.3</title>
|
||||
<description><![CDATA[
|
||||
<p>Same as 6.0.3b2 except for the version number.</p>
|
||||
]]></description>
|
||||
<pubDate>Sun, 05 Sep 2021 12:20:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.3/NetNewsWire6.0.3.zip" sparkle:version="6035" sparkle:shortVersionString="6.0.3" length="10477066" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.3b2</title>
|
||||
<description><![CDATA[
|
||||
<p>Feedly: preserve custom feed names with Feedly when moving them between folders</p>
|
||||
<p>Preferences: use full-width row style in accounts and extensions panes</p>
|
||||
<p>Fixed a crashing bug triggered by running some UI code outside of main thread</p>
|
||||
<p>Fixed a crashing bug that could happen when the app tries to find a feed for a website</p>
|
||||
<p>Fixed a crashing bug that could happen when rendering tweets</p>
|
||||
<p>Changed how images are placed in Twitter articles so that you can better see who Tweeted the image</p>
|
||||
<p>Fixed bug where iCloud syncing could stop prematurely when the sync database has records not in the local database</p>
|
||||
<p>Fixed bug where favicons wouldn’t be found when a home page URL has non-ASCII characters</p>
|
||||
<p>Fixed bug where external URLs in Feedbin feeds might be lost</p>
|
||||
<p>Fixed bug where words prepended with $ wouldn’t appear in Twitter feeds</p>
|
||||
<p>Fixed bug where newlines would be just a space in Twitter feeds</p>
|
||||
<p>Fixed bug where BazQux-synced feeds might stop updating</p>
|
||||
]]></description>
|
||||
<pubDate>Sun, 29 Aug 2021 15:25:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.3b2/NetNewsWire6.0.3b2.zip" sparkle:version="6034" sparkle:shortVersionString="6.0.3b2" length="10477006" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.3b1</title>
|
||||
<description><![CDATA[
|
||||
<p>Feedly: handle API change with deleting and don’t show a spurious error</p>
|
||||
<p>NewsBlur: don’t fetch articles marked hidden by NewsBlur</p>
|
||||
<p>FreshRSS: add API endpoint URL example in setup form</p>
|
||||
<p>iCloud: fixed bug not retaining feeds in a folder where the folder hasn’t been synced yet</p>
|
||||
<p>Feeds list: smart feeds remain visible despite Hide Read Feeds setting</p>
|
||||
<p>Keyboard shortcuts: fixed regression where L key wouldn’t go to next unread when feed is all read</p>
|
||||
<p>Twitter extension: fixed weird bug where an extra https:/ could appear in tweet text</p>
|
||||
]]></description>
|
||||
<pubDate>Thu, 20 May 2021 20:00:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.3b1/NetNewsWire6.0.3b1.zip" sparkle:version="6033" sparkle:shortVersionString="6.0.3b1" length="10463681" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.2</title>
|
||||
<description><![CDATA[
|
||||
<p>Same as 6.0.2b1 — no changes other than version</p>
|
||||
]]></description>
|
||||
<pubDate>Tue, 20 Apr 2021 17:40:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.2/NetNewsWire6.0.2.zip" sparkle:version="6032" sparkle:shortVersionString="6.0.2" length="10453603" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.2b1</title>
|
||||
<description><![CDATA[
|
||||
<p>Inoreader sync: fixed (hopefully) cause of rate limit errors — now doing background sync of statuses much less often - note that this fix needs to be rolled out across all NetNewsWire users in order for it to have full effect</p>
|
||||
<p>Fixed regression with the L key — now works properly again</p>
|
||||
]]></description>
|
||||
<pubDate>Thu, 15 Apr 2021 19:15:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.2b1/NetNewsWire6.0.2b1.zip" sparkle:version="6031" sparkle:shortVersionString="6.0.2b1" length="10453628" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.1</title>
|
||||
<description><![CDATA[
|
||||
<p>Adjusted layout of the add account sheet so that it fits on smaller monitors</p>
|
||||
<p>Sidebar: properly scale the smart feed icons when sidebar is set to large size in System Preferences </p>
|
||||
]]></description>
|
||||
<pubDate>Thu, 01 Apr 2021 20:22:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.1/NetNewsWire6.0.1.zip" sparkle:version="6030" sparkle:shortVersionString="6.0.1" length="10448727" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.1b2</title>
|
||||
<description><![CDATA[
|
||||
<p>Twitter: fixed a date parsing bug that could affect people in some locales, which would prevent Twitter feeds from working for them</p>
|
||||
<p>Feeds list: fixed bug where newly added feed would be called Untitled past the time when the app actually knows its name</p>
|
||||
<p>Fixed bug where next-unread command wouldn’t wrap around when you got to the bottom of the Feeds list</p>
|
||||
]]></description>
|
||||
<pubDate>Mon, 29 Mar 2021 20:55:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.1b2/NetNewsWire6.0.1b2.zip" sparkle:version="6029" sparkle:shortVersionString="6.0.1b2" length="10445067" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
Executable → Regular
+39
-300
@@ -6,310 +6,49 @@
|
||||
<description>Most recent NetNewsWire releases (not test builds).</description>
|
||||
<language>en</language>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.3</title>
|
||||
<description><![CDATA[
|
||||
<p>Feedly: preserve custom feed names with Feedly when moving them between folders</p>
|
||||
<p>Feedly: handle API change with deleting and don’t show a spurious error</p>
|
||||
<p>NewsBlur: don’t fetch articles marked hidden by NewsBlur</p>
|
||||
<p>FreshRSS: add API endpoint URL example in setup form</p>
|
||||
<p>iCloud: fixed bug not retaining feeds in a folder where the folder hasn’t been synced yet</p>
|
||||
<p>iCloud: fixed bug where iCloud syncing could stop prematurely when the sync database has records not in the local database</p>
|
||||
<p>BazQux: fixed bug where BazQux-synced feeds might stop updating</p>
|
||||
<p>Feedbin: fixed bug where external URLs in Feedbin feeds might be lost</p>
|
||||
<p>Twitter extension: fixed weird bug where an extra https:/ could appear in tweet text</p>
|
||||
<p>Preferences: use full-width row style in accounts and extensions panes</p>
|
||||
<p>Fixed a crashing bug triggered by running some UI code outside of main thread</p>
|
||||
<p>Fixed a crashing bug that could happen when the app tries to find a feed for a website</p>
|
||||
<p>Fixed a crashing bug that could happen when rendering tweets</p>
|
||||
<p>Changed how images are placed in Twitter articles so that you can better see who Tweeted the image</p>
|
||||
<p>Fixed bug where favicons wouldn’t be found when a home page URL has non-ASCII characters</p>
|
||||
<p>Fixed bug where words prepended with $ wouldn’t appear in Twitter feeds</p>
|
||||
<p>Fixed bug where newlines would be just a space in Twitter feeds</p>
|
||||
<p>Feeds list: smart feeds remain visible despite Hide Read Feeds setting</p>
|
||||
<p>Keyboard shortcuts: fixed regression where L key wouldn’t go to next unread when feed is all read</p>
|
||||
]]></description>
|
||||
<pubDate>Sun, 05 Sep 2021 12:20:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.3/NetNewsWire6.0.3.zip" sparkle:version="6035" sparkle:shortVersionString="6.0.3" length="10477066" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.2</title>
|
||||
<description><![CDATA[
|
||||
<p>Inoreader sync: fixed (hopefully) cause of rate limit errors — now doing background sync of statuses much less often - note that this fix needs to be rolled out across all NetNewsWire users in order for it to have full effect</p>
|
||||
<p>Fixed regression with the L key — now works properly again</p>
|
||||
]]></description>
|
||||
<pubDate>Tue, 20 Apr 2021 17:40:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.2/NetNewsWire6.0.2.zip" sparkle:version="6032" sparkle:shortVersionString="6.0.2" length="10453603" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0.1</title>
|
||||
<description><![CDATA[
|
||||
<p>Twitter: fixed a date parsing bug that could affect people in some locales, which would prevent Twitter feeds from working for them</p>
|
||||
<p>Preferences: adjusted layout of the add account sheet so that it fits on smaller monitors</p>
|
||||
<p>Feeds list: properly scale the smart feed icons when sidebar is set to large size in System Preferences</p>
|
||||
<p>Feeds list: fixed bug where newly added feed would be called Untitled past the time when the app actually knows its name</p>
|
||||
<p>Timeline: fixed bug where next-unread command wouldn’t wrap around when you got to the bottom of the Feeds list</p>
|
||||
<p>Timeline: fixed bug updating article display when an article with the same article ID appears more than once (which can happen when a person has multiple accounts)</p>
|
||||
<p>iCloud: won’t add feeds that aren’t parseable, which fixes an error upon trying to rename one of these feeds</p>
|
||||
<p>Feedbin: fixed a bug with read/unread status syncing</p>
|
||||
]]></description>
|
||||
<pubDate>Thu, 01 Apr 2021 20:22:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0.1/NetNewsWire6.0.1.zip" sparkle:version="6030" sparkle:shortVersionString="6.0.1" length="10448727" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.0</title>
|
||||
<description><![CDATA[
|
||||
<p>Big Sur app icon</p>
|
||||
<p>Big Sur UI (when running on Big Sur)</p>
|
||||
<p>App is now sandboxed</p>
|
||||
<p>Apple Silicon native code</p>
|
||||
<p>Syncing via iCloud</p>
|
||||
<p>Syncing via BazQux, Inoreader, NewsBlur, The Old Reader, and FreshRSS</p>
|
||||
<p>Share extension, so you can send URLs to NetNewsWire</p>
|
||||
<p>Special support for Twitter and Reddit feeds</p>
|
||||
<p>Sidebar contextual menu commands for turning on and off Reader View and for notifications</p>
|
||||
<p>High resolution icons in the sidebar (when available)</p>
|
||||
<p>External link, when available, shows in article view</p>
|
||||
<p>Preference to change article text size</p>
|
||||
<p>Preference to set preferred browser</p>
|
||||
]]></description>
|
||||
<pubDate>Sat, 27 Mar 2021 14:30:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.0/NetNewsWire6.0.zip" sparkle:version="6026" sparkle:shortVersionString="6.0" length="10447422" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.1.2</title>
|
||||
<description><![CDATA[
|
||||
<p>Fixed a crashing bug in the timeline</p>
|
||||
<p>Fixed a background color bug in dark mode in the timeline</p>
|
||||
<p>Fixed a crashing bug updating the browser popup in Preferences</p>
|
||||
<p>Feedbin: fixed bug where credentials couldn’t be updated</p>
|
||||
<p>Feedly: fixed bug syncing feed name changes</p>
|
||||
<p>Feedly: fixed a bug adding a feed to a Feedly collection that has a + in its name</p>
|
||||
<p>On My Mac: increased performance downloading feeds in the On My Mac account</p>
|
||||
]]></description>
|
||||
<pubDate>Sat, 31 Oct 2020 11:25:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-5.1.2/NetNewsWire5.1.2.zip" sparkle:version="3016" sparkle:shortVersionString="5.1.2" length="6583447" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.1.1</title>
|
||||
<description><![CDATA[
|
||||
<p>Fixed a crash handling a specific type of weird URL</p>
|
||||
<p>Preferences: restored ability to set default RSS reader</p>
|
||||
<p>Fixed bug where o key wouldn’t mark older as read</p>
|
||||
<p>Fixed an Open System Preferences button in an alert that didn’t work</p>
|
||||
<p>Fixed a possible hang when adding a feed to Feedly (and the feed isn’t found)</p>
|
||||
<p>Fixed some UI issues to do with adding a Feedly account</p>
|
||||
<p>Fixed contrast in footnotes indicator</p>
|
||||
<p>Fixed bug where duplicate accounts (same username and service) could be made</p>
|
||||
<p>Fixed bug where open in Safari in background might not open in the background</p>
|
||||
]]></description>
|
||||
<pubDate>Mon, 05 Oct 2020 11:45:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-5.1.1/NetNewsWire5.1.1.zip" sparkle:version="3012" sparkle:shortVersionString="5.1.1" length="6582076" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.1</title>
|
||||
<description><![CDATA[
|
||||
<p>Changes since 5.0.4:</p>
|
||||
<p>Feedly syncing</p>
|
||||
<p>Reader view</p>
|
||||
<p>Notifications (configure per feed in the Info window)</p>
|
||||
<p>Multiple windows - File > New Window</p>
|
||||
<p>View > Hide Read Feeds</p>
|
||||
<p>View > Hide Read Articles (also a filter button above timeline for this)</p>
|
||||
<p>Clean Up command (to immediately hide read articles when hide-read-articles is on)</p>
|
||||
<p>Feeds view: remember expansion state between runs</p>
|
||||
<p>Timeline: more compact rows (source and date on same line)</p>
|
||||
<p>Timeline: sort menu on top</p>
|
||||
<p>Timeline: swipe actions</p>
|
||||
<p>Article view: shift-space scrolls backwards</p>
|
||||
<p>Articles with non-ASCII URLs can now open in browser</p>
|
||||
<p>Adding feeds with non-ASCII URLs now works</p>
|
||||
<p>AppleScript: article now has a feed property</p>
|
||||
<p>Hold down shift to temporarily toggle open-in-browser in background preference</p>
|
||||
<p>Article > Mark Above as Read, Mark Below as Read</p>
|
||||
<p>Preferences: Choose preferred browser (for viewing web pages)</p>
|
||||
<p>Inspector: window title now matches name of thing being inspected</p>
|
||||
]]></description>
|
||||
<pubDate>Sat, 19 Sep 2020 12:45:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-5.1/NetNewsWire5.1.zip" sparkle:version="3007" sparkle:shortVersionString="5.1" length="6561360" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.15.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0.4</title>
|
||||
<description><![CDATA[
|
||||
<p>Performance enhancement: fetching articles is faster and uses less memory</p>
|
||||
|
||||
<p>Changed the retention policy to match iOS</p>
|
||||
|
||||
<p>Feeds view: fixed bug where multiple sequential deletes could mess up the current selection index</p>
|
||||
|
||||
<p>Article view: dealt with Twitter change that caused Twitter embeds to get cut off</p>
|
||||
|
||||
<p>Article view: properly size emojis that are actually graphics (from Wordpress, for instance)</p>
|
||||
|
||||
<p>Article view: stop playing any audio if the window is closed</p>
|
||||
|
||||
<p>Article view: don’t let line lengths get too long</p>
|
||||
|
||||
<p>Article view: fixed display of BandCamp widgets</p>
|
||||
|
||||
<p>OPML export: use an accessory view instead of an intermediate sheet</p>
|
||||
|
||||
<p>Add Folder: disable Add Folder button when text field is empty</p>
|
||||
|
||||
<p>Feed icons: get more icons from Feedbin; get favicons from some tricky cases</p>
|
||||
|
||||
<p>Add Feed: now allows IPv6 literal URLs</p>
|
||||
|
||||
<p>Feed discovery: give less weight to feeds with the word “podcast” in them, because they’re probably not what we want</p>
|
||||
|
||||
<p>Refreshing: fixed bug where automatic refreshing might not happening after the computer wakes from sleep</p>
|
||||
|
||||
<p>Preferences > Accounts: Renamed “Create” account button to “Add Account”</p>
|
||||
|
||||
<p>Fixed bug where a Feedbin article could stay unread right after you select it</p>
|
||||
|
||||
<p>Fixed bug where folder names with double quotes would have the quotes replaced with the HTML entity for quote</p>
|
||||
|
||||
<p>When importing from NNW 3, the app now ignores script feeds (since we don’t have that feature yet)</p>
|
||||
|
||||
<p>Fixed bug where, right after initial launch, the spacebar might not work to go to next unread article</p>
|
||||
|
||||
<p>Pressing return now opens the selected article in your browser</p>
|
||||
]]></description>
|
||||
<pubDate>Sat, 08 Aug 2020 11:40:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-5.0.4/NetNewsWire5.0.4.zip" sparkle:version="2622" sparkle:shortVersionString="5.0.4" length="5130054" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0.3</title>
|
||||
<description><![CDATA[
|
||||
<p>Significantly enhanced performance during syncs and refreshes. Fetching articles from the database is also faster.</p>
|
||||
|
||||
<p>When running for the first time, and the user previously used NetNewsWire 3, it will automatically import NetNewsWire 3 subscriptions instead of the defaults for new users.</p>
|
||||
|
||||
<p>You can also import NetNewsWire 3 subscriptions via the new File > Import NNW3 Subscriptions… command.</p>
|
||||
|
||||
<p>Keyboard shortcuts: the 's' key toggles starred status. The 'r' and 'u' keys now both toggle read status (instead of setting read and unread status, respectively).</p>
|
||||
|
||||
<p>Articles view: articles where the feed icon is quite large would be slow to render — now they render as fast as other articles.</p>
|
||||
|
||||
<p>Articles view: a bug where keyboard shortcuts wouldn’t work after giving the articles view focus has been fixed.</p>
|
||||
|
||||
<p>Articles view: YouTube videos could end up small. Fixed.</p>
|
||||
|
||||
<p>Articles view: fixed a bug scaling images to fit in the view.</p>
|
||||
|
||||
<p>Fixed the space bar when running on Catalina. It wouldn’t advance to the next unread — now it will. (This was due to a change in JavaScript in Catalina.)</p>
|
||||
|
||||
<p>Fixed a crashing bug having to do with async database fetches for the timeline.</p>
|
||||
|
||||
<p>Feedbin syncing: fixed a bug where renaming a tag on the Feedbin site would result in feeds in NNW ending up at the top level.</p>
|
||||
|
||||
<p>Help menu: fixed the expired Slack link.</p>
|
||||
|
||||
]]></description>
|
||||
<pubDate>Tue, 22 Oct 2019 13:00:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/brentsimmons/NetNewsWire/releases/download/mac-5.0.3/NetNewsWire5.0.3.zip" sparkle:version="2618" sparkle:shortVersionString="5.0.3" length="5152201" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0.2</title>
|
||||
<description><![CDATA[
|
||||
<p>The app movement monitor has been updated to handle quarantined apps and translocation.</p>
|
||||
|
||||
<p>Normally we wouldn’t have pushed out a new release for a single bug fix, but this one is important — we were getting false positives on app movement, which was affecting some users negatively.</p>
|
||||
]]></description>
|
||||
<pubDate>Sat, 14 Sep 2019 11:20:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/brentsimmons/NetNewsWire/releases/download/mac-5.0.2/NetNewsWire5.0.2.zip" sparkle:version="2615" sparkle:shortVersionString="5.0.2" length="5082387" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0.1</title>
|
||||
<description><![CDATA[
|
||||
<p>Crash fix: when the app is renamed or moved on disk while running, alert the user and quit the app. This prevents crashes that will happen due to renaming/moving. See Daniel Jalkut on <a href="https://red-sweater.com/blog/3508/app-movement-monitoring">App Movement Monitoring</a> for more info.</p>
|
||||
|
||||
<p>(Probably) fix a crashing bug having to do with a callback being called more than once, when it was designed to be called just once.</p>
|
||||
|
||||
<p>Sidebar: deleting an empty Feedbin folder no longer makes the sidebar non-responsive.</p>
|
||||
|
||||
<p>Timeline: update UI more quickly when a feed icon is downloaded.</p>
|
||||
|
||||
<p>Timeline: reload the timeline when show-feed-names is toggled. This fixes a bug where switching between a folder and a feed with the exact same list of articles to appear in the timeline would result in display glitches.</p>
|
||||
|
||||
<p>Timeline and article pane: make sure the link for an article isn’t an empty string.</p>
|
||||
|
||||
<p>Article pane: stop blocking links containing the string “feedburner” — there are legitimate cases where that string appears.</p>
|
||||
|
||||
<p>Article pane: handle figures and iframes as we do images, so they fit in the view.</p>
|
||||
|
||||
<p>Article pane: fix white flash on first article load while in Dark Mode.</p>
|
||||
|
||||
<p>Preferences > General: add checkbox to hide the unread count in the Dock.</p>
|
||||
|
||||
<p>Preferences > Accounts: Updated the UI when a Feedbin user with an expired trial creates an account in NetNewsWire.</p>
|
||||
|
||||
<p>RSS parser: Detect RDF (RSS 1.0) feeds that lack an XML header.</p>
|
||||
|
||||
<p>RSS parser: Parse Atom-style dates that are missing a T character in the middle.</p>
|
||||
|
||||
<p>RSS parser: check for bad permalinks more aggressively. If they don’t contain a / character, then do not consider them permalinks.</p>
|
||||
|
||||
<p>RSS parser: don’t let author/title overwrite item/title.</p>
|
||||
|
||||
<p>About window: add link to NetNewsWire website.</p>
|
||||
|
||||
<p>Feedbin syncing: fixed a bug where starred articles could appear as unread.</p>
|
||||
|
||||
<p>Microblog Mac app sharing: when it has to launch the app first, it waits a little longer before sending it content, which should fix a bug where sometimes you get no content in that case.</p>
|
||||
|
||||
<p>Enable the Open in Browser command only when a single article is selected.</p>
|
||||
|
||||
]]></description>
|
||||
<pubDate>Fri, 13 Sep 2019 13:40:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/brentsimmons/NetNewsWire/releases/download/mac-5.0.1/NetNewsWire5.0.1.zip" sparkle:version="2614" sparkle:shortVersionString="5.0.1" length="5095218" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0b6</title>
|
||||
<title>NetNewsWire 6.1.10</title>
|
||||
<description><![CDATA[
|
||||
<p>Okay — one last beta! Pretty sure, at least.</p>
|
||||
<p>Fixes a bug with undoing deleting feeds or folders. The sidebar wouldn’t update afterward to show that the feed is back. Now it does.</p>
|
||||
<p>Opens preferences window in center of screen.</p>
|
||||
<p>Centers main window on first launch.</p>
|
||||
]]></description>
|
||||
<pubDate>Fri, 23 Aug 2019 18:50:00 -0700</pubDate>
|
||||
<enclosure url="https://github.com/brentsimmons/NetNewsWire/releases/download/mac-5.0b6/NetNewsWire5.0b6.zip" sparkle:version="2608" sparkle:shortVersionString="5.0b6" length="5174618" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
<p>Changes since 6.1.9:</p>
|
||||
<ul>
|
||||
<li>Added caching to the downloader (the one that downloads feed icons, favicons, etc.) — make fewer network requests</li>
|
||||
<li>Worked around The Verge’s bug with character encoding</li>
|
||||
<li>Fixed bug where links in footnotes — in light mode, using the default theme — would be invisible</li>
|
||||
<li>Fixed double-underlines on 404 Media links. (Fixed bug where using tag inside an would cause two underlines.)</li>
|
||||
<li>Added &smallcircle; to the entities decoder</li>
|
||||
<li>Synced the Mac default theme with the iOS version</li>
|
||||
<li>Adopted secure state restoration</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Mon, 08 Sep 2025 11:24:08 -0700</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.10/NetNewsWire6.1.10.zip" sparkle:version="6140" sparkle:shortVersionString="6.1.10" length="9396988" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 5.0b4</title>
|
||||
<description><![CDATA[
|
||||
<p>Fixed a bug showing the unread count for the selected feed, smart feed, or folder.</p>
|
||||
]]></description>
|
||||
<pubDate>Wed, 14 Aug 2019 00:30:00 -0700</pubDate>
|
||||
<enclosure url="https://ranchero.com/downloads/NetNewsWire5.0b4.zip" sparkle:version="2606" sparkle:shortVersionString="5.0b4" length="5168358" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
<item>
|
||||
<title>NetNewsWire 6.1.9</title>
|
||||
<description><![CDATA[
|
||||
<ul>
|
||||
<li>Fix some glitches in the default article theme</li>
|
||||
<li>Fix an issue with slow updates for some feeds (by not paying attention to http Cache-Control response headers [except for openrss.org])</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Sun, 12 Jan 2025 12:30:00 -0800</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.9/NetNewsWire6.1.9.zip" sparkle:version="6135" sparkle:shortVersionString="6.1.9" length="10086716" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>NetNewsWire 6.1.8</title>
|
||||
<description><![CDATA[
|
||||
<ul>
|
||||
<li>Fix state restoration bug (temporary fix — building on Xcode 14 — permanent fix to come later)</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<pubDate>Thu, 19 Dec 2024 12:45:00 -0800</pubDate>
|
||||
<enclosure url="https://github.com/Ranchero-Software/NetNewsWire/releases/download/mac-6.1.8/NetNewsWire6.1.8.zip" sparkle:version="6133" sparkle:shortVersionString="6.1.8" length="10087307" type="application/zip" />
|
||||
<sparkle:minimumSystemVersion>13.0.0</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -60,4 +60,17 @@ NetNewsWire is a multi-platform RSS reader with separate targets for macOS and i
|
||||
- API keys are managed through buildscripts/updateSecrets.sh (runs during builds)
|
||||
- Some features disabled in development builds due to private API keys
|
||||
- Code signing configured through SharedXcodeSettings for development
|
||||
- Documentation and technical notes are located in the `Technotes/` folder
|
||||
- Documentation and technical notes are located in the `Technotes/` folder
|
||||
|
||||
## Code Formatting
|
||||
|
||||
Prefer idiomatic modern Swift.
|
||||
|
||||
Prefer `if let x` and `guard let x` over `if let x = x` and `guard let x = x`.
|
||||
|
||||
Don’t use `...` or `…` in Logger messages.
|
||||
|
||||
Guard statements should always put the return in a separate line.
|
||||
|
||||
Don’t do force unwrapping of optionals.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting Brent Simmons via direct message on the [Slack group](https://netnewswire.com/slack). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct/][version]
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org/
|
||||
[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/
|
||||
+4
-77
@@ -2,12 +2,16 @@
|
||||
|
||||
We welcome contributions — but it’s **really important to ask first** before working on a new feature or bug fix. Just because the app is open source doesn’t mean we add features just whenever someone codes one up. The app is planned the same way it would be if it weren’t open source. (See NetNewsWire [milestones](https://github.com/Ranchero-Software/NetNewsWire/milestones).)
|
||||
|
||||
Also: just because a ticket exists doesn’t mean we’re going to implement a fix or feature. Or not now, or not before some other things happen first.
|
||||
|
||||
Here’s how to contribute:
|
||||
|
||||
1. Find or file a ticket describing the bug you want to fix or feature you want to add.
|
||||
2. On the [Slack group](https://netnewswire.com/slack), bring it up on the #work channel for discussion (which may or may not include implementation discussion). **This is very important, because there might be things you need to know before you start work.** We might also, for whatever reason, not want to do that feature, not do it this year, do it in a very different way, or whatever. Or it may be that a given bug fix should come after some other refactoring, for instance.
|
||||
3. Once approved, then go for it. Write the code, then do a pull request. We’ll either have comments or we’ll merge it. (We might revise it afterward, of course.)
|
||||
|
||||
By participating, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Notes
|
||||
|
||||
It’s important that the pull request merge cleanly with `main`. It must add no more warnings than we already have. (We try to keep warnings at zero, but aren’t always successful.)
|
||||
@@ -15,80 +19,3 @@ It’s important that the pull request merge cleanly with `main`. It must add no
|
||||
You should have read the [coding guidelines](Technotes/CodingGuidelines.md) first. If your code doesn’t follow the guidelines, we will likely suggest revising it.
|
||||
|
||||
Patience may be required at times. Brent isn’t always available — just because of life. 🐥
|
||||
|
||||
Our code of conduct is below.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
### Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
### Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
### Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
### Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting Brent Simmons via direct message on the [Slack group](https://netnewswire.com/slack). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
### Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct/][version]
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org/
|
||||
[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/
|
||||
+19
-6
@@ -23,7 +23,8 @@ final class AppDefaults {
|
||||
|
||||
struct Key {
|
||||
static let firstRunDate = "firstRunDate"
|
||||
static let windowState = "windowState"
|
||||
static let legacyWindowState = "windowState"
|
||||
static let secureWindowState = "secureWindowState"
|
||||
static let lastImageCacheFlushDate = "lastImageCacheFlushDate"
|
||||
static let sidebarFontSize = "sidebarFontSize"
|
||||
static let timelineFontSize = "timelineFontSize"
|
||||
@@ -73,16 +74,28 @@ final class AppDefaults {
|
||||
firstRunDate = Date()
|
||||
return true
|
||||
}()
|
||||
|
||||
var windowState: [AnyHashable : Any]? {
|
||||
|
||||
/// Stores window state prior to switching to secure state restoration.
|
||||
///
|
||||
/// This is referenced temporarily, only to be able to provide migration from legacy to secure window state.
|
||||
/// TODO: delete for NetNewsWire 7.
|
||||
var legacyWindowState: [AnyHashable: Any]? {
|
||||
UserDefaults.standard.object(forKey: Key.legacyWindowState) as? [AnyHashable: Any]
|
||||
}
|
||||
|
||||
func deleteLegacyWindowState() {
|
||||
UserDefaults.standard.removeObject(forKey: Key.legacyWindowState)
|
||||
}
|
||||
|
||||
var secureWindowState: Data? {
|
||||
get {
|
||||
return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any]
|
||||
UserDefaults.standard.object(forKey: Key.secureWindowState) as? Data
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: Key.windowState)
|
||||
UserDefaults.standard.set(newValue, forKey: Key.secureWindowState)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var lastImageCacheFlushDate: Date? {
|
||||
get {
|
||||
return AppDefaults.date(for: Key.lastImageCacheFlushDate)
|
||||
|
||||
+61
-58
@@ -8,6 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
import UserNotifications
|
||||
import os
|
||||
import Articles
|
||||
import RSTree
|
||||
import RSWeb
|
||||
@@ -15,7 +16,6 @@ import Account
|
||||
import RSCore
|
||||
import RSCoreResources
|
||||
import Secrets
|
||||
import OSLog
|
||||
import CrashReporter
|
||||
|
||||
// If we're not going to import Sparkle, provide dummy protocols to make it easy
|
||||
@@ -30,8 +30,9 @@ import Sparkle
|
||||
var appDelegate: AppDelegate!
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate
|
||||
{
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate {
|
||||
|
||||
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "AppDelegate")
|
||||
|
||||
private struct WindowRestorationIdentifiers {
|
||||
static let mainWindow = "mainWindow"
|
||||
@@ -184,14 +185,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
try self.softwareUpdater.start()
|
||||
}
|
||||
catch {
|
||||
NSLog("Failed to start software updater with error: \(error)")
|
||||
Self.logger.error("Failed to start software updater with error: \(error.localizedDescription)")
|
||||
}
|
||||
#endif
|
||||
|
||||
AppDefaults.shared.registerDefaults()
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
||||
if isFirstRun {
|
||||
os_log(.debug, "Is first run.")
|
||||
Self.logger.debug("Is first run.")
|
||||
}
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
|
||||
@@ -301,6 +302,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
return false
|
||||
}
|
||||
|
||||
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive(_ notification: Notification) {
|
||||
fireOldTimers()
|
||||
}
|
||||
@@ -611,45 +616,39 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
}
|
||||
|
||||
@IBAction func openWebsite(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://netnewswire.com/", inBackground: false)
|
||||
HelpURL.website.open()
|
||||
}
|
||||
|
||||
@IBAction func openReleaseNotes(_ sender: Any?) {
|
||||
Browser.open(URL.releaseNotes.absoluteString, inBackground: false)
|
||||
HelpURL.releaseNotes.open()
|
||||
}
|
||||
|
||||
|
||||
@IBAction func openHowToSupport(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://github.com/brentsimmons/NetNewsWire/blob/main/Technotes/HowToSupportNetNewsWire.markdown", inBackground: false)
|
||||
HelpURL.howToSupportNetNewsWire.open()
|
||||
}
|
||||
|
||||
@IBAction func openRepository(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://github.com/brentsimmons/NetNewsWire", inBackground: false)
|
||||
@IBAction func openTechnotes(_ sender: Any?) {
|
||||
HelpURL.technotes.open()
|
||||
}
|
||||
|
||||
@IBAction func openRepository(_ sender: Any?) {
|
||||
HelpURL.githubRepo.open()
|
||||
}
|
||||
|
||||
@IBAction func openBugTracker(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://github.com/brentsimmons/NetNewsWire/issues", inBackground: false)
|
||||
HelpURL.bugTracker.open()
|
||||
}
|
||||
|
||||
@IBAction func openSlackGroup(_ sender: Any?) {
|
||||
Browser.open("https://netnewswire.com/slack", inBackground: false)
|
||||
HelpURL.slack.open()
|
||||
}
|
||||
|
||||
@IBAction func showHelp(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://netnewswire.com/help/mac/6.1/en/", inBackground: false)
|
||||
}
|
||||
|
||||
@IBAction func donateToAppCampForGirls(_ sender: Any?) {
|
||||
Browser.open("https://appcamp4girls.com/contribute/", inBackground: false)
|
||||
HelpURL.helpHome.open()
|
||||
}
|
||||
|
||||
@IBAction func showPrivacyPolicy(_ sender: Any?) {
|
||||
Browser.open("https://netnewswire.com/privacypolicy.html", inBackground: false)
|
||||
HelpURL.privacyPolicy.open()
|
||||
}
|
||||
|
||||
@IBAction func gotoToday(_ sender: Any?) {
|
||||
@@ -731,10 +730,12 @@ extension AppDelegate {
|
||||
}
|
||||
|
||||
@IBAction func openApplicationSupportFolder(_ sender: Any?) {
|
||||
#if DEBUG
|
||||
guard let appSupport = Platform.dataSubfolder(forApplication: nil, folderName: "") else { return }
|
||||
NSWorkspace.shared.open(URL(fileURLWithPath: appSupport))
|
||||
#endif
|
||||
guard let appSupport = Platform.dataSubfolder(forApplication: nil, folderName: "") else {
|
||||
assertionFailure("Expected non-nil app support folder path")
|
||||
return
|
||||
}
|
||||
|
||||
NSWorkspace.shared.open(URL(fileURLWithPath: appSupport))
|
||||
}
|
||||
|
||||
@IBAction func toggleWebInspectorEnabled(_ sender: Any?) {
|
||||
@@ -750,6 +751,14 @@ extension AppDelegate {
|
||||
#endif
|
||||
}
|
||||
|
||||
@IBAction func showiCloudDriveMissingAlert(_ sender: Any?) {
|
||||
// Manual testing for alert in AccountsAddCloudKitWindowController
|
||||
// Check for:
|
||||
// - Expected text
|
||||
// - Button for opening Settings
|
||||
// - Button works
|
||||
mainWindowController?.presentError(AddCloudKitAccountError.iCloudDriveMissing)
|
||||
}
|
||||
}
|
||||
|
||||
internal extension AppDelegate {
|
||||
@@ -975,43 +984,37 @@ extension AppDelegate: NSWindowRestoration {
|
||||
// Handle Notification Actions
|
||||
|
||||
private extension AppDelegate {
|
||||
|
||||
|
||||
func handleMarkAsRead(userInfo: [AnyHashable: Any]) {
|
||||
guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any],
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String else {
|
||||
return
|
||||
}
|
||||
|
||||
let account = AccountManager.shared.existingAccount(with: accountID)
|
||||
guard account != nil else {
|
||||
os_log(.debug, "No account found from notification.")
|
||||
return
|
||||
}
|
||||
let article = try? account!.fetchArticles(.articleIDs([articleID]))
|
||||
guard article != nil else {
|
||||
os_log(.debug, "No article found from search using %@", articleID)
|
||||
return
|
||||
}
|
||||
account!.markArticles(article!, statusKey: .read, flag: true) { _ in }
|
||||
handleStatusNotification(userInfo: userInfo, statusKey: .read)
|
||||
}
|
||||
|
||||
|
||||
func handleMarkAsStarred(userInfo: [AnyHashable: Any]) {
|
||||
handleStatusNotification(userInfo: userInfo, statusKey: .starred)
|
||||
}
|
||||
|
||||
private func handleStatusNotification(userInfo: [AnyHashable: Any], statusKey: ArticleStatus.Key) {
|
||||
guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any],
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String else {
|
||||
return
|
||||
}
|
||||
let account = AccountManager.shared.existingAccount(with: accountID)
|
||||
guard account != nil else {
|
||||
os_log(.debug, "No account found from notification.")
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String else {
|
||||
assertionFailure("Expected valid articlePathUserInfo from userInfo \(userInfo)")
|
||||
Self.logger.error("No valid articlePathUserInfo from userInfo \(userInfo) in status notification")
|
||||
return
|
||||
}
|
||||
let article = try? account!.fetchArticles(.articleIDs([articleID]))
|
||||
guard article != nil else {
|
||||
os_log(.debug, "No article found from search using %@", articleID)
|
||||
|
||||
guard let account = AccountManager.shared.existingAccount(with: accountID) else {
|
||||
assertionFailure("Expected account with \(accountID)")
|
||||
Self.logger.error("No account with accountID \(accountID) found from status notification")
|
||||
return
|
||||
}
|
||||
account!.markArticles(article!, statusKey: .starred, flag: true) { _ in }
|
||||
|
||||
guard let singleArticleSet = try? account.fetchArticles(.articleIDs([articleID])) else {
|
||||
assertionFailure("Expected article with \(articleID)")
|
||||
Self.logger.error("No article with articleID found \(articleID) from status notification")
|
||||
return
|
||||
}
|
||||
|
||||
assert(singleArticleSet.count == 1)
|
||||
account.markArticles(singleArticleSet, statusKey: statusKey, flag: true) { _ in }
|
||||
}
|
||||
}
|
||||
@@ -540,10 +540,11 @@
|
||||
<action selector="toggleWebInspectorEnabled:" target="Voe-Tx-rLC" id="SNL-zh-XIE"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Open Application Support Folder" id="rg6-L6-JUr">
|
||||
<menuItem isSeparatorItem="YES" id="dgO-u4-aEs"/>
|
||||
<menuItem title="Show iCloud Drive Missing Alert" id="m0T-w3-neT">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="openApplicationSupportFolder:" target="Ady-hI-5gd" id="gT9-ry-evV"/>
|
||||
<action selector="showiCloudDriveMissingAlert:" target="Ady-hI-5gd" id="kfQ-dM-8vB"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
@@ -607,6 +608,12 @@
|
||||
<action selector="addAppNews:" target="Ady-hI-5gd" id="xHC-9j-EpT"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Open Application Support Folder" id="QxZ-DC-21I">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="openApplicationSupportFolder:" target="Ady-hI-5gd" id="StO-ob-5HH"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="rK6-cL-4Vj"/>
|
||||
<menuItem title="Website" id="q2Z-9K-GBd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
@@ -638,10 +645,16 @@
|
||||
<action selector="openBugTracker:" target="Ady-hI-5gd" id="fZQ-ng-gIm"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Slack Group" id="4eb-qF-n9S">
|
||||
<menuItem title="Slack Group" id="OKC-FV-V33">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="openSlackGroup:" target="Ady-hI-5gd" id="YX2-gA-pgV"/>
|
||||
<action selector="openSlackGroup:" target="Ady-hI-5gd" id="5HZ-0D-vG5"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Technotes" id="4eb-qF-n9S">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="openTechnotes:" target="Ady-hI-5gd" id="O06-UA-SCO"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import RSCore
|
||||
import RSWeb
|
||||
import CrashReporter
|
||||
|
||||
@@ -27,6 +28,9 @@ struct CrashReporter {
|
||||
/// Look in ~/Library/Logs/DiagnosticReports/ for a new crash log for this app.
|
||||
/// Show a crash log reporter window if found.
|
||||
static func check(crashReporter: PLCrashReporter) {
|
||||
guard !Platform.isRunningUnitTests else {
|
||||
return
|
||||
}
|
||||
guard crashReporter.hasPendingCrashReport(),
|
||||
let crashData = crashReporter.loadPendingCrashReportData(),
|
||||
let crashReport = try? PLCrashReport(data: crashData),
|
||||
|
||||
@@ -12,14 +12,13 @@ import os.log
|
||||
|
||||
struct ErrorHandler {
|
||||
|
||||
private static var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Account")
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ErrorHandler")
|
||||
|
||||
public static func present(_ error: Error) {
|
||||
NSApplication.shared.presentError(error)
|
||||
}
|
||||
|
||||
|
||||
public static func log(_ error: Error) {
|
||||
os_log(.error, log: self.log, "%@", error.localizedDescription)
|
||||
logger.error("\(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import RSParser
|
||||
// Else,
|
||||
// display error sheet.
|
||||
|
||||
class AddFeedController: AddFeedWindowControllerDelegate {
|
||||
final class AddFeedController: AddFeedWindowControllerDelegate {
|
||||
|
||||
private let hostWindow: NSWindow
|
||||
private var addFeedWindowController: AddFeedWindowController?
|
||||
|
||||
@@ -12,8 +12,8 @@ import RSTree
|
||||
import Articles
|
||||
import Account
|
||||
|
||||
class AddWebFeedWindowController : NSWindowController, AddFeedWindowController {
|
||||
|
||||
final class AddWebFeedWindowController : NSWindowController, AddFeedWindowController {
|
||||
|
||||
@IBOutlet var urlTextField: NSTextField!
|
||||
@IBOutlet var nameTextField: NSTextField!
|
||||
@IBOutlet var addButton: NSButton!
|
||||
@@ -47,10 +47,13 @@ class AddWebFeedWindowController : NSWindowController, AddFeedWindowController {
|
||||
self.folderTreeController = folderTreeController
|
||||
}
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
hostWindow.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
}
|
||||
hostWindow.beginSheet(window) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
}
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
if let urlString = urlString {
|
||||
|
||||
@@ -11,7 +11,7 @@ import RSCore
|
||||
import RSTree
|
||||
import Account
|
||||
|
||||
class FolderTreeMenu {
|
||||
final class FolderTreeMenu {
|
||||
|
||||
static func createFolderPopupMenu(with rootNode: Node, restrictToSpecialAccounts: Bool = false) -> NSMenu {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import AppKit
|
||||
import Articles
|
||||
import Account
|
||||
|
||||
class AddFolderWindowController : NSWindowController {
|
||||
final class AddFolderWindowController : NSWindowController {
|
||||
|
||||
@IBOutlet var folderNameTextField: NSTextField!
|
||||
@IBOutlet var accountPopupButton: NSPopUpButton!
|
||||
@@ -23,10 +23,13 @@ class AddFolderWindowController : NSWindowController {
|
||||
|
||||
// MARK: - API
|
||||
|
||||
func runSheetOnWindow(_ w: NSWindow) {
|
||||
hostWindow = w
|
||||
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
self.hostWindow = hostWindow
|
||||
|
||||
hostWindow.beginSheet(window) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
if returnCode == NSApplication.ModalResponse.OK {
|
||||
self.addFolderIfNeeded()
|
||||
}
|
||||
@@ -62,11 +65,19 @@ class AddFolderWindowController : NSWindowController {
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func cancel(_ sender: Any?) {
|
||||
hostWindow!.endSheet(window!, returnCode: .cancel)
|
||||
guard let hostWindow, let window else {
|
||||
return
|
||||
}
|
||||
hostWindow.endSheet(window, returnCode: .cancel)
|
||||
self.hostWindow = nil
|
||||
}
|
||||
|
||||
@IBAction func addFolder(_ sender: Any?) {
|
||||
hostWindow!.endSheet(window!, returnCode: .OK)
|
||||
guard let hostWindow, let window else {
|
||||
return
|
||||
}
|
||||
hostWindow.endSheet(window, returnCode: .OK)
|
||||
self.hostWindow = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ enum ArticleExtractorButtonState {
|
||||
case off
|
||||
}
|
||||
|
||||
class ArticleExtractorButton: NSButton {
|
||||
final class ArticleExtractorButton: NSButton {
|
||||
|
||||
private var animatedLayer: CALayer?
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
import WebKit
|
||||
import Articles
|
||||
|
||||
class DetailIconSchemeHandler: NSObject, WKURLSchemeHandler {
|
||||
final class DetailIconSchemeHandler: NSObject, WKURLSchemeHandler {
|
||||
|
||||
var currentArticle: Article?
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ final class DetailViewController: NSViewController, WKUIDelegate {
|
||||
private lazy var regularWebViewController = createWebViewController()
|
||||
private var searchWebViewController: DetailWebViewController?
|
||||
|
||||
var windowState: DetailWindowState {
|
||||
currentWebViewController.windowState
|
||||
}
|
||||
|
||||
private var currentWebViewController: DetailWebViewController! {
|
||||
didSet {
|
||||
let webview = currentWebViewController.view
|
||||
@@ -107,13 +111,6 @@ final class DetailViewController: NSViewController, WKUIDelegate {
|
||||
}
|
||||
window.makeFirstResponderUnlessDescendantIsFirstResponder(currentWebViewController.webView)
|
||||
}
|
||||
|
||||
// MARK: State Restoration
|
||||
|
||||
func saveState(to state: inout [AnyHashable : Any]) {
|
||||
currentWebViewController.saveState(to: &state)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - DetailWebViewControllerDelegate
|
||||
|
||||
@@ -35,6 +35,10 @@ final class DetailWebViewController: NSViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var windowState: DetailWindowState {
|
||||
DetailWindowState(isShowingExtractedArticle: isShowingExtractedArticle, windowScrollY: windowScrollY ?? 0)
|
||||
}
|
||||
|
||||
var article: Article? {
|
||||
switch state {
|
||||
case .article(let article, _):
|
||||
@@ -73,16 +77,6 @@ final class DetailWebViewController: NSViewController {
|
||||
}
|
||||
}
|
||||
|
||||
static let userScripts: [WKUserScript] = {
|
||||
let filenames = ["main", "main_mac", "newsfoot"]
|
||||
let scripts = filenames.map { filename in
|
||||
let scriptURL = Bundle.main.url(forResource: filename, withExtension: ".js")!
|
||||
let scriptSource = try! String(contentsOf: scriptURL)
|
||||
return WKUserScript(source: scriptSource, injectionTime: .atDocumentStart, forMainFrameOnly: true)
|
||||
}
|
||||
return scripts
|
||||
}()
|
||||
|
||||
private struct MessageName {
|
||||
static let mouseDidEnter = "mouseDidEnter"
|
||||
static let mouseDidExit = "mouseDidExit"
|
||||
@@ -90,24 +84,12 @@ final class DetailWebViewController: NSViewController {
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
let preferences = WKPreferences()
|
||||
preferences.minimumFontSize = 12.0
|
||||
preferences.javaScriptCanOpenWindowsAutomatically = false
|
||||
|
||||
let configuration = WKWebViewConfiguration()
|
||||
configuration.preferences = preferences
|
||||
configuration.defaultWebpagePreferences.allowsContentJavaScript = AppDefaults.shared.isArticleContentJavascriptEnabled
|
||||
configuration.setURLSchemeHandler(detailIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme)
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = .audio
|
||||
let configuration = WebViewConfiguration.configuration(with: detailIconSchemeHandler)
|
||||
|
||||
let userContentController = WKUserContentController()
|
||||
userContentController.add(self, name: MessageName.windowDidScroll)
|
||||
userContentController.add(self, name: MessageName.mouseDidEnter)
|
||||
userContentController.add(self, name: MessageName.mouseDidExit)
|
||||
for script in Self.userScripts {
|
||||
userContentController.addUserScript(script)
|
||||
}
|
||||
configuration.userContentController = userContentController
|
||||
configuration.userContentController.add(self, name: MessageName.windowDidScroll)
|
||||
configuration.userContentController.add(self, name: MessageName.mouseDidEnter)
|
||||
configuration.userContentController.add(self, name: MessageName.mouseDidExit)
|
||||
|
||||
webView = DetailWebView(frame: NSRect.zero, configuration: configuration)
|
||||
webView.uiDelegate = self
|
||||
@@ -120,15 +102,13 @@ final class DetailWebViewController: NSViewController {
|
||||
|
||||
view = webView
|
||||
|
||||
// Hide the web view until the first reload (navigation) is complete (plus some delay) to avoid the awful white flash that happens on the initial display in dark mode.
|
||||
// Hide the web view until the first reload (navigation) is committed (plus some delay) to avoid the white flash that happens on initial display in dark mode.
|
||||
// See bug #901.
|
||||
webView.isHidden = true
|
||||
waitingForFirstReload = true
|
||||
|
||||
#if !MAC_APP_STORE
|
||||
webInspectorEnabled = AppDefaults.shared.webInspectorEnabled
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil)
|
||||
#endif
|
||||
webInspectorEnabled = AppDefaults.shared.webInspectorEnabled
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(webFeedIconDidBecomeAvailable(_:)), name: .feedIconDidBecomeAvailable, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil)
|
||||
@@ -191,14 +171,6 @@ final class DetailWebViewController: NSViewController {
|
||||
override func scrollPageUp(_ sender: Any?) {
|
||||
webView.scrollPageUp(sender)
|
||||
}
|
||||
|
||||
// MARK: State Restoration
|
||||
|
||||
func saveState(to state: inout [AnyHashable : Any]) {
|
||||
state[UserInfoKey.isShowingExtractedArticle] = isShowingExtractedArticle
|
||||
state[UserInfoKey.articleWindowScrollY] = windowScrollY
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - WKScriptMessageHandler
|
||||
@@ -239,25 +211,30 @@ extension DetailWebViewController: WKNavigationDelegate, WKUIDelegate {
|
||||
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
|
||||
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
// See note in viewDidLoad()
|
||||
if waitingForFirstReload {
|
||||
assert(webView.isHidden)
|
||||
waitingForFirstReload = false
|
||||
reloadHTML()
|
||||
|
||||
// Waiting for the first navigation to complete isn't long enough to avoid the flash of white.
|
||||
// A hard coded value is awful, but 5/100th of a second seems to be enough.
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||
webView.isHidden = false
|
||||
}
|
||||
} else {
|
||||
if let windowScrollY = windowScrollY {
|
||||
webView.evaluateJavaScript("window.scrollTo(0, \(windowScrollY));")
|
||||
self.windowScrollY = nil
|
||||
}
|
||||
public func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||
// See note in loadView()
|
||||
guard waitingForFirstReload else {
|
||||
return
|
||||
}
|
||||
|
||||
assert(webView.isHidden)
|
||||
waitingForFirstReload = false
|
||||
reloadHTML()
|
||||
|
||||
// Waiting for the first navigation to commit isn't enough to avoid the flash of white.
|
||||
// Delaying an additional half a second seems to be enough.
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
webView.isHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
guard let windowScrollY else {
|
||||
return
|
||||
}
|
||||
webView.evaluateJavaScript("window.scrollTo(0, \(windowScrollY));")
|
||||
self.windowScrollY = nil
|
||||
}
|
||||
|
||||
// WKUIDelegate
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// DetailWindowState.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 12/16/23.
|
||||
// Copyright © 2023 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class DetailWindowState: NSObject, NSSecureCoding {
|
||||
|
||||
static let supportsSecureCoding = true
|
||||
|
||||
let isShowingExtractedArticle: Bool
|
||||
let windowScrollY: CGFloat
|
||||
|
||||
init(isShowingExtractedArticle: Bool, windowScrollY: CGFloat) {
|
||||
self.isShowingExtractedArticle = isShowingExtractedArticle
|
||||
self.windowScrollY = windowScrollY
|
||||
}
|
||||
|
||||
private struct Key {
|
||||
static let isShowingExtractedArticle = "isShowingExtractedArticle"
|
||||
static let windowScrollY = "windowScrollY"
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
isShowingExtractedArticle = coder.decodeBool(forKey: Key.isShowingExtractedArticle)
|
||||
windowScrollY = CGFloat(coder.decodeDouble(forKey: Key.windowScrollY))
|
||||
}
|
||||
|
||||
func encode(with coder: NSCoder) {
|
||||
coder.encode(isShowingExtractedArticle, forKey: Key.isShowingExtractedArticle)
|
||||
coder.encode(Double(windowScrollY), forKey: Key.windowScrollY)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class LegacyArticleExtractorButton: NSButton {
|
||||
final class LegacyArticleExtractorButton: NSButton {
|
||||
|
||||
var isError = false {
|
||||
didSet {
|
||||
|
||||
@@ -16,7 +16,7 @@ enum TimelineSourceMode {
|
||||
case regular, search
|
||||
}
|
||||
|
||||
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
final class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
|
||||
@IBOutlet weak var articleThemePopUpButton: NSPopUpButton?
|
||||
|
||||
@@ -131,17 +131,24 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
}
|
||||
|
||||
func saveStateToUserDefaults() {
|
||||
AppDefaults.shared.windowState = savableState()
|
||||
let data = try? NSKeyedArchiver.archivedData(withRootObject: savableState(), requiringSecureCoding: true)
|
||||
AppDefaults.shared.secureWindowState = data
|
||||
window?.saveFrame(usingName: windowAutosaveName)
|
||||
}
|
||||
|
||||
func restoreStateFromUserDefaults() {
|
||||
if let state = AppDefaults.shared.windowState {
|
||||
if let data = AppDefaults.shared.secureWindowState,
|
||||
let state = try? NSKeyedUnarchiver.unarchivedObject(ofClass: MainWindowState.self, from: data) {
|
||||
restoreState(from: state)
|
||||
window?.setFrameUsingName(windowAutosaveName, force: true)
|
||||
} else if let state = AppDefaults.shared.legacyWindowState {
|
||||
// Migrate from previous window state data. Delete data when finished.
|
||||
restoreLegacyState(from: state)
|
||||
window?.setFrameUsingName(windowAutosaveName, force: true)
|
||||
AppDefaults.shared.deleteLegacyWindowState()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func refreshProgressDidChange(_ note: Notification) {
|
||||
@@ -291,19 +298,34 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
detailViewController.scrollPageUp(sender)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@IBAction func copyArticleURL(_ sender: Any?) {
|
||||
if let link = oneSelectedArticle?.preferredURL?.absoluteString {
|
||||
URLPasteboardWriter.write(urlString: link, to: .general)
|
||||
guard let articles = selectedArticles else {
|
||||
assertionFailure("Expected selectedArticles to be non-nil")
|
||||
return
|
||||
}
|
||||
let links = articles.compactMap { $0.preferredLink }
|
||||
if links.isEmpty {
|
||||
assertionFailure("Expected at least one link")
|
||||
return
|
||||
}
|
||||
|
||||
URLPasteboardWriter.write(urlStrings: links, to: .general)
|
||||
}
|
||||
|
||||
@IBAction func copyExternalURL(_ sender: Any?) {
|
||||
if let link = oneSelectedArticle?.externalLink {
|
||||
URLPasteboardWriter.write(urlString: link, to: .general)
|
||||
guard let articles = selectedArticles else {
|
||||
assertionFailure("Expected selectedArticles to be non-nil")
|
||||
return
|
||||
}
|
||||
let links = articles.compactMap { $0.externalLink }
|
||||
if links.isEmpty {
|
||||
assertionFailure("Expected at least one link")
|
||||
return
|
||||
}
|
||||
|
||||
URLPasteboardWriter.write(urlStrings: links, to: .general)
|
||||
}
|
||||
|
||||
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
||||
@@ -531,7 +553,7 @@ extension MainWindowController: NSWindowDelegate {
|
||||
}
|
||||
|
||||
func window(_ window: NSWindow, didDecodeRestorableState coder: NSCoder) {
|
||||
guard let state = try? coder.decodeTopLevelObject(forKey: UserInfoKey.windowState) as? [AnyHashable : Any] else { return }
|
||||
guard let state = coder.decodeObject(of: MainWindowState.self, forKey: UserInfoKey.windowState) else { return }
|
||||
restoreState(from: state)
|
||||
}
|
||||
|
||||
@@ -950,44 +972,95 @@ private extension MainWindowController {
|
||||
|
||||
// MARK: - State Restoration
|
||||
|
||||
func savableState() -> [AnyHashable : Any] {
|
||||
var state = [AnyHashable : Any]()
|
||||
state[UserInfoKey.windowFullScreenState] = window?.styleMask.contains(.fullScreen) ?? false
|
||||
saveSplitViewState(to: &state)
|
||||
sidebarViewController?.saveState(to: &state)
|
||||
timelineContainerViewController?.saveState(to: &state)
|
||||
detailViewController?.saveState(to: &state)
|
||||
return state
|
||||
func savableState() -> MainWindowState {
|
||||
let isFullScreen = window?.styleMask.contains(.fullScreen) ?? false
|
||||
|
||||
let splitViewWidths: [Int]
|
||||
if let splitView = splitViewController?.splitView {
|
||||
splitViewWidths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) }
|
||||
} else {
|
||||
splitViewWidths = []
|
||||
}
|
||||
|
||||
let isSidebarHidden = sidebarSplitViewItem?.isCollapsed ?? false
|
||||
|
||||
return MainWindowState(isFullScreen: isFullScreen,
|
||||
splitViewWidths: splitViewWidths,
|
||||
isSidebarHidden: isSidebarHidden,
|
||||
sidebarWindowState: sidebarViewController?.windowState,
|
||||
timelineWindowState: timelineContainerViewController?.windowState,
|
||||
detailWindowState: detailViewController?.windowState)
|
||||
}
|
||||
|
||||
func restoreState(from state: [AnyHashable : Any]) {
|
||||
if let fullScreen = state[UserInfoKey.windowFullScreenState] as? Bool, fullScreen {
|
||||
func restoreState(from state: MainWindowState) {
|
||||
if state.isFullScreen {
|
||||
window?.toggleFullScreen(self)
|
||||
}
|
||||
restoreSplitViewState(from: state)
|
||||
|
||||
sidebarViewController?.restoreState(from: state)
|
||||
sidebarViewController?.restoreState(from: state.sidebarWindowState)
|
||||
|
||||
timelineContainerViewController?.restoreState(from: state.timelineWindowState)
|
||||
restoreArticleWindowScrollY = state.detailWindowState?.windowScrollY
|
||||
|
||||
let isShowingExtractedArticle = state.detailWindowState?.isShowingExtractedArticle ?? false
|
||||
if isShowingExtractedArticle {
|
||||
startArticleExtractorForCurrentLink()
|
||||
}
|
||||
}
|
||||
|
||||
/// Restore state using pre-secure-state-restoration data.
|
||||
///
|
||||
/// It’s up to the caller to call this only when:
|
||||
/// 1. Legacy state exists, and
|
||||
/// 2. Secure state data does not exist.
|
||||
///
|
||||
/// TODO: delete this for NetNewsWire 7.
|
||||
func restoreLegacyState(from state: [AnyHashable: Any]) {
|
||||
if let fullScreen = state[UserInfoKey.windowFullScreenState] as? Bool, fullScreen {
|
||||
window?.toggleFullScreen(self)
|
||||
}
|
||||
restoreLegacySplitViewState(from: state)
|
||||
|
||||
sidebarViewController?.restoreLegacyState(from: state)
|
||||
|
||||
let articleWindowScrollY = state[UserInfoKey.articleWindowScrollY] as? CGFloat
|
||||
restoreArticleWindowScrollY = articleWindowScrollY
|
||||
timelineContainerViewController?.restoreState(from: state)
|
||||
|
||||
timelineContainerViewController?.restoreLegacyState(from: state)
|
||||
|
||||
let isShowingExtractedArticle = state[UserInfoKey.isShowingExtractedArticle] as? Bool ?? false
|
||||
if isShowingExtractedArticle {
|
||||
restoreArticleWindowScrollY = articleWindowScrollY
|
||||
startArticleExtractorForCurrentLink()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Command Validation
|
||||
|
||||
func canCopyArticleURL() -> Bool {
|
||||
return currentLink != nil
|
||||
guard let selectedArticles else {
|
||||
return false
|
||||
}
|
||||
|
||||
for article in selectedArticles {
|
||||
if article.preferredLink != nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func canCopyExternalURL() -> Bool {
|
||||
return oneSelectedArticle?.externalLink != nil && oneSelectedArticle?.externalLink != currentLink
|
||||
guard let selectedArticles else {
|
||||
return false
|
||||
}
|
||||
|
||||
for article in selectedArticles {
|
||||
if article.externalLink != nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool {
|
||||
@@ -1238,23 +1311,38 @@ private extension MainWindowController {
|
||||
}
|
||||
}
|
||||
|
||||
func saveSplitViewState(to state: inout [AnyHashable : Any]) {
|
||||
guard let splitView = splitViewController?.splitView else {
|
||||
func restoreSplitViewState(from state: MainWindowState) {
|
||||
guard let splitView = splitViewController?.splitView,
|
||||
state.splitViewWidths.count == 3,
|
||||
let window = window else {
|
||||
return
|
||||
}
|
||||
|
||||
let widths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) }
|
||||
state[MainWindowController.mainWindowWidthsStateKey] = widths
|
||||
|
||||
state[UserInfoKey.isSidebarHidden] = sidebarSplitViewItem?.isCollapsed
|
||||
let windowWidth = Int(floor(window.frame.width))
|
||||
let dividerThickness: Int = Int(splitView.dividerThickness)
|
||||
let sidebarWidth: Int = state.splitViewWidths[0]
|
||||
let timelineWidth: Int = state.splitViewWidths[1]
|
||||
|
||||
// Make sure the detail view has its minimum thickness, at least.
|
||||
if windowWidth < sidebarWidth + dividerThickness + timelineWidth + dividerThickness + MainWindowController.detailViewMinimumThickness {
|
||||
return
|
||||
}
|
||||
|
||||
splitView.setPosition(CGFloat(sidebarWidth), ofDividerAt: 0)
|
||||
splitView.setPosition(CGFloat(sidebarWidth + dividerThickness + timelineWidth), ofDividerAt: 1)
|
||||
|
||||
sidebarSplitViewItem?.isCollapsed = state.isSidebarHidden
|
||||
}
|
||||
|
||||
func restoreSplitViewState(from state: [AnyHashable : Any]) {
|
||||
/// Restore main window split view using legacy state restoration data.
|
||||
///
|
||||
/// TODO: Delete this for NetNewsWire 7.
|
||||
func restoreLegacySplitViewState(from state: [AnyHashable: Any]) {
|
||||
guard let splitView = splitViewController?.splitView,
|
||||
let widths = state[MainWindowController.mainWindowWidthsStateKey] as? [Int],
|
||||
widths.count == 3,
|
||||
let window = window else {
|
||||
return
|
||||
let widths = state[MainWindowController.mainWindowWidthsStateKey] as? [Int],
|
||||
widths.count == 3,
|
||||
let window = window else {
|
||||
return
|
||||
}
|
||||
|
||||
let windowWidth = Int(floor(window.frame.width))
|
||||
@@ -1269,9 +1357,9 @@ private extension MainWindowController {
|
||||
|
||||
splitView.setPosition(CGFloat(sidebarWidth), ofDividerAt: 0)
|
||||
splitView.setPosition(CGFloat(sidebarWidth + dividerThickness + timelineWidth), ofDividerAt: 1)
|
||||
|
||||
|
||||
let isSidebarHidden = state[UserInfoKey.isSidebarHidden] as? Bool ?? false
|
||||
|
||||
|
||||
if !(sidebarSplitViewItem?.isCollapsed ?? false) && isSidebarHidden {
|
||||
sidebarSplitViewItem?.isCollapsed = true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// MainWindowState.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 12/16/23.
|
||||
// Copyright © 2023 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class MainWindowState: NSObject, NSSecureCoding {
|
||||
|
||||
static let supportsSecureCoding = true
|
||||
|
||||
let isFullScreen: Bool
|
||||
let splitViewWidths: [Int]
|
||||
let isSidebarHidden: Bool
|
||||
let sidebarWindowState: SidebarWindowState?
|
||||
let timelineWindowState: TimelineWindowState?
|
||||
let detailWindowState: DetailWindowState?
|
||||
|
||||
init(isFullScreen: Bool, splitViewWidths: [Int], isSidebarHidden: Bool, sidebarWindowState: SidebarWindowState? = nil, timelineWindowState: TimelineWindowState? = nil, detailWindowState: DetailWindowState? = nil) {
|
||||
self.isFullScreen = isFullScreen
|
||||
self.splitViewWidths = splitViewWidths
|
||||
self.isSidebarHidden = isSidebarHidden
|
||||
self.sidebarWindowState = sidebarWindowState
|
||||
self.timelineWindowState = timelineWindowState
|
||||
self.detailWindowState = detailWindowState
|
||||
}
|
||||
|
||||
private struct Key {
|
||||
static let isFullScreen = "isFullScreen"
|
||||
static let splitViewWidths = "splitViewWidths"
|
||||
static let isSidebarHidden = "isSidebarHidden"
|
||||
static let sidebarWindowState = "sidebarWindowState"
|
||||
static let timelineWindowState = "timelineWindowState"
|
||||
static let detailWindowState = "detailWindowState"
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
isFullScreen = coder.decodeBool(forKey: Key.isFullScreen)
|
||||
splitViewWidths = coder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: Key.splitViewWidths) as? [Int] ?? []
|
||||
isSidebarHidden = coder.decodeBool(forKey: Key.isSidebarHidden)
|
||||
sidebarWindowState = coder.decodeObject(of: SidebarWindowState.self, forKey: Key.sidebarWindowState)
|
||||
timelineWindowState = coder.decodeObject(of: TimelineWindowState.self, forKey: Key.timelineWindowState)
|
||||
detailWindowState = coder.decodeObject(of: DetailWindowState.self, forKey: Key.detailWindowState)
|
||||
}
|
||||
|
||||
func encode(with coder: NSCoder) {
|
||||
coder.encode(isFullScreen, forKey: Key.isFullScreen)
|
||||
coder.encode(splitViewWidths, forKey: Key.splitViewWidths)
|
||||
coder.encode(isSidebarHidden, forKey: Key.isSidebarHidden)
|
||||
coder.encode(sidebarWindowState, forKey: Key.sidebarWindowState)
|
||||
coder.encode(timelineWindowState, forKey: Key.timelineWindowState)
|
||||
coder.encode(detailWindowState, forKey: Key.detailWindowState)
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import AppKit
|
||||
import Account
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class ExportOPMLWindowController: NSWindowController {
|
||||
final class ExportOPMLWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var accountPopUpButton: NSPopUpButton!
|
||||
private weak var hostWindow: NSWindow?
|
||||
@@ -42,16 +42,18 @@ class ExportOPMLWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
|
||||
if AccountManager.shared.accounts.count == 1 {
|
||||
let account = AccountManager.shared.accounts.first!
|
||||
exportOPML(account: account)
|
||||
} else {
|
||||
hostWindow.beginSheet(window!)
|
||||
hostWindow.beginSheet(window)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -10,7 +10,7 @@ import AppKit
|
||||
import Account
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class ImportOPMLWindowController: NSWindowController {
|
||||
final class ImportOPMLWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var accountPopUpButton: NSPopUpButton!
|
||||
private weak var hostWindow: NSWindow?
|
||||
@@ -46,16 +46,18 @@ class ImportOPMLWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
|
||||
if AccountManager.shared.activeAccounts.count == 1 {
|
||||
let account = AccountManager.shared.activeAccounts.first!
|
||||
importOPML(account: account)
|
||||
} else {
|
||||
hostWindow.beginSheet(window!)
|
||||
hostWindow.beginSheet(window)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -11,7 +11,7 @@ import RSCore
|
||||
import Account
|
||||
import RSTree
|
||||
|
||||
class SidebarCell : NSTableCellView {
|
||||
final class SidebarCell : NSTableCellView {
|
||||
|
||||
var iconImage: IconImage? {
|
||||
didSet {
|
||||
|
||||
@@ -10,7 +10,7 @@ import AppKit
|
||||
import RSCore
|
||||
import RSTree
|
||||
|
||||
class SidebarOutlineView : NSOutlineView {
|
||||
final class SidebarOutlineView : NSOutlineView {
|
||||
|
||||
@IBOutlet var keyboardDelegate: KeyboardDelegate!
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ protocol SidebarDelegate: AnyObject {
|
||||
func sidebarInvalidatedRestorationState(_: SidebarViewController)
|
||||
}
|
||||
|
||||
@objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSMenuDelegate, UndoableCommandRunner {
|
||||
@objc final class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSMenuDelegate, UndoableCommandRunner {
|
||||
|
||||
@IBOutlet weak var outlineView: NSOutlineView!
|
||||
|
||||
@@ -30,6 +30,12 @@ protocol SidebarDelegate: AnyObject {
|
||||
|
||||
weak var splitViewItem: NSSplitViewItem?
|
||||
|
||||
var windowState: SidebarWindowState {
|
||||
let expandedContainers = expandedTable.compactMap { $0.userInfo as? [String: String] }
|
||||
let selectedFeeds = selectedFeeds.compactMap { $0.feedID?.userInfo as? [String: String] }
|
||||
return SidebarWindowState(isReadFiltered: isReadFiltered, expandedContainers: expandedContainers, selectedFeeds: selectedFeeds)
|
||||
}
|
||||
|
||||
private let rebuildTreeAndRestoreSelectionQueue = CoalescingQueue(name: "Rebuild Tree Queue", interval: 1.0)
|
||||
let treeControllerDelegate = WebFeedTreeControllerDelegate()
|
||||
lazy var treeController: TreeController = {
|
||||
@@ -96,14 +102,39 @@ protocol SidebarDelegate: AnyObject {
|
||||
|
||||
// MARK: State Restoration
|
||||
|
||||
func saveState(to state: inout [AnyHashable : Any]) {
|
||||
state[UserInfoKey.readFeedsFilterState] = isReadFiltered
|
||||
state[UserInfoKey.containerExpandedWindowState] = expandedTable.map { $0.userInfo }
|
||||
state[UserInfoKey.selectedFeedsState] = selectedFeeds.compactMap { $0.feedID?.userInfo }
|
||||
}
|
||||
|
||||
func restoreState(from state: [AnyHashable : Any]) {
|
||||
func restoreState(from state: SidebarWindowState?) {
|
||||
guard let state else { return }
|
||||
|
||||
let containerIdentifers = state.expandedContainers.compactMap( { ContainerIdentifier(userInfo: $0) })
|
||||
expandedTable = Set(containerIdentifers)
|
||||
|
||||
let selectedFeedIdentifers = Set(state.selectedFeeds.compactMap( { FeedIdentifier(userInfo: $0) }))
|
||||
selectedFeedIdentifers.forEach { treeControllerDelegate.addFilterException($0) }
|
||||
|
||||
rebuildTreeAndReloadDataIfNeeded()
|
||||
|
||||
var selectIndexes = IndexSet()
|
||||
|
||||
func selectFeedsVisitor(node: Node) {
|
||||
if let feedID = (node.representedObject as? FeedIdentifiable)?.feedID {
|
||||
if selectedFeedIdentifers.contains(feedID) {
|
||||
selectIndexes.insert(outlineView.row(forItem: node) )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
treeController.visitNodes(selectFeedsVisitor(node:))
|
||||
outlineView.selectRowIndexes(selectIndexes, byExtendingSelection: false)
|
||||
focus()
|
||||
|
||||
isReadFiltered = state.isReadFiltered
|
||||
}
|
||||
|
||||
/// Restore state using legacy state restoration data.
|
||||
///
|
||||
/// TODO: Delete for NetNewsWire 7.
|
||||
func restoreLegacyState(from state: [AnyHashable : Any]) {
|
||||
|
||||
if let containerExpandedWindowState = state[UserInfoKey.containerExpandedWindowState] as? [[AnyHashable: AnyHashable]] {
|
||||
let containerIdentifiers = containerExpandedWindowState.compactMap( { ContainerIdentifier(userInfo: $0) })
|
||||
expandedTable = Set(containerIdentifiers)
|
||||
@@ -115,9 +146,9 @@ protocol SidebarDelegate: AnyObject {
|
||||
|
||||
let selectedFeedIdentifiers = Set(selectedFeedsState.compactMap( { FeedIdentifier(userInfo: $0) }))
|
||||
selectedFeedIdentifiers.forEach { treeControllerDelegate.addFilterException($0) }
|
||||
|
||||
|
||||
rebuildTreeAndReloadDataIfNeeded()
|
||||
|
||||
|
||||
var selectIndexes = IndexSet()
|
||||
|
||||
func selectFeedsVisitor(node: Node) {
|
||||
@@ -131,12 +162,12 @@ protocol SidebarDelegate: AnyObject {
|
||||
treeController.visitNodes(selectFeedsVisitor(node:))
|
||||
outlineView.selectRowIndexes(selectIndexes, byExtendingSelection: false)
|
||||
focus()
|
||||
|
||||
|
||||
if let readFeedsFilterState = state[UserInfoKey.readFeedsFilterState] as? Bool {
|
||||
isReadFiltered = readFeedsFilterState
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func unreadCountDidInitialize(_ notification: Notification) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SidebarWindowState.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 12/16/23.
|
||||
// Copyright © 2023 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class SidebarWindowState: NSObject, NSSecureCoding {
|
||||
|
||||
static let supportsSecureCoding = true
|
||||
|
||||
let isReadFiltered: Bool
|
||||
let expandedContainers: [[String: String]]
|
||||
let selectedFeeds: [[String: String]]
|
||||
|
||||
init(isReadFiltered: Bool, expandedContainers: [[String : String]], selectedFeeds: [[String : String]]) {
|
||||
self.isReadFiltered = isReadFiltered
|
||||
self.expandedContainers = expandedContainers
|
||||
self.selectedFeeds = selectedFeeds
|
||||
}
|
||||
|
||||
private struct Key {
|
||||
static let isReadFiltered = "isReadFiltered"
|
||||
static let expandedContainers = "expandedContainers"
|
||||
static let selectedFeeds = "selectedFeeds"
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
isReadFiltered = coder.decodeBool(forKey: Key.isReadFiltered)
|
||||
expandedContainers = coder.decodeObject(of: [NSArray.self, NSDictionary.self, NSString.self], forKey: Key.expandedContainers) as? [[String: String]] ?? []
|
||||
selectedFeeds = coder.decodeObject(of: [NSArray.self, NSDictionary.self, NSString.self], forKey: Key.selectedFeeds) as? [[String: String]] ?? []
|
||||
}
|
||||
|
||||
func encode(with coder: NSCoder) {
|
||||
coder.encode(isReadFiltered, forKey: Key.isReadFiltered)
|
||||
coder.encode(expandedContainers, forKey: Key.expandedContainers)
|
||||
coder.encode(selectedFeeds, forKey: Key.selectedFeeds)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
|
||||
class UnreadCountView : NSView {
|
||||
final class UnreadCountView : NSView {
|
||||
|
||||
struct Appearance {
|
||||
static let padding = NSEdgeInsets(top: 1.0, left: 7.0, bottom: 1.0, right: 7.0)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import AppKit
|
||||
import RSCore
|
||||
|
||||
class TimelineTableCellView: NSTableCellView {
|
||||
final class TimelineTableCellView: NSTableCellView {
|
||||
|
||||
private let titleView = TimelineTableCellView.multiLineTextField()
|
||||
private let summaryView = TimelineTableCellView.multiLineTextField()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
|
||||
class UnreadIndicatorView: NSView {
|
||||
final class UnreadIndicatorView: NSView {
|
||||
|
||||
static let unreadCircleDimension: CGFloat = 8.0
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@ final class TimelineContainerViewController: NSViewController {
|
||||
view?.window?.recalculateKeyViewLoop()
|
||||
}
|
||||
}
|
||||
|
||||
var windowState: TimelineWindowState? {
|
||||
return currentTimelineViewController?.windowState
|
||||
}
|
||||
|
||||
weak var delegate: TimelineContainerViewControllerDelegate?
|
||||
|
||||
@@ -127,14 +131,20 @@ final class TimelineContainerViewController: NSViewController {
|
||||
|
||||
// MARK: State Restoration
|
||||
|
||||
func saveState(to state: inout [AnyHashable : Any]) {
|
||||
regularTimelineViewController.saveState(to: &state)
|
||||
}
|
||||
|
||||
func restoreState(from state: [AnyHashable : Any]) {
|
||||
func restoreState(from state: TimelineWindowState?) {
|
||||
guard let state else { return }
|
||||
|
||||
regularTimelineViewController.restoreState(from: state)
|
||||
updateReadFilterButton()
|
||||
}
|
||||
|
||||
/// Restore state using legacy state restoration data.
|
||||
///
|
||||
/// TODO: Delete for NetNewsWire 7.
|
||||
func restoreLegacyState(from state: [AnyHashable: Any]) {
|
||||
regularTimelineViewController.restoreLegacyState(from: state)
|
||||
updateReadFilterButton()
|
||||
}
|
||||
}
|
||||
|
||||
extension TimelineContainerViewController: TimelineDelegate {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
|
||||
class TimelineTableRowView : NSTableRowView {
|
||||
final class TimelineTableRowView : NSTableRowView {
|
||||
|
||||
private var separator: NSView?
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import AppKit
|
||||
import RSCore
|
||||
|
||||
class TimelineTableView: NSTableView {
|
||||
final class TimelineTableView: NSTableView {
|
||||
|
||||
weak var keyboardDelegate: KeyboardDelegate?
|
||||
|
||||
|
||||
@@ -72,14 +72,22 @@ extension TimelineViewController {
|
||||
}
|
||||
|
||||
@objc func markAllInFeedAsRead(_ sender: Any?) {
|
||||
guard let menuItem = sender as? NSMenuItem, let feedArticles = menuItem.representedObject as? ArticleArray else {
|
||||
guard let menuItem = sender as? NSMenuItem,
|
||||
let feed = menuItem.representedObject as? WebFeed else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: feedArticles, markingRead: true, undoManager: undoManager) else {
|
||||
|
||||
guard let unreadArticles = try? feed.fetchUnreadArticles(), !unreadArticles.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let undoManager, let markReadCommand = MarkStatusCommand(
|
||||
initialArticles: Array(unreadArticles),
|
||||
markingRead: true,
|
||||
undoManager: undoManager
|
||||
) else {
|
||||
return
|
||||
}
|
||||
|
||||
runCommand(markReadCommand)
|
||||
}
|
||||
|
||||
@@ -255,18 +263,14 @@ private extension TimelineViewController {
|
||||
}
|
||||
|
||||
func markAllAsReadMenuItem(_ feed: WebFeed) -> NSMenuItem? {
|
||||
guard let articlesSet = try? feed.fetchArticles() else {
|
||||
return nil
|
||||
}
|
||||
let articles = Array(articlesSet)
|
||||
guard articles.canMarkAllAsRead() else {
|
||||
guard feed.unreadCount > 0 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let menuText = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
|
||||
|
||||
return menuItem(menuText, #selector(markAllInFeedAsRead(_:)), articles, image: AppAssets.markAllAsReadImage)
|
||||
return menuItem(menuText, #selector(markAllInFeedAsRead(_:)), feed, image: AppAssets.markAllAsReadImage)
|
||||
}
|
||||
|
||||
func openInBrowserMenuItem(_ urlString: String) -> NSMenuItem {
|
||||
|
||||
@@ -80,6 +80,24 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
}
|
||||
}
|
||||
|
||||
var windowState: TimelineWindowState {
|
||||
let readArticlesFilterStateKeys = readFilterEnabledTable.keys.compactMap { $0.userInfo as? [String: String] }
|
||||
let readArticlesFilterStateValues = readFilterEnabledTable.values.compactMap( { $0 })
|
||||
|
||||
if selectedArticles.count == 1 {
|
||||
let path = selectedArticles.first!.pathUserInfo
|
||||
return TimelineWindowState(readArticlesFilterStateKeys: readArticlesFilterStateKeys,
|
||||
readArticlesFilterStateValues: readArticlesFilterStateValues,
|
||||
selectedAccountID: path[ArticlePathKey.accountID] as? String,
|
||||
selectedArticleID: path[ArticlePathKey.articleID] as? String)
|
||||
} else {
|
||||
return TimelineWindowState(readArticlesFilterStateKeys: readArticlesFilterStateKeys,
|
||||
readArticlesFilterStateValues: readArticlesFilterStateValues,
|
||||
selectedAccountID: nil,
|
||||
selectedArticleID: nil)
|
||||
}
|
||||
|
||||
}
|
||||
weak var delegate: TimelineDelegate?
|
||||
var sharingServiceDelegate: NSSharingServiceDelegate?
|
||||
|
||||
@@ -192,6 +210,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
private let keyboardDelegate = TimelineKeyboardDelegate()
|
||||
private var timelineShowsSeparatorsObserver: NSKeyValueObservation?
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "TimelineViewController")
|
||||
|
||||
convenience init(delegate: TimelineDelegate) {
|
||||
self.init(nibName: "TimelineTableView", bundle: nil)
|
||||
self.delegate = delegate
|
||||
@@ -269,16 +289,36 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
|
||||
// MARK: State Restoration
|
||||
|
||||
func saveState(to state: inout [AnyHashable : Any]) {
|
||||
state[UserInfoKey.readArticlesFilterStateKeys] = readFilterEnabledTable.keys.compactMap { $0.userInfo }
|
||||
state[UserInfoKey.readArticlesFilterStateValues] = readFilterEnabledTable.values.compactMap( { $0 })
|
||||
func restoreState(from state: TimelineWindowState) {
|
||||
for i in 0..<state.readArticlesFilterStateKeys.count {
|
||||
if let feedIdentifier = FeedIdentifier(userInfo: state.readArticlesFilterStateKeys[i]) {
|
||||
readFilterEnabledTable[feedIdentifier] = state.readArticlesFilterStateValues[i]
|
||||
}
|
||||
}
|
||||
|
||||
if selectedArticles.count == 1 {
|
||||
state[UserInfoKey.articlePath] = selectedArticles.first!.pathUserInfo
|
||||
if let selectedAccountID = state.selectedAccountID,
|
||||
let account = AccountManager.shared.existingAccount(with: selectedAccountID),
|
||||
let selectedArticleID = state.selectedArticleID {
|
||||
|
||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: selectedArticleID)
|
||||
fetchAndReplaceArticlesSync()
|
||||
|
||||
if let selectedIndex = articles.firstIndex(where: { $0.articleID == selectedArticleID }) {
|
||||
tableView.selectRow(selectedIndex)
|
||||
DispatchQueue.main.async {
|
||||
self.tableView.scrollTo(row: selectedIndex)
|
||||
}
|
||||
focus()
|
||||
}
|
||||
} else {
|
||||
fetchAndReplaceArticlesSync()
|
||||
}
|
||||
}
|
||||
|
||||
func restoreState(from state: [AnyHashable : Any]) {
|
||||
|
||||
/// Restore state using legacy state restoration data.
|
||||
///
|
||||
/// TODO: Delete for NetNewsWire 7.
|
||||
func restoreLegacyState(from state: [AnyHashable: Any]) {
|
||||
guard let readArticlesFilterStateKeys = state[UserInfoKey.readArticlesFilterStateKeys] as? [[AnyHashable: AnyHashable]],
|
||||
let readArticlesFilterStateValues = state[UserInfoKey.readArticlesFilterStateValues] as? [Bool] else {
|
||||
return
|
||||
@@ -289,15 +329,15 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
readFilterEnabledTable[feedIdentifier] = readArticlesFilterStateValues[i]
|
||||
}
|
||||
}
|
||||
|
||||
if let articlePathUserInfo = state[UserInfoKey.articlePath] as? [AnyHashable : Any],
|
||||
|
||||
if let articlePathUserInfo = state[UserInfoKey.articlePath] as? [AnyHashable: Any],
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
let account = AccountManager.shared.existingAccount(with: accountID),
|
||||
let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String {
|
||||
|
||||
|
||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: articleID)
|
||||
fetchAndReplaceArticlesSync()
|
||||
|
||||
|
||||
if let selectedIndex = articles.firstIndex(where: { $0.articleID == articleID }) {
|
||||
tableView.selectRow(selectedIndex)
|
||||
DispatchQueue.main.async {
|
||||
@@ -305,15 +345,12 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
}
|
||||
focus()
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
fetchAndReplaceArticlesSync()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@objc func openArticleInBrowser(_ sender: Any?) {
|
||||
@@ -724,7 +761,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
let longTitle = "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
|
||||
let prototypeID = "prototype"
|
||||
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
|
||||
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, webFeedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
|
||||
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, webFeedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, markdown: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status)
|
||||
|
||||
let prototypeCellData = TimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false)
|
||||
let height = TimelineCellLayout.height(for: 100, cellData: prototypeCellData, appearance: cellAppearance)
|
||||
@@ -943,7 +980,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
return [action]
|
||||
|
||||
@unknown default:
|
||||
os_log(.error, "Unknown table row edge: %ld", edge.rawValue)
|
||||
Self.logger.error("TimelineViewController: unknown edge \(edge.rawValue, privacy: .public)")
|
||||
}
|
||||
|
||||
return []
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// TimelineWindowState.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 12/16/23.
|
||||
// Copyright © 2023 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class TimelineWindowState: NSObject, NSSecureCoding {
|
||||
|
||||
static let supportsSecureCoding = true
|
||||
|
||||
let readArticlesFilterStateKeys: [[String: String]]
|
||||
let readArticlesFilterStateValues: [Bool]
|
||||
let selectedAccountID: String?
|
||||
let selectedArticleID: String?
|
||||
|
||||
init(readArticlesFilterStateKeys: [[String : String]], readArticlesFilterStateValues: [Bool], selectedAccountID: String? = nil, selectedArticleID: String? = nil) {
|
||||
self.readArticlesFilterStateKeys = readArticlesFilterStateKeys
|
||||
self.readArticlesFilterStateValues = readArticlesFilterStateValues
|
||||
self.selectedAccountID = selectedAccountID
|
||||
self.selectedArticleID = selectedArticleID
|
||||
}
|
||||
|
||||
private struct Key {
|
||||
static let readArticlesFilterStateKeys = "readArticlesFilterStateKeys"
|
||||
static let readArticlesFilterStateValues = "readArticlesFilterStateValues"
|
||||
static let selectedAccountID = "selectedAccountID"
|
||||
static let selectedArticleID = "selectedArticleID"
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
readArticlesFilterStateKeys = coder.decodeObject(of: [NSArray.self, NSDictionary.self, NSString.self], forKey: Key.readArticlesFilterStateKeys) as? [[String: String]] ?? []
|
||||
readArticlesFilterStateValues = coder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: Key.readArticlesFilterStateValues) as? [Bool] ?? []
|
||||
selectedAccountID = coder.decodeObject(of: NSString.self, forKey: Key.selectedAccountID) as? String
|
||||
selectedArticleID = coder.decodeObject(of: NSString.self, forKey: Key.selectedArticleID) as? String
|
||||
}
|
||||
|
||||
func encode(with coder: NSCoder) {
|
||||
coder.encode(readArticlesFilterStateKeys, forKey: Key.readArticlesFilterStateKeys)
|
||||
coder.encode(readArticlesFilterStateValues, forKey: Key.readArticlesFilterStateValues)
|
||||
coder.encode(selectedAccountID, forKey: Key.selectedAccountID)
|
||||
coder.encode(selectedArticleID, forKey: Key.selectedArticleID)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import AppKit
|
||||
|
||||
class AccountCell: NSTableCellView {
|
||||
final class AccountCell: NSTableCellView {
|
||||
|
||||
private var originalImage: NSImage?
|
||||
|
||||
|
||||
@@ -9,47 +9,51 @@
|
||||
import Foundation
|
||||
import Account
|
||||
|
||||
enum AccountsAddCloudKitWindowControllerError: LocalizedError {
|
||||
case iCloudDriveMissing
|
||||
|
||||
var errorDescription: String? {
|
||||
return NSLocalizedString("Unable to add iCloud Account. Please make sure you have iCloud and iCloud Drive enabled in System Preferences.", comment: "Unable to add iCloud Account.")
|
||||
}
|
||||
}
|
||||
|
||||
class AccountsAddCloudKitWindowController: NSWindowController {
|
||||
final class AccountsAddCloudKitWindowController: NSWindowController {
|
||||
|
||||
private weak var hostWindow: NSWindow?
|
||||
|
||||
convenience init() {
|
||||
self.init(windowNibName: NSNib.Name("AccountsAddCloudKit"))
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
}
|
||||
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!, completionHandler: completion)
|
||||
self.init(windowNibName: "AccountsAddCloudKit")
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
||||
// MARK: - API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
assert(window != nil)
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window, completionHandler: completion)
|
||||
}
|
||||
|
||||
@IBAction func create(_ sender: Any) {
|
||||
guard FileManager.default.ubiquityIdentityToken != nil else {
|
||||
NSApplication.shared.presentError(AccountsAddCloudKitWindowControllerError.iCloudDriveMissing)
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
assert(hostWindow != nil && window != nil)
|
||||
guard let hostWindow, let window else {
|
||||
return
|
||||
}
|
||||
|
||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
hostWindow.endSheet(window, returnCode: NSApplication.ModalResponse.cancel)
|
||||
}
|
||||
|
||||
@IBAction func create(_ sender: Any) {
|
||||
assert(!AccountManager.shared.hasiCloudAccount)
|
||||
|
||||
guard AddCloudKitAccountUtilities.isiCloudDriveEnabled else {
|
||||
presentError(AddCloudKitAccountError.iCloudDriveMissing)
|
||||
return
|
||||
}
|
||||
|
||||
assert(hostWindow != nil && window != nil)
|
||||
guard let hostWindow, let window else {
|
||||
return
|
||||
}
|
||||
|
||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||
hostWindow.endSheet(window, returnCode: NSApplication.ModalResponse.OK)
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
import AppKit
|
||||
import Account
|
||||
|
||||
class AccountsAddLocalWindowController: NSWindowController {
|
||||
final class AccountsAddLocalWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet private weak var nameTextField: NSTextField!
|
||||
@IBOutlet private weak var localAccountNameTextField: NSTextField!
|
||||
@@ -29,8 +29,12 @@ class AccountsAddLocalWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!)
|
||||
hostWindow.beginSheet(window)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -11,7 +11,7 @@ import Account
|
||||
import RSWeb
|
||||
import Secrets
|
||||
|
||||
class AccountsFeedbinWindowController: NSWindowController {
|
||||
final class AccountsFeedbinWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var signInTextField: NSTextField!
|
||||
@IBOutlet weak var noAccountTextField: NSTextField!
|
||||
@@ -50,8 +50,12 @@ class AccountsFeedbinWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!, completionHandler: completion)
|
||||
hostWindow.beginSheet(window, completionHandler: completion)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -11,7 +11,7 @@ import Account
|
||||
import RSWeb
|
||||
import Secrets
|
||||
|
||||
class AccountsNewsBlurWindowController: NSWindowController {
|
||||
final class AccountsNewsBlurWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var signInTextField: NSTextField!
|
||||
@IBOutlet weak var noAccountTextField: NSTextField!
|
||||
@@ -48,8 +48,12 @@ class AccountsNewsBlurWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!, completionHandler: completion)
|
||||
hostWindow.beginSheet(window, completionHandler: completion)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -244,7 +244,7 @@ private extension AccountsPreferencesViewController {
|
||||
if sortedAccounts.count == 0 {
|
||||
helpText = NSLocalizedString("Add an account by clicking the + button.", comment: "Add Account Explainer")
|
||||
} else {
|
||||
helpText = NSLocalizedString("Select an account or add a new account by clicking the + button.", comment: "Add Account Explainer")
|
||||
helpText = NSLocalizedString("To add an account to NetNewsWire,\nclick its icon above.\n\nOr click the + button in the lower left.", comment: "Add Account Explainer")
|
||||
}
|
||||
|
||||
let textHostingController = NSHostingController(rootView:
|
||||
|
||||
@@ -11,7 +11,7 @@ import Account
|
||||
import RSWeb
|
||||
import Secrets
|
||||
|
||||
class AccountsReaderAPIWindowController: NSWindowController {
|
||||
final class AccountsReaderAPIWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var titleImageView: NSImageView!
|
||||
@IBOutlet weak var titleLabel: NSTextField!
|
||||
@@ -79,8 +79,12 @@ class AccountsReaderAPIWindowController: NSWindowController {
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
guard let window else {
|
||||
return
|
||||
}
|
||||
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!, completionHandler: completion)
|
||||
hostWindow.beginSheet(window, completionHandler: completion)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@@ -14,19 +14,21 @@ struct AddAccountHelpView: View {
|
||||
let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent
|
||||
var delegate: AccountsPreferencesAddAccountDelegate?
|
||||
var helpText: String
|
||||
@State private var iCloudUnavailableError: Bool = false
|
||||
|
||||
|
||||
var hasiCloudAccount: Bool {
|
||||
AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit })
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
ForEach(accountTypes, id: \.self) { accountType in
|
||||
if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) {
|
||||
if accountType == .cloudKit && hasiCloudAccount {
|
||||
EmptyView()
|
||||
}
|
||||
else if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) {
|
||||
Button(action: {
|
||||
if accountType == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
|
||||
iCloudUnavailableError = true
|
||||
} else {
|
||||
delegate?.presentSheetForAccount(accountType)
|
||||
}
|
||||
delegate?.presentSheetForAccount(accountType)
|
||||
}, label: {
|
||||
accountType.image()
|
||||
.resizable()
|
||||
@@ -40,15 +42,6 @@ struct AddAccountHelpView: View {
|
||||
Text(helpText)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.top, 8)
|
||||
|
||||
}
|
||||
.alert(isPresented: $iCloudUnavailableError, content: {
|
||||
Alert(title: Text(NSLocalizedString("Error", comment: "Error")),
|
||||
message: Text(NSLocalizedString("You've already set up an iCloud account.", comment: "Error")),
|
||||
dismissButton: Alert.Button.cancel({
|
||||
iCloudUnavailableError = false
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -182,8 +182,8 @@ struct AddAccountsView: View {
|
||||
})
|
||||
})
|
||||
.offset(x: 7.5, y: 0)
|
||||
.disabled(isCloudInUse())
|
||||
|
||||
.disabled(AccountManager.shared.hasiCloudAccount)
|
||||
|
||||
Text(AddAccountSections.icloud.sectionFooter).foregroundColor(.gray)
|
||||
.padding(.horizontal)
|
||||
.lineLimit(3)
|
||||
@@ -258,15 +258,10 @@ struct AddAccountsView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
|
||||
private func isCloudInUse() -> Bool {
|
||||
AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit })
|
||||
}
|
||||
|
||||
|
||||
private func chunkedWebAccounts() -> [[AccountType]] {
|
||||
AddAccountSections.web.sectionContent.chunked(into: chunkLimit)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ private struct ToolbarItemIdentifier {
|
||||
static let Advanced = "Advanced"
|
||||
}
|
||||
|
||||
class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
|
||||
final class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
|
||||
|
||||
private let windowWidth = CGFloat(512.0) // Width is constant for all views; only the height changes
|
||||
private var viewControllers = [String: NSViewController]()
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>UIDesignRequiresCompatibility</key>
|
||||
<true/>
|
||||
<key>NSAutoFillRequiresTextContentTypeForOneTimeCodeOnMac</key>
|
||||
<true/>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
<element type="account">
|
||||
<cocoa key="accounts"/>
|
||||
</element>
|
||||
<element type="article">
|
||||
<cocoa key="selectedArticles"/>
|
||||
</element>
|
||||
<element type="webFeed">
|
||||
<synonym name="feed"/>
|
||||
<cocoa key="webFeeds"/>
|
||||
@@ -114,6 +117,10 @@
|
||||
<synonym name="feed"/>
|
||||
<cocoa key="webFeeds"/>
|
||||
</element>
|
||||
<element type="webFeed">
|
||||
<synonym name="allFeeds"/>
|
||||
<cocoa key="allWebFeeds"/>
|
||||
</element>
|
||||
<element type="folder">
|
||||
<cocoa key="folders"/>
|
||||
</element>
|
||||
@@ -186,6 +193,9 @@
|
||||
<synonym name="feed"/>
|
||||
<cocoa key="webFeeds"/>
|
||||
</element>
|
||||
<element type="article">
|
||||
<cocoa key="articles"/>
|
||||
</element>
|
||||
</class>
|
||||
|
||||
<class name="article" code="Arcl" plural="articles" description="An article in a feed">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import SafariServices
|
||||
|
||||
class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
final class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
|
||||
// Safari App Extensions don't support any reasonable means of detecting whether a
|
||||
// specific Safari page was loaded with the benefit of the extension's injected
|
||||
@@ -20,7 +20,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
// I tried to use a NSMapTable from String to the closure directly, but Swift
|
||||
// complains that the object has to be a class type.
|
||||
typealias ValidationHandler = (Bool, String) -> Void
|
||||
class ValidationWrapper {
|
||||
final class ValidationWrapper {
|
||||
let validationHandler: ValidationHandler
|
||||
|
||||
init(validationHandler: @escaping ValidationHandler) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import SafariServices
|
||||
|
||||
class SafariExtensionViewController: SFSafariExtensionViewController {
|
||||
final class SafariExtensionViewController: SFSafariExtensionViewController {
|
||||
|
||||
// This would be the place to handle a popover that could, for example, list the possibly multiple feeds offered by a site.
|
||||
static let shared: SafariExtensionViewController = {
|
||||
|
||||
@@ -12,7 +12,7 @@ import Articles
|
||||
import RSCore
|
||||
|
||||
@objc(ScriptableAccount)
|
||||
class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
final class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let account:Account
|
||||
init (_ account:Account) {
|
||||
@@ -99,6 +99,18 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
return account.topLevelWebFeeds.map { ScriptableWebFeed($0, container:self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfWebFeeds)
|
||||
func countOfWebFeeds() -> Int {
|
||||
return account.topLevelWebFeeds.count
|
||||
}
|
||||
|
||||
@objc(objectInWebFeedsAtIndex:)
|
||||
func objectInWebFeedsAtIndex(_ index: Int) -> ScriptableWebFeed? {
|
||||
let feeds = Array(account.topLevelWebFeeds)
|
||||
guard index >= 0 && index < feeds.count else { return nil }
|
||||
return ScriptableWebFeed(feeds[index], container: self)
|
||||
}
|
||||
|
||||
@objc(valueInWebFeedsWithUniqueID:)
|
||||
func valueInWebFeeds(withUniqueID id:String) -> ScriptableWebFeed? {
|
||||
guard let feed = account.existingWebFeed(withWebFeedID: id) else { return nil }
|
||||
@@ -119,6 +131,19 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
return folders.map { ScriptableFolder($0, container:self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfFolders)
|
||||
func countOfFolders() -> Int {
|
||||
return account.folders?.count ?? 0
|
||||
}
|
||||
|
||||
@objc(objectInFoldersAtIndex:)
|
||||
func objectInFoldersAtIndex(_ index: Int) -> ScriptableFolder? {
|
||||
let foldersSet = account.folders ?? Set<Folder>()
|
||||
let folders = Array(foldersSet)
|
||||
guard index >= 0 && index < folders.count else { return nil }
|
||||
return ScriptableFolder(folders[index], container: self)
|
||||
}
|
||||
|
||||
@objc(valueInFoldersWithUniqueID:)
|
||||
func valueInFolders(withUniqueID id:NSNumber) -> ScriptableFolder? {
|
||||
let folderId = id.intValue
|
||||
@@ -132,19 +157,36 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
|
||||
@objc(allWebFeeds)
|
||||
var allWebFeeds: NSArray {
|
||||
var webFeeds = [ScriptableWebFeed]()
|
||||
for webFeed in account.topLevelWebFeeds {
|
||||
webFeeds.append(ScriptableWebFeed(webFeed, container: self))
|
||||
let allFeeds = account.flattenedWebFeeds()
|
||||
let scriptableWebFeeds = allFeeds.map { webFeed in
|
||||
return ScriptableWebFeed(webFeed, container: self)
|
||||
}
|
||||
if let folders = account.folders {
|
||||
for folder in folders {
|
||||
let scriptableFolder = ScriptableFolder(folder, container: self)
|
||||
for webFeed in folder.topLevelWebFeeds {
|
||||
webFeeds.append(ScriptableWebFeed(webFeed, container: scriptableFolder))
|
||||
}
|
||||
}
|
||||
}
|
||||
return webFeeds as NSArray
|
||||
return scriptableWebFeeds as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfAllWebFeeds)
|
||||
func countOfAllWebFeeds() -> Int {
|
||||
return account.flattenedWebFeeds().count
|
||||
}
|
||||
|
||||
@objc(objectInAllWebFeedsAtIndex:)
|
||||
func objectInAllWebFeedsAtIndex(_ index: Int) -> ScriptableWebFeed? {
|
||||
let allFeeds = Array(account.flattenedWebFeeds())
|
||||
guard index >= 0 && index < allFeeds.count else { return nil }
|
||||
return ScriptableWebFeed(allFeeds[index], container: self)
|
||||
}
|
||||
|
||||
@objc(valueInAllWebFeedsWithUniqueID:)
|
||||
func valueInAllWebFeeds(withUniqueID id:String) -> ScriptableWebFeed? {
|
||||
guard let feed = account.existingWebFeed(withWebFeedID: id) else { return nil }
|
||||
return ScriptableWebFeed(feed, container:self)
|
||||
}
|
||||
|
||||
@objc(valueInAllWebFeedsWithName:)
|
||||
func valueInAllWebFeeds(withName name:String) -> ScriptableWebFeed? {
|
||||
let feeds = Array(account.flattenedWebFeeds())
|
||||
guard let feed = feeds.first(where:{$0.name == name}) else { return nil }
|
||||
return ScriptableWebFeed(feed, container:self)
|
||||
}
|
||||
|
||||
@objc(opmlRepresentation)
|
||||
|
||||
@@ -91,7 +91,7 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
}
|
||||
}
|
||||
|
||||
class NetNewsWireCreateElementCommand : NSCreateCommand {
|
||||
final class NetNewsWireCreateElementCommand : NSCreateCommand {
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
let classDescription = self.createClassDescription
|
||||
if (classDescription.className == "webFeed") {
|
||||
@@ -111,7 +111,7 @@ class NetNewsWireCreateElementCommand : NSCreateCommand {
|
||||
is ambiguity about whether specifiers are lists or single objects, the code switches
|
||||
based on which it is.
|
||||
*/
|
||||
class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
final class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
|
||||
/*
|
||||
delete(objectToDelete:, from container:)
|
||||
@@ -166,7 +166,7 @@ class NetNewsWireDeleteCommand : NSDeleteCommand {
|
||||
}
|
||||
}
|
||||
|
||||
class NetNewsWireExistsCommand : NSExistsCommand {
|
||||
final class NetNewsWireExistsCommand : NSExistsCommand {
|
||||
|
||||
// cocoa default behavior doesn't work here, because of cases where we define an object's property
|
||||
// to be another object type. e.g., 'permalink of the current article' parses as
|
||||
|
||||
@@ -11,7 +11,7 @@ import Account
|
||||
import Articles
|
||||
|
||||
@objc(ScriptableArticle)
|
||||
class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
final class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let article:Article
|
||||
let container:ScriptingObjectContainer
|
||||
@@ -143,11 +143,7 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
|
||||
@objc(feed)
|
||||
var feed: ScriptableWebFeed? {
|
||||
guard let parentFeed = self.article.webFeed,
|
||||
let account = parentFeed.account
|
||||
else { return nil }
|
||||
|
||||
return ScriptableWebFeed(parentFeed, container: ScriptableAccount(account))
|
||||
guard let parentFeed = self.article.webFeed else { return nil }
|
||||
return ScriptableWebFeed.scriptableWebFeed(for: parentFeed)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import Account
|
||||
import Articles
|
||||
|
||||
@objc(ScriptableAuthor)
|
||||
class ScriptableAuthor: NSObject, UniqueIdScriptingObject {
|
||||
final class ScriptableAuthor: NSObject, UniqueIdScriptingObject {
|
||||
|
||||
let author:Author
|
||||
let container:ScriptingObjectContainer
|
||||
|
||||
@@ -12,7 +12,7 @@ import Articles
|
||||
import RSCore
|
||||
|
||||
@objc(ScriptableFolder)
|
||||
class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
final class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let folder:Folder
|
||||
let container:ScriptingObjectContainer
|
||||
@@ -101,6 +101,41 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
return feeds.map { ScriptableWebFeed($0, container:self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(articles)
|
||||
var articles:NSArray {
|
||||
let feeds = Array(folder.topLevelWebFeeds)
|
||||
let allArticles = feeds.flatMap { feed in
|
||||
(try? feed.fetchArticles()) ?? Set<Article>()
|
||||
}
|
||||
// Sort articles by logical date published like WebFeed does
|
||||
let sortedArticles = allArticles.sorted(by: {
|
||||
return $0.logicalDatePublished > $1.logicalDatePublished
|
||||
})
|
||||
return sortedArticles.map { ScriptableArticle($0, container:self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfArticles)
|
||||
func countOfArticles() -> Int {
|
||||
let feeds = Array(folder.topLevelWebFeeds)
|
||||
return feeds.reduce(0) { count, feed in
|
||||
let feedArticles = (try? feed.fetchArticles()) ?? Set<Article>()
|
||||
return count + feedArticles.count
|
||||
}
|
||||
}
|
||||
|
||||
@objc(objectInArticlesAtIndex:)
|
||||
func objectInArticlesAtIndex(_ index: Int) -> ScriptableArticle? {
|
||||
let feeds = Array(folder.topLevelWebFeeds)
|
||||
let allArticles = feeds.flatMap { feed in
|
||||
(try? feed.fetchArticles()) ?? Set<Article>()
|
||||
}
|
||||
let sortedArticles = allArticles.sorted(by: {
|
||||
return $0.logicalDatePublished > $1.logicalDatePublished
|
||||
})
|
||||
guard index >= 0 && index < sortedArticles.count else { return nil }
|
||||
return ScriptableArticle(sortedArticles[index], container: self)
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
@objc(name)
|
||||
|
||||
@@ -30,9 +30,9 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
func currentArticle() -> ScriptableArticle? {
|
||||
var scriptableArticle: ScriptableArticle?
|
||||
if let currentArticle = appDelegate.scriptingCurrentArticle {
|
||||
if let feed = currentArticle.webFeed {
|
||||
let scriptableFeed = ScriptableWebFeed(feed, container:self)
|
||||
scriptableArticle = ScriptableArticle(currentArticle, container:scriptableFeed)
|
||||
if let feed = currentArticle.webFeed,
|
||||
let scriptableFeed = ScriptableWebFeed.scriptableWebFeed(for: feed) {
|
||||
scriptableArticle = ScriptableArticle(currentArticle, container: scriptableFeed)
|
||||
}
|
||||
}
|
||||
return scriptableArticle
|
||||
@@ -42,8 +42,8 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
func selectedArticles() -> NSArray {
|
||||
let articles = appDelegate.scriptingSelectedArticles
|
||||
let scriptableArticles:[ScriptableArticle] = articles.compactMap { article in
|
||||
if let feed = article.webFeed {
|
||||
let scriptableFeed = ScriptableWebFeed(feed, container:self)
|
||||
if let feed = article.webFeed,
|
||||
let scriptableFeed = ScriptableWebFeed.scriptableWebFeed(for: feed) {
|
||||
return ScriptableArticle(article, container:scriptableFeed)
|
||||
} else {
|
||||
return nil
|
||||
@@ -51,6 +51,25 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
}
|
||||
return scriptableArticles as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfSelectedArticles)
|
||||
func countOfSelectedArticles() -> Int {
|
||||
return appDelegate.scriptingSelectedArticles.count
|
||||
}
|
||||
|
||||
@objc(objectInSelectedArticlesAtIndex:)
|
||||
func objectInSelectedArticlesAtIndex(_ index: Int) -> ScriptableArticle? {
|
||||
let articles = appDelegate.scriptingSelectedArticles
|
||||
guard index >= 0 && index < articles.count else { return nil }
|
||||
let article = articles[index]
|
||||
|
||||
if let feed = article.webFeed,
|
||||
let scriptableFeed = ScriptableWebFeed.scriptableWebFeed(for: feed) {
|
||||
return ScriptableArticle(article, container: scriptableFeed)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: --- scriptable elements ---
|
||||
|
||||
@@ -60,6 +79,18 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
return accounts.map { ScriptableAccount($0) } as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfAccounts)
|
||||
func countOfAccounts() -> Int {
|
||||
return AccountManager.shared.accounts.count
|
||||
}
|
||||
|
||||
@objc(objectInAccountsAtIndex:)
|
||||
func objectInAccountsAtIndex(_ index: Int) -> ScriptableAccount? {
|
||||
let accounts = Array(AccountManager.shared.accounts)
|
||||
guard index >= 0 && index < accounts.count else { return nil }
|
||||
return ScriptableAccount(accounts[index])
|
||||
}
|
||||
|
||||
@objc(valueInAccountsWithUniqueID:)
|
||||
func valueInAccounts(withUniqueID id:String) -> ScriptableAccount? {
|
||||
let accounts = AccountManager.shared.accounts
|
||||
@@ -87,6 +118,18 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
let webFeeds = self.allWebFeeds()
|
||||
return webFeeds.map { ScriptableWebFeed($0, container:self) } as NSArray
|
||||
}
|
||||
|
||||
@objc(countOfWebFeeds)
|
||||
func countOfWebFeeds() -> Int {
|
||||
return self.allWebFeeds().count
|
||||
}
|
||||
|
||||
@objc(objectInWebFeedsAtIndex:)
|
||||
func objectInWebFeedsAtIndex(_ index: Int) -> ScriptableWebFeed? {
|
||||
let webFeeds = self.allWebFeeds()
|
||||
guard index >= 0 && index < webFeeds.count else { return nil }
|
||||
return ScriptableWebFeed(webFeeds[index], container: self)
|
||||
}
|
||||
|
||||
@objc(valueInWebFeedsWithUniqueID:)
|
||||
func valueInWebFeeds(withUniqueID id:String) -> ScriptableWebFeed? {
|
||||
|
||||
@@ -12,7 +12,7 @@ import Account
|
||||
import Articles
|
||||
|
||||
@objc(ScriptableWebFeed)
|
||||
class ScriptableWebFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
final class ScriptableWebFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer {
|
||||
|
||||
let webFeed:WebFeed
|
||||
let container:ScriptingObjectContainer
|
||||
@@ -81,6 +81,24 @@ class ScriptableWebFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
}
|
||||
}
|
||||
|
||||
class func scriptableWebFeed(for feed: WebFeed) -> ScriptableWebFeed? {
|
||||
guard let account = feed.account else { return nil }
|
||||
|
||||
// Find the proper container hierarchy
|
||||
let containers = account.existingContainers(withWebFeed: feed)
|
||||
var folder: Folder? = nil
|
||||
|
||||
// Check if feed is in a folder
|
||||
for container in containers {
|
||||
if let foundFolder = container as? Folder {
|
||||
folder = foundFolder
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return scriptableFeed(feed, account: account, folder: folder)
|
||||
}
|
||||
|
||||
class func handleCreateElement(command:NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass:"Feed") else { return nil }
|
||||
guard let arguments = command.arguments else {return nil}
|
||||
|
||||
@@ -7,17 +7,15 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import os.log
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class ShareViewController: NSViewController {
|
||||
final class ShareViewController: NSViewController {
|
||||
|
||||
@IBOutlet weak var nameTextField: NSTextField!
|
||||
@IBOutlet weak var folderPopUpButton: NSPopUpButton!
|
||||
|
||||
private var url: URL?
|
||||
private var extensionContainers: ExtensionContainers?
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ShareViewController")
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name("ShareViewController")
|
||||
|
||||
@@ -17,7 +17,6 @@ import RSParser
|
||||
import RSDatabase
|
||||
import ArticlesDatabase
|
||||
import RSWeb
|
||||
import os.log
|
||||
import Secrets
|
||||
|
||||
// Main thread only.
|
||||
@@ -76,10 +75,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
public static let webFeeds = "webFeeds" // AccountDidDownloadArticles, StatusesDidChange
|
||||
public static let syncErrors = "syncErrors" // AccountsDidFailToSyncWithErrors
|
||||
}
|
||||
|
||||
|
||||
public static let defaultLocalAccountName = NSLocalizedString("account.name.on-my-device", tableName: "DefaultAccountNames", comment: "Device specific default account name, e.g: On My iPhone")
|
||||
|
||||
var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "account")
|
||||
|
||||
public var isDeleted = false
|
||||
|
||||
@@ -503,7 +500,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
return existingFolder(withExternalID: externalID)
|
||||
}
|
||||
|
||||
func existingContainers(withWebFeed webFeed: WebFeed) -> [Container] {
|
||||
public func existingContainers(withWebFeed webFeed: WebFeed) -> [Container] {
|
||||
var containers = [Container]()
|
||||
if topLevelWebFeeds.contains(webFeed) {
|
||||
containers.append(self)
|
||||
@@ -719,6 +716,19 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
webFeedDictionariesNeedUpdate = true
|
||||
}
|
||||
|
||||
@MainActor func update(_ feed: WebFeed, with parsedFeed: ParsedFeed) async throws -> ArticleChanges {
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
update(feed, with: parsedFeed) { result in
|
||||
switch result {
|
||||
case .success(let articleChanges):
|
||||
continuation.resume(returning: articleChanges)
|
||||
case .failure(let error):
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func update(_ webFeed: WebFeed, with parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesCompletionBlock) {
|
||||
// Used only by an On My Mac or iCloud account.
|
||||
precondition(Thread.isMainThread)
|
||||
|
||||
@@ -55,6 +55,16 @@ public final class AccountManager: UnreadCountProvider {
|
||||
return sortByName(accounts)
|
||||
}
|
||||
|
||||
public var hasiCloudAccount: Bool {
|
||||
for account in accounts {
|
||||
if account.type == .cloudKit {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
public var activeAccounts: [Account] {
|
||||
assert(Thread.isMainThread)
|
||||
return Array(accountsDictionary.values.filter { $0.isActive })
|
||||
@@ -121,6 +131,12 @@ public final class AccountManager: UnreadCountProvider {
|
||||
// MARK: - API
|
||||
|
||||
public func createAccount(type: AccountType) -> Account {
|
||||
if type == .cloudKit {
|
||||
if let existingiCloudAccount = accounts.first(where: { $0.type == .cloudKit }) {
|
||||
return existingiCloudAccount
|
||||
}
|
||||
}
|
||||
|
||||
let accountID = type == .cloudKit ? "iCloud" : UUID().uuidString
|
||||
let accountFolder = (accountsFolder as NSString).appendingPathComponent("\(type.rawValue)_\(accountID)")
|
||||
|
||||
@@ -140,7 +156,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
|
||||
return account
|
||||
}
|
||||
|
||||
|
||||
public func deleteAccount(_ account: Account) {
|
||||
guard !account.refreshInProgress else {
|
||||
return
|
||||
|
||||
@@ -11,9 +11,6 @@ import os.log
|
||||
import RSCore
|
||||
|
||||
final class AccountMetadataFile {
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "accountMetadataFile")
|
||||
|
||||
private let fileURL: URL
|
||||
private let account: Account
|
||||
|
||||
@@ -23,6 +20,7 @@ final class AccountMetadataFile {
|
||||
}
|
||||
}
|
||||
private let saveQueue = CoalescingQueue(name: "Save Queue", interval: 0.5)
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "AccountMetadataFile")
|
||||
|
||||
init(filename: String, account: Account) {
|
||||
self.fileURL = URL(fileURLWithPath: filename)
|
||||
@@ -51,7 +49,7 @@ final class AccountMetadataFile {
|
||||
let data = try encoder.encode(account.metadata)
|
||||
try data.write(to: fileURL)
|
||||
} catch let error as NSError {
|
||||
os_log(.error, log: log, "Save to disk failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("AccountMetadataFile accountID: \(self.account.accountID) save to disk failed: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,5 +67,4 @@ private extension AccountMetadataFile {
|
||||
save()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ enum CloudKitAccountDelegateError: LocalizedError {
|
||||
|
||||
final class CloudKitAccountDelegate: AccountDelegate {
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
private let database: SyncDatabase
|
||||
|
||||
@@ -322,7 +322,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
||||
self.removeWebFeedFromCloud(for: account, with: webFeed, from: folder) { result in
|
||||
group.leave()
|
||||
if case .failure(let error) = result {
|
||||
os_log(.error, log: self.log, "Remove folder, remove webfeed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Remove folder, remove webfeed error: \(error.localizedDescription)")
|
||||
errorOccurred = true
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Restore folder feed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Restore folder feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
||||
account.externalID = externalID
|
||||
self.initialRefreshAll(for: account) { _ in }
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Error adding account container: %@", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error adding account container: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
accountZone.subscribeToZoneChanges()
|
||||
@@ -640,10 +640,17 @@ private extension CloudKitAccountDelegate {
|
||||
feed.editedName = editedName
|
||||
container.addWebFeed(feed)
|
||||
|
||||
InitialFeedDownloader.download(url) { parsedFeed in
|
||||
InitialFeedDownloader.download(url) { parsedFeed, _, response, _ in
|
||||
self.syncProgress.completeTask()
|
||||
feed.lastCheckDate = Date()
|
||||
|
||||
if let parsedFeed {
|
||||
// Save conditional GET info so that first refresh uses conditional GET.
|
||||
if let httpResponse = response as? HTTPURLResponse,
|
||||
let conditionalGetInfo = HTTPConditionalGetInfo(urlResponse: httpResponse) {
|
||||
feed.conditionalGetInfo = conditionalGetInfo
|
||||
}
|
||||
|
||||
if let parsedFeed = parsedFeed {
|
||||
account.update(feed, with: parsedFeed) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
@@ -706,12 +713,12 @@ private extension CloudKitAccountDelegate {
|
||||
case .success:
|
||||
self.articlesZone.fetchChangesInZone() { _ in }
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "CloudKit Feed send articles error: %@.", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Feed send articles error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "CloudKit Feed send articles error: %@.", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Feed send articles error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ enum CloudKitAccountZoneError: LocalizedError {
|
||||
final class CloudKitAccountZone: CloudKitZone {
|
||||
|
||||
var zoneID: CKRecordZone.ID
|
||||
|
||||
var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
weak var container: CKContainer?
|
||||
weak var database: CKDatabase?
|
||||
|
||||
@@ -13,14 +13,12 @@ import CloudKit
|
||||
import RSCore
|
||||
import Articles
|
||||
|
||||
class CloudKitAcountZoneDelegate: CloudKitZoneDelegate {
|
||||
final class CloudKitAcountZoneDelegate: CloudKitZoneDelegate {
|
||||
|
||||
private typealias UnclaimedWebFeed = (url: URL, name: String?, editedName: String?, homePageURL: String?, webFeedExternalID: String)
|
||||
private var newUnclaimedWebFeeds = [String: [UnclaimedWebFeed]]()
|
||||
private var existingUnclaimedWebFeeds = [String: [WebFeed]]()
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
weak var account: Account?
|
||||
weak var articlesZone: CloudKitArticlesZone?
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ final class CloudKitArticlesZone: CloudKitZone {
|
||||
|
||||
var zoneID: CKRecordZone.ID
|
||||
|
||||
var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
weak var container: CKContainer?
|
||||
weak var database: CKDatabase?
|
||||
var delegate: CloudKitZoneDelegate? = nil
|
||||
|
||||
@@ -16,10 +16,10 @@ import SyncDatabase
|
||||
import Articles
|
||||
import ArticlesDatabase
|
||||
|
||||
class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
||||
final class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
||||
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
weak var account: Account?
|
||||
var database: SyncDatabase
|
||||
weak var articlesZone: CloudKitArticlesZone?
|
||||
@@ -49,19 +49,16 @@ class CloudKitArticlesZoneDelegate: CloudKitZoneDelegate {
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Error occurred getting pending starred records: %@", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error getting pending starred records: \(error.localizedDescription)")
|
||||
completion(.failure(CloudKitZoneError.unknown))
|
||||
}
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Error occurred getting pending read status records: %@", error.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error getting pending read status records: \(error.localizedDescription)")
|
||||
completion(.failure(CloudKitZoneError.unknown))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private extension CloudKitArticlesZoneDelegate {
|
||||
@@ -102,7 +99,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
account?.markAsUnread(updateableUnreadArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Error occurred while storing unread statuses: %@", databaseError.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error while storing unread statuses: \(databaseError.localizedDescription)")
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
@@ -111,7 +108,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
account?.markAsRead(updateableReadArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Error occurred while storing read statuses: %@", databaseError.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error while storing read statuses: \(databaseError.localizedDescription)")
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
@@ -120,7 +117,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
account?.markAsUnstarred(updateableUnstarredArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Error occurred while storing unstarred statuses: %@", databaseError.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error while storing unstarred statuses: \(databaseError.localizedDescription)")
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
@@ -129,7 +126,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
account?.markAsStarred(updateableStarredArticleIDs) { result in
|
||||
if case .failure(let databaseError) = result {
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Error occurred while storing starred statuses: %@", databaseError.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error while storing starred statuses: \(databaseError.localizedDescription)")
|
||||
}
|
||||
group.leave()
|
||||
}
|
||||
@@ -155,7 +152,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
}
|
||||
case .failure(let databaseError):
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Error occurred while storing articles: %@", databaseError.localizedDescription)
|
||||
Self.logger.error("CloudKit: Error while storing starred articles: \(databaseError.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
@@ -223,6 +220,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
language: nil,
|
||||
contentHTML: contentHTML,
|
||||
contentText: contentText,
|
||||
markdown: nil,
|
||||
summary: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.summary] as? String,
|
||||
imageURL: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.imageURL] as? String,
|
||||
bannerImageURL: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.imageURL] as? String,
|
||||
|
||||
@@ -10,10 +10,7 @@ import Foundation
|
||||
import os.log
|
||||
import RSCore
|
||||
|
||||
class CloudKitReceiveStatusOperation: MainThreadOperation {
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
final class CloudKitReceiveStatusOperation: MainThreadOperation {
|
||||
// MainThreadOperation
|
||||
public var isCanceled = false
|
||||
public var id: Int?
|
||||
@@ -22,29 +19,29 @@ class CloudKitReceiveStatusOperation: MainThreadOperation {
|
||||
public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock?
|
||||
|
||||
private weak var articlesZone: CloudKitArticlesZone?
|
||||
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
init(articlesZone: CloudKitArticlesZone) {
|
||||
self.articlesZone = articlesZone
|
||||
}
|
||||
|
||||
|
||||
func run() {
|
||||
guard let articlesZone = articlesZone else {
|
||||
guard let articlesZone else {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Refreshing article statuses...")
|
||||
|
||||
|
||||
Self.logger.debug("iCloud: Refreshing article statuses")
|
||||
|
||||
articlesZone.refreshArticles() { result in
|
||||
os_log(.debug, log: self.log, "Done refreshing article statuses.")
|
||||
Self.logger.debug("iCloud: Finished refreshing article statuses")
|
||||
switch result {
|
||||
case .success:
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Receive status error: %@.", error.localizedDescription)
|
||||
Self.logger.error("iCloud: Receive status error: \(error.localizedDescription)")
|
||||
self.operationDelegate?.cancelOperation(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,10 +11,7 @@ import Foundation
|
||||
import os.log
|
||||
import RSCore
|
||||
|
||||
class CloudKitRemoteNotificationOperation: MainThreadOperation {
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
|
||||
final class CloudKitRemoteNotificationOperation: MainThreadOperation {
|
||||
// MainThreadOperation
|
||||
public var isCanceled = false
|
||||
public var id: Int?
|
||||
@@ -25,7 +22,8 @@ class CloudKitRemoteNotificationOperation: MainThreadOperation {
|
||||
private weak var accountZone: CloudKitAccountZone?
|
||||
private weak var articlesZone: CloudKitArticlesZone?
|
||||
private var userInfo: [AnyHashable : Any]
|
||||
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
init(accountZone: CloudKitAccountZone, articlesZone: CloudKitArticlesZone, userInfo: [AnyHashable : Any]) {
|
||||
self.accountZone = accountZone
|
||||
self.articlesZone = articlesZone
|
||||
@@ -37,16 +35,14 @@ class CloudKitRemoteNotificationOperation: MainThreadOperation {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Processing remote notification...")
|
||||
|
||||
|
||||
Self.logger.debug("iCloud: Processing remote notification")
|
||||
|
||||
accountZone.receiveRemoteNotification(userInfo: userInfo) {
|
||||
articlesZone.receiveRemoteNotification(userInfo: self.userInfo) {
|
||||
os_log(.debug, log: self.log, "Done processing remote notification.")
|
||||
Self.logger.debug("iCloud: Finished processing remote notification")
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,9 @@ import RSCore
|
||||
import RSWeb
|
||||
import SyncDatabase
|
||||
|
||||
class CloudKitSendStatusOperation: MainThreadOperation {
|
||||
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CloudKit")
|
||||
final class CloudKitSendStatusOperation: MainThreadOperation {
|
||||
private let blockSize = 150
|
||||
|
||||
|
||||
// MainThreadOperation
|
||||
public var isCanceled = false
|
||||
public var id: Int?
|
||||
@@ -30,6 +28,7 @@ class CloudKitSendStatusOperation: MainThreadOperation {
|
||||
private weak var refreshProgress: DownloadProgress?
|
||||
private var showProgress: Bool
|
||||
private var database: SyncDatabase
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
init(account: Account, articlesZone: CloudKitArticlesZone, refreshProgress: DownloadProgress, showProgress: Bool, database: SyncDatabase) {
|
||||
self.account = account
|
||||
@@ -38,12 +37,12 @@ class CloudKitSendStatusOperation: MainThreadOperation {
|
||||
self.showProgress = showProgress
|
||||
self.database = database
|
||||
}
|
||||
|
||||
|
||||
func run() {
|
||||
os_log(.debug, log: log, "Sending article statuses...")
|
||||
|
||||
Self.logger.debug("iCloud: Sending article statuses")
|
||||
|
||||
if showProgress {
|
||||
|
||||
|
||||
database.selectPendingCount() { result in
|
||||
switch result {
|
||||
case .success(let count):
|
||||
@@ -51,41 +50,36 @@ class CloudKitSendStatusOperation: MainThreadOperation {
|
||||
self.refreshProgress?.addToNumberOfTasksAndRemaining(ticks)
|
||||
self.selectForProcessing()
|
||||
case .failure(let databaseError):
|
||||
os_log(.error, log: self.log, "Send status count pending error: %@.", databaseError.localizedDescription)
|
||||
Self.logger.error("iCloud: Send status count pending error: \(databaseError.localizedDescription)")
|
||||
self.operationDelegate?.cancelOperation(self)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
selectForProcessing()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension CloudKitSendStatusOperation {
|
||||
|
||||
|
||||
func selectForProcessing() {
|
||||
database.selectForProcessing(limit: blockSize) { result in
|
||||
switch result {
|
||||
case .success(let syncStatuses):
|
||||
|
||||
|
||||
func stopProcessing() {
|
||||
if self.showProgress {
|
||||
self.refreshProgress?.completeTask()
|
||||
}
|
||||
os_log(.debug, log: self.log, "Done sending article statuses.")
|
||||
Self.logger.debug("iCloud: Finished sending article statuses")
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
|
||||
|
||||
guard syncStatuses.count > 0 else {
|
||||
stopProcessing()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
self.processStatuses(syncStatuses) { stop in
|
||||
if stop {
|
||||
stopProcessing()
|
||||
@@ -93,25 +87,25 @@ private extension CloudKitSendStatusOperation {
|
||||
self.selectForProcessing()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
case .failure(let databaseError):
|
||||
os_log(.error, log: self.log, "Send status error: %@.", databaseError.localizedDescription)
|
||||
Self.logger.error("iCloud: Send status error \(databaseError.localizedDescription)")
|
||||
self.operationDelegate?.cancelOperation(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func processStatuses(_ syncStatuses: [SyncStatus], completion: @escaping (Bool) -> Void) {
|
||||
guard let account = account, let articlesZone = articlesZone else {
|
||||
completion(true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let articleIDs = syncStatuses.map({ $0.articleID })
|
||||
account.fetchArticlesAsync(.articleIDs(Set(articleIDs))) { result in
|
||||
|
||||
|
||||
func processWithArticles(_ articles: Set<Article>) {
|
||||
|
||||
|
||||
let syncStatusesDict = Dictionary(grouping: syncStatuses, by: { $0.articleID })
|
||||
let articlesDict = articles.reduce(into: [String: Article]()) { result, article in
|
||||
result[article.articleID] = article
|
||||
@@ -119,16 +113,15 @@ private extension CloudKitSendStatusOperation {
|
||||
let statusUpdates = syncStatusesDict.compactMap { (key, value) in
|
||||
return CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key])
|
||||
}
|
||||
|
||||
|
||||
func done(_ stop: Bool) {
|
||||
// Don't clear the last one since we might have had additional ticks added
|
||||
if self.showProgress && self.refreshProgress?.numberRemaining ?? 0 > 1 {
|
||||
if self.showProgress {
|
||||
self.refreshProgress?.completeTask()
|
||||
}
|
||||
os_log(.debug, log: self.log, "Done sending article status block...")
|
||||
Self.logger.debug("iCloud: Finished sending article status block")
|
||||
completion(stop)
|
||||
}
|
||||
|
||||
|
||||
// If this happens, we have somehow gotten into a state where we have new status records
|
||||
// but the articles didn't come back in the fetch. We need to clean up those sync records
|
||||
// and stop processing.
|
||||
@@ -147,13 +140,12 @@ private extension CloudKitSendStatusOperation {
|
||||
case .failure(let error):
|
||||
self.database.resetSelectedForProcessing(syncStatuses.map({ $0.articleID })) { _ in
|
||||
self.processAccountError(account, error)
|
||||
os_log(.error, log: self.log, "Send article status modify articles error: %@.", error.localizedDescription)
|
||||
Self.logger.error("iCloud: Send article status modify articles error: \(error.localizedDescription)")
|
||||
completion(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch result {
|
||||
@@ -161,14 +153,13 @@ private extension CloudKitSendStatusOperation {
|
||||
processWithArticles(articles)
|
||||
case .failure(let databaseError):
|
||||
self.database.resetSelectedForProcessing(syncStatuses.map({ $0.articleID })) { _ in
|
||||
os_log(.error, log: self.log, "Send article status fetch articles error: %@.", databaseError.localizedDescription)
|
||||
Self.logger.error("iCloud: Send article status fetch articles error: \(databaseError.localizedDescription)")
|
||||
completion(true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func processAccountError(_ account: Account, _ error: Error) {
|
||||
if case CloudKitZoneError.userDeletedZone = error {
|
||||
account.removeFeeds(account.topLevelWebFeeds)
|
||||
@@ -177,5 +168,4 @@ private extension CloudKitSendStatusOperation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,14 +7,24 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os.log
|
||||
import RSParser
|
||||
import RSWeb
|
||||
import RSCore
|
||||
|
||||
class FeedFinder {
|
||||
|
||||
final class FeedFinder {
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "FeedFinder")
|
||||
|
||||
static func find(url: URL, completion: @escaping (Result<Set<FeedSpecifier>, Error>) -> Void) {
|
||||
Task { @MainActor in
|
||||
// Check special cases first.
|
||||
if let feedSpecifier = FeedSpecifier.knownFeedSpecifier(url: url) {
|
||||
logger.info("FeedFinder: found special case feed URL: \(url.absoluteString) - \(feedSpecifier.urlString)")
|
||||
completion(.success(Set([feedSpecifier])))
|
||||
return
|
||||
}
|
||||
|
||||
Downloader.shared.download(url) { (data, response, error) in
|
||||
|
||||
if response?.forcedStatusCode == 404 {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import RSWeb
|
||||
|
||||
struct FeedSpecifier: Hashable {
|
||||
|
||||
@@ -25,7 +26,17 @@ struct FeedSpecifier: Hashable {
|
||||
public var score: Int {
|
||||
return calculatedScore()
|
||||
}
|
||||
|
||||
|
||||
/// Some feed URLs are known in advance. Save time/bandwidth by special-casing those.
|
||||
static func knownFeedSpecifier(url: URL) -> FeedSpecifier? {
|
||||
if url.isRachelByTheBayURL {
|
||||
let feedURLString = "https://rachelbythebay.com/w/atom.xml"
|
||||
return FeedSpecifier(title: "writing - rachelbythebay", urlString: feedURLString, source: .UserEntered, orderFound: 0)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func feedSpecifierByMerging(_ feedSpecifier: FeedSpecifier) -> FeedSpecifier {
|
||||
// Take the best data (non-nil title, better source) to create a new feed specifier;
|
||||
|
||||
@@ -82,6 +93,9 @@ private extension FeedSpecifier {
|
||||
if urlString.caseInsensitiveContains("rss") {
|
||||
score = score + 5
|
||||
}
|
||||
if urlString.hasSuffix("/index.xml") {
|
||||
score = score + 5
|
||||
}
|
||||
if urlString.hasSuffix("/feed/") {
|
||||
score = score + 5
|
||||
}
|
||||
@@ -89,16 +103,13 @@ private extension FeedSpecifier {
|
||||
score = score + 4
|
||||
}
|
||||
if urlString.caseInsensitiveContains("json") {
|
||||
score = score + 6
|
||||
score = score + 3
|
||||
}
|
||||
|
||||
if let title = title {
|
||||
if title.caseInsensitiveContains("comments") {
|
||||
score = score - 10
|
||||
}
|
||||
if title.caseInsensitiveContains("json") {
|
||||
score = score + 1
|
||||
}
|
||||
}
|
||||
|
||||
return score
|
||||
|
||||
@@ -11,7 +11,7 @@ import RSParser
|
||||
|
||||
private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"]
|
||||
|
||||
class HTMLFeedFinder {
|
||||
final class HTMLFeedFinder {
|
||||
|
||||
var feedSpecifiers: Set<FeedSpecifier> {
|
||||
return Set(feedSpecifiersDictionary.values)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// File.swift
|
||||
// Account
|
||||
//
|
||||
// Created by Brent Simmons on 10/2/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os.log
|
||||
|
||||
struct Feedbin {
|
||||
|
||||
// Convention with this logger is to put "Feedbin: " at the beginning of each message.
|
||||
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Feedbin")
|
||||
}
|
||||
@@ -25,8 +25,8 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
private let database: SyncDatabase
|
||||
|
||||
private let caller: FeedbinAPICaller
|
||||
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Feedbin")
|
||||
|
||||
private static let logger = Feedbin.logger
|
||||
|
||||
let behaviors: AccountBehaviors = [.disallowFeedCopyInRootFolder]
|
||||
let server: String? = "api.feedbin.com"
|
||||
var isOPMLImportInProgress = false
|
||||
@@ -133,7 +133,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
|
||||
func sendArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
|
||||
os_log(.debug, log: log, "Sending article statuses...")
|
||||
Self.logger.info("Feedbin: Sending article statuses")
|
||||
|
||||
database.selectForProcessing { result in
|
||||
|
||||
@@ -179,7 +179,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
os_log(.debug, log: self.log, "Done sending article statuses.")
|
||||
Self.logger.info("Feedbin: Finished sending article statuses")
|
||||
if errorOccurred {
|
||||
completion(.failure(FeedbinAccountDelegateError.unknown))
|
||||
} else {
|
||||
@@ -199,8 +199,8 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
|
||||
func refreshArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
|
||||
os_log(.debug, log: log, "Refreshing article statuses...")
|
||||
|
||||
Self.logger.info("Feedbin: Refreshing article statuses")
|
||||
|
||||
let group = DispatchGroup()
|
||||
var errorOccurred = false
|
||||
|
||||
@@ -213,7 +213,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
}
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Retrieving unread entries failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
|
||||
@@ -228,14 +228,14 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
}
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Retrieving starred entries failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
os_log(.debug, log: self.log, "Done refreshing article statuses.")
|
||||
Self.logger.info("Feedbin: Finished refreshing article statuses")
|
||||
if errorOccurred {
|
||||
completion(.failure(FeedbinAccountDelegateError.unknown))
|
||||
} else {
|
||||
@@ -261,7 +261,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Begin importing OPML...")
|
||||
Self.logger.info("Feedbin: Did begin importing OPML")
|
||||
isOPMLImportInProgress = true
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
|
||||
@@ -269,7 +269,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
switch result {
|
||||
case .success(let importResult):
|
||||
if importResult.complete {
|
||||
os_log(.debug, log: self.log, "Import OPML done.")
|
||||
Self.logger.info("Feedbin: Finished importing OPML")
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
DispatchQueue.main.async {
|
||||
@@ -279,7 +279,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
self.checkImportResult(opmlImportResultID: importResult.importResultID, completion: completion)
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Import OPML failed.")
|
||||
Self.logger.info("Feedbin: OPML import failed: \(error.localizedDescription)")
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
DispatchQueue.main.async {
|
||||
@@ -353,7 +353,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
self.clearFolderRelationship(for: feed, withFolderName: folder.name ?? "")
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Remove feed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Remove feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,7 +372,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
account.clearWebFeedMetadata(feed)
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Remove feed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Remove feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Restore folder feed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Restore folder feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,14 +624,14 @@ private extension FeedbinAccountDelegate {
|
||||
DispatchQueue.main.async {
|
||||
|
||||
Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { timer in
|
||||
|
||||
os_log(.debug, log: self.log, "Checking status of OPML import...")
|
||||
|
||||
|
||||
Self.logger.info("Feedbin: Checking status of OPML import")
|
||||
|
||||
self.caller.retrieveOPMLImportResult(importID: opmlImportResultID) { result in
|
||||
switch result {
|
||||
case .success(let importResult):
|
||||
if let result = importResult, result.complete {
|
||||
os_log(.debug, log: self.log, "Checking status of OPML import successfully completed.")
|
||||
Self.logger.info("Feedbin: Checking status of OPML import finished successfully")
|
||||
timer.invalidate()
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
@@ -640,7 +640,7 @@ private extension FeedbinAccountDelegate {
|
||||
}
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Import OPML check failed.")
|
||||
Self.logger.info("Feedbin: Import OPML check failed: \(error.localizedDescription)")
|
||||
timer.invalidate()
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
@@ -773,7 +773,7 @@ private extension FeedbinAccountDelegate {
|
||||
guard let tags = tags else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count)
|
||||
Self.logger.info("Feedbin: Syncing folders \(tags.count) tags")
|
||||
|
||||
let tagNames = tags.map { $0.name }
|
||||
|
||||
@@ -812,8 +812,8 @@ private extension FeedbinAccountDelegate {
|
||||
guard let subscriptions = subscriptions else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing feeds with %ld subscriptions.", subscriptions.count)
|
||||
|
||||
Self.logger.info("Feedbin: Syncing feeds with \(subscriptions.count) subscriptions")
|
||||
|
||||
let subFeedIds = subscriptions.map { String($0.feedID) }
|
||||
|
||||
// Remove any feeds that are no longer in the subscriptions
|
||||
@@ -866,8 +866,8 @@ private extension FeedbinAccountDelegate {
|
||||
guard let taggings = taggings else { return }
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
os_log(.debug, log: log, "Syncing taggings with %ld taggings.", taggings.count)
|
||||
|
||||
Self.logger.info("Feedbin: Syncing taggings with \(taggings.count) taggings")
|
||||
|
||||
// Set up some structures to make syncing easier
|
||||
let folderDict = nameToFolderDictionary(with: account.folders)
|
||||
let taggingsDict = taggings.reduce([String: [FeedbinTagging]]()) { (dict, tagging) in
|
||||
@@ -962,7 +962,8 @@ private extension FeedbinAccountDelegate {
|
||||
group.leave()
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Article status sync call failed: %@.", error.localizedDescription)
|
||||
|
||||
Self.logger.error("Feedbin: Article status sync call failed: \(error.localizedDescription)")
|
||||
self.database.resetSelectedForProcessing(articleIDGroup.map { String($0) } )
|
||||
group.leave()
|
||||
}
|
||||
@@ -1123,8 +1124,8 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
func refreshArticles(_ account: Account, completion: @escaping VoidResultCompletionBlock) {
|
||||
|
||||
os_log(.debug, log: log, "Refreshing articles...")
|
||||
|
||||
Self.logger.info("Feedbin: Refreshing articles")
|
||||
|
||||
caller.retrieveEntries() { result in
|
||||
|
||||
switch result {
|
||||
@@ -1144,7 +1145,7 @@ private extension FeedbinAccountDelegate {
|
||||
}
|
||||
|
||||
self.refreshArticles(account, page: page, updateFetchDate: updateFetchDate) { result in
|
||||
os_log(.debug, log: self.log, "Done refreshing articles.")
|
||||
Self.logger.info("Feedbin: Finished refreshing articles")
|
||||
switch result {
|
||||
case .success:
|
||||
completion(.success(()))
|
||||
@@ -1161,7 +1162,7 @@ private extension FeedbinAccountDelegate {
|
||||
}
|
||||
|
||||
func refreshMissingArticles(_ account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
os_log(.debug, log: log, "Refreshing missing articles...")
|
||||
Self.logger.info("Feedbin: Refreshing missing articles")
|
||||
|
||||
account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { result in
|
||||
|
||||
@@ -1188,7 +1189,7 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
case .failure(let error):
|
||||
errorOccurred = true
|
||||
os_log(.error, log: self.log, "Refresh missing articles failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Refresh missing articles failed: \(error.localizedDescription)")
|
||||
group.leave()
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1197,7 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
self.refreshProgress.completeTask()
|
||||
os_log(.debug, log: self.log, "Done refreshing missing articles.")
|
||||
Self.logger.info("Feedbin: Finished refreshing missing articles")
|
||||
if errorOccurred {
|
||||
completion(.failure(FeedbinAccountDelegateError.unknown))
|
||||
} else {
|
||||
@@ -1260,7 +1261,7 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
let parsedItems: [ParsedItem] = entries.map { entry in
|
||||
let authors = Set([ParsedAuthor(name: entry.authorName, url: entry.jsonFeed?.jsonFeedAuthor?.url, avatarURL: entry.jsonFeed?.jsonFeedAuthor?.avatarURL, emailAddress: nil)])
|
||||
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: entry.url, externalURL: entry.jsonFeed?.jsonFeedExternalURL, title: entry.title, language: nil, contentHTML: entry.contentHTML, contentText: nil, summary: entry.summary, imageURL: nil, bannerImageURL: nil, datePublished: entry.parsedDatePublished, dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
||||
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: entry.url, externalURL: entry.jsonFeed?.jsonFeedExternalURL, title: entry.title, language: nil, contentHTML: entry.contentHTML, contentText: nil, markdown: nil, summary: entry.summary, imageURL: nil, bannerImageURL: nil, datePublished: entry.parsedDatePublished, dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
||||
}
|
||||
|
||||
return Set(parsedItems)
|
||||
@@ -1313,11 +1314,9 @@ private extension FeedbinAccountDelegate {
|
||||
case .success(let pendingArticleIDs):
|
||||
process(pendingArticleIDs)
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Sync Article Read Status failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Sync Article Read Status failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func syncArticleStarredState(account: Account, articleIDs: [Int]?, completion: @escaping (() -> Void)) {
|
||||
@@ -1365,11 +1364,9 @@ private extension FeedbinAccountDelegate {
|
||||
case .success(let pendingArticleIDs):
|
||||
process(pendingArticleIDs)
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Sync Article Starred Status failed: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedbin: Sync Article Starred Status failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func deleteTagging(for account: Account, with feed: WebFeed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
@@ -1409,30 +1406,30 @@ private extension FeedbinAccountDelegate {
|
||||
completion(.failure(FeedbinAccountDelegateError.invalidParameter))
|
||||
return
|
||||
}
|
||||
|
||||
func complete() {
|
||||
DispatchQueue.main.async {
|
||||
account.clearWebFeedMetadata(feed)
|
||||
account.removeWebFeed(feed)
|
||||
if let folders = account.folders {
|
||||
for folder in folders {
|
||||
folder.removeWebFeed(feed)
|
||||
}
|
||||
}
|
||||
completion(.success(()))
|
||||
}
|
||||
}
|
||||
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
caller.deleteSubscription(subscriptionID: subscriptionID) { result in
|
||||
self.refreshProgress.completeTask()
|
||||
switch result {
|
||||
case .success:
|
||||
DispatchQueue.main.async {
|
||||
account.clearWebFeedMetadata(feed)
|
||||
account.removeWebFeed(feed)
|
||||
if let folders = account.folders {
|
||||
for folder in folders {
|
||||
folder.removeWebFeed(feed)
|
||||
}
|
||||
}
|
||||
completion(.success(()))
|
||||
}
|
||||
complete()
|
||||
case .failure(let error):
|
||||
DispatchQueue.main.async {
|
||||
let wrappedError = AccountError.wrappedError(error: error, account: account)
|
||||
completion(.failure(wrappedError))
|
||||
}
|
||||
Self.logger.error("Feedbin: Unable to remove feed from Feedbin. Removing locally and continuing processing: \(error.localizedDescription)")
|
||||
complete()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Feedly.swift
|
||||
// Account
|
||||
//
|
||||
// Created by Brent Simmons on 10/2/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os.log
|
||||
|
||||
struct Feedly {
|
||||
|
||||
// Convention with this logger is to put "Feedly: " at the beginning of each message.
|
||||
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Feedly")
|
||||
}
|
||||
@@ -18,7 +18,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
/// Feedly has a sandbox API and a production API.
|
||||
/// This property is referred to when clients need to know which environment it should be pointing to.
|
||||
/// The value of this proptery must match any `OAuthAuthorizationClient` used.
|
||||
/// The value of this property must match any `OAuthAuthorizationClient` used.
|
||||
/// Currently this is always returning the cloud API, but we are leaving it stubbed out for now.
|
||||
static var environment: FeedlyAPICaller.API {
|
||||
return .cloud
|
||||
@@ -60,8 +60,8 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
private weak var initializedAccount: Account?
|
||||
|
||||
internal let caller: FeedlyAPICaller
|
||||
|
||||
private let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Feedly")
|
||||
|
||||
private static let logger = Feedly.logger
|
||||
private let database: SyncDatabase
|
||||
|
||||
private weak var currentSyncAllOperation: MainThreadOperation?
|
||||
@@ -110,24 +110,27 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
func refreshAll(for account: Account, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
|
||||
guard !Platform.isRunningUnitTests else {
|
||||
Self.logger.debug("Feedly: Ignoring refreshAll: running unit tests")
|
||||
completion(.success(()))
|
||||
return
|
||||
}
|
||||
guard currentSyncAllOperation == nil else {
|
||||
os_log(.debug, log: log, "Ignoring refreshAll: Feedly sync already in progress.")
|
||||
Self.logger.debug("Feedly: Ignoring refreshAll: sync already in progress")
|
||||
completion(.success(()))
|
||||
return
|
||||
}
|
||||
|
||||
guard let credentials = credentials else {
|
||||
os_log(.debug, log: log, "Ignoring refreshAll: Feedly account has no credentials.")
|
||||
Self.logger.info("Feedly: Ignoring refreshAll: account has no credentials")
|
||||
completion(.failure(FeedlyAccountDelegateError.notLoggedIn))
|
||||
return
|
||||
}
|
||||
|
||||
refreshProgress.reset()
|
||||
|
||||
let log = self.log
|
||||
|
||||
let syncAllOperation = FeedlySyncAllOperation(account: account, feedlyUserId: credentials.username, caller: caller, database: database, lastSuccessfulFetchStartDate: accountMetadata?.lastArticleFetchStartTime, downloadProgress: refreshProgress, log: log)
|
||||
let syncAllOperation = FeedlySyncAllOperation(account: account, feedlyUserId: credentials.username, caller: caller, database: database, lastSuccessfulFetchStartDate: accountMetadata?.lastArticleFetchStartTime, downloadProgress: refreshProgress)
|
||||
|
||||
syncAllOperation.downloadProgress = refreshProgress
|
||||
|
||||
@@ -137,8 +140,8 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
self?.accountMetadata?.lastArticleFetchStartTime = date
|
||||
self?.accountMetadata?.lastArticleFetchEndTime = Date()
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Sync took %{public}.3f seconds", -date.timeIntervalSinceNow)
|
||||
|
||||
Self.logger.debug("Feedly: Sync took \(-date.timeIntervalSinceNow, privacy: .public) seconds")
|
||||
completion(result)
|
||||
self?.refreshProgress.reset()
|
||||
}
|
||||
@@ -168,7 +171,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
func sendArticleStatus(for account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
// Ensure remote articles have the same status as they do locally.
|
||||
let send = FeedlySendArticleStatusesOperation(database: database, service: caller, log: log)
|
||||
let send = FeedlySendArticleStatusesOperation(database: database, service: caller)
|
||||
send.completionBlock = { operation in
|
||||
// TODO: not call with success if operation was canceled? Not sure.
|
||||
DispatchQueue.main.async {
|
||||
@@ -191,7 +194,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
let group = DispatchGroup()
|
||||
|
||||
let ingestUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: credentials.username, service: caller, database: database, newerThan: nil, log: log)
|
||||
let ingestUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: credentials.username, service: caller, database: database, newerThan: nil)
|
||||
|
||||
group.enter()
|
||||
ingestUnread.completionBlock = { _ in
|
||||
@@ -199,7 +202,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
|
||||
}
|
||||
|
||||
let ingestStarred = FeedlyIngestStarredArticleIdsOperation(account: account, userId: credentials.username, service: caller, database: database, newerThan: nil, log: log)
|
||||
let ingestStarred = FeedlyIngestStarredArticleIdsOperation(account: account, userId: credentials.username, service: caller, database: database, newerThan: nil)
|
||||
|
||||
group.enter()
|
||||
ingestStarred.completionBlock = { _ in
|
||||
@@ -222,22 +225,22 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
completion(.failure(error))
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Begin importing OPML...")
|
||||
|
||||
Self.logger.info("Feedly: Begin importing OPML")
|
||||
isOPMLImportInProgress = true
|
||||
refreshProgress.addToNumberOfTasksAndRemaining(1)
|
||||
|
||||
caller.importOpml(data) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
os_log(.debug, log: self.log, "Import OPML done.")
|
||||
Self.logger.info("Feedly: OPML import finished")
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
DispatchQueue.main.async {
|
||||
completion(.success(()))
|
||||
}
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Import OPML failed.")
|
||||
Self.logger.error("Feedly: OPML import failed: \(error.localizedDescription)")
|
||||
self.refreshProgress.completeTask()
|
||||
self.isOPMLImportInProgress = false
|
||||
DispatchQueue.main.async {
|
||||
@@ -334,9 +337,8 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
getStreamContentsService: caller,
|
||||
database: database,
|
||||
container: container,
|
||||
progress: refreshProgress,
|
||||
log: log)
|
||||
|
||||
progress: refreshProgress)
|
||||
|
||||
addNewFeed.addCompletionHandler = { result in
|
||||
completion(result)
|
||||
}
|
||||
@@ -391,7 +393,6 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
service: caller,
|
||||
container: container,
|
||||
progress: refreshProgress,
|
||||
log: log,
|
||||
customFeedName: feed.editedName)
|
||||
|
||||
|
||||
@@ -497,10 +498,9 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
case .success:
|
||||
break
|
||||
case .failure(let error):
|
||||
os_log(.error, log: self.log, "Restore folder feed error: %@.", error.localizedDescription)
|
||||
Self.logger.error("Feedly: Restore folder feed error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
group.notify(queue: .main) {
|
||||
@@ -537,7 +537,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
func accountWillBeDeleted(_ account: Account) {
|
||||
let logout = FeedlyLogoutOperation(account: account, service: caller, log: log)
|
||||
let logout = FeedlyLogoutOperation(account: account, service: caller)
|
||||
// Dispatch on the shared queue because the lifetime of the account delegate is uncertain.
|
||||
MainThreadOperationQueue.shared.add(logout)
|
||||
}
|
||||
@@ -585,7 +585,7 @@ extension FeedlyAccountDelegate: FeedlyAPICallerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
let refreshAccessToken = FeedlyRefreshAccessTokenOperation(account: account, service: self, oauthClient: oauthAuthorizationClient, log: log)
|
||||
let refreshAccessToken = FeedlyRefreshAccessTokenOperation(account: account, service: self, oauthClient: oauthAuthorizationClient)
|
||||
refreshAccessToken.downloadProgress = refreshProgress
|
||||
|
||||
/// This must be strongly referenced by the completionBlock of the `FeedlyRefreshAccessTokenOperation`.
|
||||
|
||||
@@ -101,6 +101,7 @@ struct FeedlyEntryParser {
|
||||
language: nil,
|
||||
contentHTML: contentHMTL,
|
||||
contentText: contentText,
|
||||
markdown: nil,
|
||||
summary: summary,
|
||||
imageURL: nil,
|
||||
bannerImageURL: nil,
|
||||
|
||||
+3
-3
@@ -12,12 +12,12 @@ import RSWeb
|
||||
import RSCore
|
||||
import Secrets
|
||||
|
||||
class FeedlyAddExistingFeedOperation: FeedlyOperation, FeedlyOperationDelegate, FeedlyCheckpointOperationDelegate {
|
||||
final class FeedlyAddExistingFeedOperation: FeedlyOperation, FeedlyOperationDelegate, FeedlyCheckpointOperationDelegate {
|
||||
|
||||
private let operationQueue = MainThreadOperationQueue()
|
||||
var addCompletionHandler: ((Result<Void, Error>) -> ())?
|
||||
|
||||
init(account: Account, credentials: Credentials, resource: FeedlyFeedResourceId, service: FeedlyAddFeedToCollectionService, container: Container, progress: DownloadProgress, log: OSLog, customFeedName: String? = nil) throws {
|
||||
init(account: Account, credentials: Credentials, resource: FeedlyFeedResourceId, service: FeedlyAddFeedToCollectionService, container: Container, progress: DownloadProgress, customFeedName: String? = nil) throws {
|
||||
|
||||
let validator = FeedlyFeedContainerValidator(container: container)
|
||||
let (folder, collectionId) = try validator.getValidContainer()
|
||||
@@ -33,7 +33,7 @@ class FeedlyAddExistingFeedOperation: FeedlyOperation, FeedlyOperationDelegate,
|
||||
addRequest.downloadProgress = progress
|
||||
self.operationQueue.add(addRequest)
|
||||
|
||||
let createFeeds = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: addRequest, log: log)
|
||||
let createFeeds = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: addRequest)
|
||||
createFeeds.downloadProgress = progress
|
||||
createFeeds.addDependency(addRequest)
|
||||
self.operationQueue.add(createFeeds)
|
||||
|
||||
@@ -13,7 +13,7 @@ import RSWeb
|
||||
import RSCore
|
||||
import Secrets
|
||||
|
||||
class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, FeedlySearchOperationDelegate, FeedlyCheckpointOperationDelegate {
|
||||
final class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, FeedlySearchOperationDelegate, FeedlyCheckpointOperationDelegate {
|
||||
|
||||
private let operationQueue = MainThreadOperationQueue()
|
||||
private let folder: Folder
|
||||
@@ -26,11 +26,10 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
|
||||
private let addToCollectionService: FeedlyAddFeedToCollectionService
|
||||
private let syncUnreadIdsService: FeedlyGetStreamIdsService
|
||||
private let getStreamContentsService: FeedlyGetStreamContentsService
|
||||
private let log: OSLog
|
||||
private var feedResourceId: FeedlyFeedResourceId?
|
||||
var addCompletionHandler: ((Result<WebFeed, Error>) -> ())?
|
||||
|
||||
init(account: Account, credentials: Credentials, url: String, feedName: String?, searchService: FeedlySearchService, addToCollectionService: FeedlyAddFeedToCollectionService, syncUnreadIdsService: FeedlyGetStreamIdsService, getStreamContentsService: FeedlyGetStreamContentsService, database: SyncDatabase, container: Container, progress: DownloadProgress, log: OSLog) throws {
|
||||
init(account: Account, credentials: Credentials, url: String, feedName: String?, searchService: FeedlySearchService, addToCollectionService: FeedlyAddFeedToCollectionService, syncUnreadIdsService: FeedlyGetStreamIdsService, getStreamContentsService: FeedlyGetStreamContentsService, database: SyncDatabase, container: Container, progress: DownloadProgress) throws {
|
||||
|
||||
|
||||
let validator = FeedlyFeedContainerValidator(container: container)
|
||||
@@ -45,7 +44,6 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
|
||||
self.addToCollectionService = addToCollectionService
|
||||
self.syncUnreadIdsService = syncUnreadIdsService
|
||||
self.getStreamContentsService = getStreamContentsService
|
||||
self.log = log
|
||||
|
||||
super.init()
|
||||
|
||||
@@ -91,19 +89,19 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
|
||||
addRequest.downloadProgress = downloadProgress
|
||||
operationQueue.add(addRequest)
|
||||
|
||||
let createFeeds = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: addRequest, log: log)
|
||||
let createFeeds = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: addRequest)
|
||||
createFeeds.delegate = self
|
||||
createFeeds.addDependency(addRequest)
|
||||
createFeeds.downloadProgress = downloadProgress
|
||||
operationQueue.add(createFeeds)
|
||||
|
||||
let syncUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: credentials.username, service: syncUnreadIdsService, database: database, newerThan: nil, log: log)
|
||||
let syncUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: credentials.username, service: syncUnreadIdsService, database: database, newerThan: nil)
|
||||
syncUnread.addDependency(createFeeds)
|
||||
syncUnread.downloadProgress = downloadProgress
|
||||
syncUnread.delegate = self
|
||||
operationQueue.add(syncUnread)
|
||||
|
||||
let syncFeed = FeedlySyncStreamContentsOperation(account: account, resource: feedResourceId, service: getStreamContentsService, isPagingEnabled: false, newerThan: nil, log: log)
|
||||
let syncFeed = FeedlySyncStreamContentsOperation(account: account, resource: feedResourceId, service: getStreamContentsService, isPagingEnabled: false, newerThan: nil)
|
||||
syncFeed.addDependency(syncUnread)
|
||||
syncFeed.downloadProgress = downloadProgress
|
||||
syncFeed.delegate = self
|
||||
@@ -120,9 +118,9 @@ class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate, Feedl
|
||||
func feedlyOperation(_ operation: FeedlyOperation, didFailWith error: Error) {
|
||||
addCompletionHandler?(.failure(error))
|
||||
addCompletionHandler = nil
|
||||
|
||||
os_log(.debug, log: log, "Unable to add new feed: %{public}@.", error as NSError)
|
||||
|
||||
|
||||
Feedly.logger.error("Feedly: Unable to add new feed with error \(error.localizedDescription)")
|
||||
|
||||
cancel()
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -14,12 +14,10 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation {
|
||||
|
||||
let account: Account
|
||||
let feedsAndFoldersProvider: FeedlyFeedsAndFoldersProviding
|
||||
let log: OSLog
|
||||
|
||||
init(account: Account, feedsAndFoldersProvider: FeedlyFeedsAndFoldersProviding, log: OSLog) {
|
||||
init(account: Account, feedsAndFoldersProvider: FeedlyFeedsAndFoldersProviding) {
|
||||
self.feedsAndFoldersProvider = feedsAndFoldersProvider
|
||||
self.account = account
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -93,8 +91,8 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation {
|
||||
|
||||
return (feed, folder)
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Processing %i feeds.", feedsAndFolders.count)
|
||||
|
||||
Feedly.logger.info("Feedly: Processing \(feedsAndFolders.count) feeds")
|
||||
feedsAndFolders.forEach { (feed, folder) in
|
||||
if !folder.has(feed) {
|
||||
folder.addWebFeed(feed)
|
||||
@@ -107,7 +105,7 @@ final class FeedlyCreateFeedsForCollectionFoldersOperation: FeedlyOperation {
|
||||
account.removeFeeds(feedsWithoutCollections)
|
||||
|
||||
if !feedsWithoutCollections.isEmpty {
|
||||
os_log(.debug, log: log, "Removed %i feeds", feedsWithoutCollections.count)
|
||||
Feedly.logger.info("Feedly: Removed \(feedsWithoutCollections.count) feeds")
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-18
@@ -11,24 +11,22 @@ import os.log
|
||||
import RSCore
|
||||
import RSWeb
|
||||
|
||||
class FeedlyDownloadArticlesOperation: FeedlyOperation {
|
||||
final class FeedlyDownloadArticlesOperation: FeedlyOperation {
|
||||
|
||||
private let account: Account
|
||||
private let log: OSLog
|
||||
private let missingArticleEntryIdProvider: FeedlyEntryIdentifierProviding
|
||||
private let updatedArticleEntryIdProvider: FeedlyEntryIdentifierProviding
|
||||
private let getEntriesService: FeedlyGetEntriesService
|
||||
private let operationQueue = MainThreadOperationQueue()
|
||||
private let finishOperation: FeedlyCheckpointOperation
|
||||
|
||||
init(account: Account, missingArticleEntryIdProvider: FeedlyEntryIdentifierProviding, updatedArticleEntryIdProvider: FeedlyEntryIdentifierProviding, getEntriesService: FeedlyGetEntriesService, log: OSLog) {
|
||||
init(account: Account, missingArticleEntryIdProvider: FeedlyEntryIdentifierProviding, updatedArticleEntryIdProvider: FeedlyEntryIdentifierProviding, getEntriesService: FeedlyGetEntriesService) {
|
||||
self.account = account
|
||||
self.operationQueue.suspend()
|
||||
self.missingArticleEntryIdProvider = missingArticleEntryIdProvider
|
||||
self.updatedArticleEntryIdProvider = updatedArticleEntryIdProvider
|
||||
self.getEntriesService = getEntriesService
|
||||
self.finishOperation = FeedlyCheckpointOperation()
|
||||
self.log = log
|
||||
super.init()
|
||||
self.finishOperation.checkpointDelegate = self
|
||||
self.operationQueue.add(self.finishOperation)
|
||||
@@ -37,27 +35,29 @@ class FeedlyDownloadArticlesOperation: FeedlyOperation {
|
||||
override func run() {
|
||||
var articleIds = missingArticleEntryIdProvider.entryIds
|
||||
articleIds.formUnion(updatedArticleEntryIdProvider.entryIds)
|
||||
|
||||
os_log(.debug, log: log, "Requesting %{public}i articles.", articleIds.count)
|
||||
|
||||
|
||||
Feedly.logger.info("Feedly: Requesting \(articleIds.count) articles")
|
||||
|
||||
let feedlyAPILimitBatchSize = 1000
|
||||
for articleIds in Array(articleIds).chunked(into: feedlyAPILimitBatchSize) {
|
||||
|
||||
let provider = FeedlyEntryIdentifierProvider(entryIds: Set(articleIds))
|
||||
let getEntries = FeedlyGetEntriesOperation(account: account, service: getEntriesService, provider: provider, log: log)
|
||||
let getEntries = FeedlyGetEntriesOperation(account: account, service: getEntriesService, provider: provider)
|
||||
getEntries.delegate = self
|
||||
self.operationQueue.add(getEntries)
|
||||
|
||||
let organiseByFeed = FeedlyOrganiseParsedItemsByFeedOperation(account: account,
|
||||
parsedItemProvider: getEntries,
|
||||
log: log)
|
||||
let organiseByFeed = FeedlyOrganiseParsedItemsByFeedOperation(
|
||||
account: account,
|
||||
parsedItemProvider: getEntries
|
||||
)
|
||||
organiseByFeed.delegate = self
|
||||
organiseByFeed.addDependency(getEntries)
|
||||
self.operationQueue.add(organiseByFeed)
|
||||
|
||||
let updateAccount = FeedlyUpdateAccountFeedsWithItemsOperation(account: account,
|
||||
organisedItemsProvider: organiseByFeed,
|
||||
log: log)
|
||||
let updateAccount = FeedlyUpdateAccountFeedsWithItemsOperation(
|
||||
account: account,
|
||||
organisedItemsProvider: organiseByFeed
|
||||
)
|
||||
|
||||
updateAccount.delegate = self
|
||||
updateAccount.addDependency(organiseByFeed)
|
||||
@@ -70,8 +70,7 @@ class FeedlyDownloadArticlesOperation: FeedlyOperation {
|
||||
}
|
||||
|
||||
override func didCancel() {
|
||||
// TODO: fix error on below line: "Expression type '()' is ambiguous without more context"
|
||||
//os_log(.debug, log: log, "Cancelling %{public}@.", self)
|
||||
Feedly.logger.info("Feedly: Canceling FeedlyDownloadArticlesOperation")
|
||||
operationQueue.cancelAllOperations()
|
||||
super.didCancel()
|
||||
}
|
||||
@@ -90,8 +89,7 @@ extension FeedlyDownloadArticlesOperation: FeedlyOperationDelegate {
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
// Having this log is useful for debugging missing required JSON keys in the response from Feedly, for example.
|
||||
os_log(.debug, log: log, "%{public}@ failed with error: %{public}@.", String(describing: operation), error as NSError)
|
||||
|
||||
Feedly.logger.error("Feedly: FeedlyDownloadArticlesOperation did fail with error: \(error.localizedDescription)")
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -12,13 +12,11 @@ import os.log
|
||||
final class FeedlyFetchIdsForMissingArticlesOperation: FeedlyOperation, FeedlyEntryIdentifierProviding {
|
||||
|
||||
private let account: Account
|
||||
private let log: OSLog
|
||||
|
||||
private(set) var entryIds = Set<String>()
|
||||
|
||||
init(account: Account, log: OSLog) {
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
|
||||
+5
-7
@@ -17,27 +17,25 @@ protocol FeedlyCollectionProviding: AnyObject {
|
||||
final class FeedlyGetCollectionsOperation: FeedlyOperation, FeedlyCollectionProviding {
|
||||
|
||||
let service: FeedlyGetCollectionsService
|
||||
let log: OSLog
|
||||
|
||||
private(set) var collections = [FeedlyCollection]()
|
||||
|
||||
init(service: FeedlyGetCollectionsService, log: OSLog) {
|
||||
init(service: FeedlyGetCollectionsService) {
|
||||
self.service = service
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
os_log(.debug, log: log, "Requesting collections.")
|
||||
|
||||
Feedly.logger.info("Feedly: Requesting collections")
|
||||
|
||||
service.getCollections { result in
|
||||
switch result {
|
||||
case .success(let collections):
|
||||
os_log(.debug, log: self.log, "Received collections: %{public}@", collections.map { $0.id })
|
||||
Feedly.logger.info("Feedly: Received collections \(collections.map { $0.id })")
|
||||
self.collections = collections
|
||||
self.didFinish()
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Unable to request collections: %{public}@.", error as NSError)
|
||||
Feedly.logger.error("Feedly: Unable to request collections with error \(error.localizedDescription)")
|
||||
self.didFinish(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@ final class FeedlyGetEntriesOperation: FeedlyOperation, FeedlyEntryProviding, Fe
|
||||
let account: Account
|
||||
let service: FeedlyGetEntriesService
|
||||
let provider: FeedlyEntryIdentifierProviding
|
||||
let log: OSLog
|
||||
|
||||
init(account: Account, service: FeedlyGetEntriesService, provider: FeedlyEntryIdentifierProviding, log: OSLog) {
|
||||
init(account: Account, service: FeedlyGetEntriesService, provider: FeedlyEntryIdentifierProviding) {
|
||||
self.account = account
|
||||
self.service = service
|
||||
self.provider = provider
|
||||
self.log = log
|
||||
}
|
||||
|
||||
private(set) var entries = [FeedlyEntry]()
|
||||
@@ -63,7 +61,7 @@ final class FeedlyGetEntriesOperation: FeedlyOperation, FeedlyEntryProviding, Fe
|
||||
self.didFinish()
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Unable to get entries: %{public}@.", error as NSError)
|
||||
Feedly.logger.error("Feedly: Unable to get entries with error \(error.localizedDescription)")
|
||||
self.didFinish(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -58,7 +58,7 @@ final class FeedlyGetStreamContentsOperation: FeedlyOperation, FeedlyEntryProvid
|
||||
let entryIds = Set(entries.map { $0.id })
|
||||
let parsedIds = Set(parsed.map { $0.uniqueID })
|
||||
let difference = entryIds.subtracting(parsedIds)
|
||||
os_log(.debug, log: log, "Dropping articles with ids: %{public}@.", difference)
|
||||
Feedly.logger.info("Feedly: Dropping articles with IDs \(difference)")
|
||||
}
|
||||
|
||||
storedParsedEntries = parsed
|
||||
@@ -79,22 +79,20 @@ final class FeedlyGetStreamContentsOperation: FeedlyOperation, FeedlyEntryProvid
|
||||
let unreadOnly: Bool?
|
||||
let newerThan: Date?
|
||||
let continuation: String?
|
||||
let log: OSLog
|
||||
|
||||
weak var streamDelegate: FeedlyGetStreamContentsOperationDelegate?
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamContentsService, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool? = nil, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamContentsService, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool? = nil) {
|
||||
self.account = account
|
||||
self.resourceProvider = ResourceProvider(resource: resource)
|
||||
self.service = service
|
||||
self.continuation = continuation
|
||||
self.unreadOnly = unreadOnly
|
||||
self.newerThan = newerThan
|
||||
self.log = log
|
||||
}
|
||||
|
||||
convenience init(account: Account, resourceProvider: FeedlyResourceProviding, service: FeedlyGetStreamContentsService, newerThan: Date?, unreadOnly: Bool? = nil, log: OSLog) {
|
||||
self.init(account: account, resource: resourceProvider.resource, service: service, newerThan: newerThan, unreadOnly: unreadOnly, log: log)
|
||||
convenience init(account: Account, resourceProvider: FeedlyResourceProviding, service: FeedlyGetStreamContentsService, newerThan: Date?, unreadOnly: Bool? = nil) {
|
||||
self.init(account: account, resource: resourceProvider.resource, service: service, newerThan: newerThan, unreadOnly: unreadOnly)
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -108,7 +106,7 @@ final class FeedlyGetStreamContentsOperation: FeedlyOperation, FeedlyEntryProvid
|
||||
self.didFinish()
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Unable to get stream contents: %{public}@.", error as NSError)
|
||||
Feedly.logger.error("Feedly: Unable to get stream contents: \(error.localizedDescription)")
|
||||
self.didFinish(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,14 @@ final class FeedlyGetStreamIdsOperation: FeedlyOperation, FeedlyEntryIdentifierP
|
||||
let resource: FeedlyResourceId
|
||||
let unreadOnly: Bool?
|
||||
let newerThan: Date?
|
||||
let log: OSLog
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, continuation: String? = nil, newerThan: Date? = nil, unreadOnly: Bool?, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, continuation: String? = nil, newerThan: Date? = nil, unreadOnly: Bool?) {
|
||||
self.account = account
|
||||
self.resource = resource
|
||||
self.service = service
|
||||
self.continuation = continuation
|
||||
self.newerThan = newerThan
|
||||
self.unreadOnly = unreadOnly
|
||||
self.log = log
|
||||
}
|
||||
|
||||
weak var streamIdsDelegate: FeedlyGetStreamIdsOperationDelegate?
|
||||
@@ -57,7 +55,7 @@ final class FeedlyGetStreamIdsOperation: FeedlyOperation, FeedlyEntryIdentifierP
|
||||
self.didFinish()
|
||||
|
||||
case .failure(let error):
|
||||
os_log(.debug, log: self.log, "Unable to get stream ids: %{public}@.", error as NSError)
|
||||
Feedly.logger.error("Feedly: Unable to get stream IDs: \(error.localizedDescription)")
|
||||
self.didFinish(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -14,25 +14,23 @@ import Secrets
|
||||
///
|
||||
/// Typically, it pages through the article ids of the global.all stream.
|
||||
/// When all the article ids are collected, it is the responsibility of another operation to download them when appropriate.
|
||||
class FeedlyGetUpdatedArticleIdsOperation: FeedlyOperation, FeedlyEntryIdentifierProviding {
|
||||
final class FeedlyGetUpdatedArticleIdsOperation: FeedlyOperation, FeedlyEntryIdentifierProviding {
|
||||
|
||||
private let account: Account
|
||||
private let resource: FeedlyResourceId
|
||||
private let service: FeedlyGetStreamIdsService
|
||||
private let newerThan: Date?
|
||||
private let log: OSLog
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, newerThan: Date?, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, newerThan: Date?) {
|
||||
self.account = account
|
||||
self.resource = resource
|
||||
self.service = service
|
||||
self.newerThan = newerThan
|
||||
self.log = log
|
||||
}
|
||||
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, newerThan: Date?, log: OSLog) {
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, newerThan: Date?) {
|
||||
let all = FeedlyCategoryResourceId.Global.all(for: userId)
|
||||
self.init(account: account, resource: all, service: service, newerThan: newerThan, log: log)
|
||||
self.init(account: account, resource: all, service: service, newerThan: newerThan)
|
||||
}
|
||||
|
||||
var entryIds: Set<String> {
|
||||
@@ -47,7 +45,7 @@ class FeedlyGetUpdatedArticleIdsOperation: FeedlyOperation, FeedlyEntryIdentifie
|
||||
|
||||
private func getStreamIds(_ continuation: String?) {
|
||||
guard let date = newerThan else {
|
||||
os_log(.debug, log: log, "No date provided so everything must be new (nothing is updated).")
|
||||
Feedly.logger.debug("Feedly: No date provided so everything must be new (nothing is updated)")
|
||||
didFinish()
|
||||
return
|
||||
}
|
||||
@@ -66,7 +64,7 @@ class FeedlyGetUpdatedArticleIdsOperation: FeedlyOperation, FeedlyEntryIdentifie
|
||||
storedUpdatedArticleIds.formUnion(streamIds.ids)
|
||||
|
||||
guard let continuation = streamIds.continuation else {
|
||||
os_log(.debug, log: log, "%{public}i articles updated since last successful sync start date.", storedUpdatedArticleIds.count)
|
||||
Feedly.logger.info("Feedly: Articles updated since last successful sync start date: \(self.storedUpdatedArticleIds.count)")
|
||||
didFinish()
|
||||
return
|
||||
}
|
||||
|
||||
+3
-5
@@ -24,19 +24,17 @@ final class FeedlyIngestStarredArticleIdsOperation: FeedlyOperation {
|
||||
private let service: FeedlyGetStreamIdsService
|
||||
private let database: SyncDatabase
|
||||
private var remoteEntryIds = Set<String>()
|
||||
private let log: OSLog
|
||||
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?, log: OSLog) {
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?) {
|
||||
let resource = FeedlyTagResourceId.Global.saved(for: userId)
|
||||
self.init(account: account, resource: resource, service: service, database: database, newerThan: newerThan, log: log)
|
||||
self.init(account: account, resource: resource, service: service, database: database, newerThan: newerThan)
|
||||
}
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?) {
|
||||
self.account = account
|
||||
self.resource = resource
|
||||
self.service = service
|
||||
self.database = database
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
|
||||
+5
-7
@@ -15,23 +15,21 @@ import Secrets
|
||||
/// Typically, it pages through the article ids of the global.all stream.
|
||||
/// As the article ids are collected, a default read status is created for each.
|
||||
/// So this operation has side effects *for the entire account* it operates on.
|
||||
class FeedlyIngestStreamArticleIdsOperation: FeedlyOperation {
|
||||
final class FeedlyIngestStreamArticleIdsOperation: FeedlyOperation {
|
||||
|
||||
private let account: Account
|
||||
private let resource: FeedlyResourceId
|
||||
private let service: FeedlyGetStreamIdsService
|
||||
private let log: OSLog
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService) {
|
||||
self.account = account
|
||||
self.resource = resource
|
||||
self.service = service
|
||||
self.log = log
|
||||
}
|
||||
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, log: OSLog) {
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService) {
|
||||
let all = FeedlyCategoryResourceId.Global.all(for: userId)
|
||||
self.init(account: account, resource: all, service: service, log: log)
|
||||
self.init(account: account, resource: all, service: service)
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -58,7 +56,7 @@ class FeedlyIngestStreamArticleIdsOperation: FeedlyOperation {
|
||||
}
|
||||
|
||||
guard let continuation = streamIds.continuation else {
|
||||
os_log(.debug, log: self.log, "Reached end of stream for %@", self.resource.id)
|
||||
Feedly.logger.info("Feedly: Reached end of stream for \(self.resource.id)")
|
||||
self.didFinish()
|
||||
return
|
||||
}
|
||||
|
||||
+3
-5
@@ -25,19 +25,17 @@ final class FeedlyIngestUnreadArticleIdsOperation: FeedlyOperation {
|
||||
private let service: FeedlyGetStreamIdsService
|
||||
private let database: SyncDatabase
|
||||
private var remoteEntryIds = Set<String>()
|
||||
private let log: OSLog
|
||||
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?, log: OSLog) {
|
||||
convenience init(account: Account, userId: String, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?) {
|
||||
let resource = FeedlyCategoryResourceId.Global.all(for: userId)
|
||||
self.init(account: account, resource: resource, service: service, database: database, newerThan: newerThan, log: log)
|
||||
self.init(account: account, resource: resource, service: service, database: database, newerThan: newerThan)
|
||||
}
|
||||
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?, log: OSLog) {
|
||||
init(account: Account, resource: FeedlyResourceId, service: FeedlyGetStreamIdsService, database: SyncDatabase, newerThan: Date?) {
|
||||
self.account = account
|
||||
self.resource = resource
|
||||
self.service = service
|
||||
self.database = database
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
|
||||
@@ -17,16 +17,14 @@ final class FeedlyLogoutOperation: FeedlyOperation {
|
||||
|
||||
let service: FeedlyLogoutService
|
||||
let account: Account
|
||||
let log: OSLog
|
||||
|
||||
init(account: Account, service: FeedlyLogoutService, log: OSLog) {
|
||||
init(account: Account, service: FeedlyLogoutService) {
|
||||
self.service = service
|
||||
self.account = account
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
os_log("Requesting logout of %{public}@ account.", "\(account.type)")
|
||||
Feedly.logger.info("Feedly: Requesting logout \(self.account.accountID, privacy: .public)")
|
||||
service.logout(completion: didCompleteLogout(_:))
|
||||
}
|
||||
|
||||
@@ -34,7 +32,7 @@ final class FeedlyLogoutOperation: FeedlyOperation {
|
||||
assert(Thread.isMainThread)
|
||||
switch result {
|
||||
case .success:
|
||||
os_log("Logged out of %{public}@ account.", "\(account.type)")
|
||||
Feedly.logger.info("Feedly: Logged out of \(self.account.accountID, privacy: .public)")
|
||||
do {
|
||||
try account.removeCredentials(type: .oauthAccessToken)
|
||||
try account.removeCredentials(type: .oauthRefreshToken)
|
||||
@@ -44,7 +42,7 @@ final class FeedlyLogoutOperation: FeedlyOperation {
|
||||
didFinish()
|
||||
|
||||
case .failure(let error):
|
||||
os_log("Logout failed because %{public}@.", error as NSError)
|
||||
Feedly.logger.error("Feedly: Logout failed: \(error.localizedDescription)")
|
||||
didFinish(with: error)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -18,14 +18,12 @@ final class FeedlyMirrorCollectionsAsFoldersOperation: FeedlyOperation, FeedlyFe
|
||||
|
||||
let account: Account
|
||||
let collectionsProvider: FeedlyCollectionProviding
|
||||
let log: OSLog
|
||||
|
||||
private(set) var feedsAndFolders = [([FeedlyFeed], Folder)]()
|
||||
|
||||
init(account: Account, collectionsProvider: FeedlyCollectionProviding, log: OSLog) {
|
||||
init(account: Account, collectionsProvider: FeedlyCollectionProviding) {
|
||||
self.collectionsProvider = collectionsProvider
|
||||
self.account = account
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -45,9 +43,9 @@ final class FeedlyMirrorCollectionsAsFoldersOperation: FeedlyOperation, FeedlyFe
|
||||
folder.externalID = parser.externalID
|
||||
return (collection.feeds, folder)
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Ensured %i folders for %i collections.", feedsAndFolders.count, collections.count)
|
||||
|
||||
|
||||
Feedly.logger.info("Feedly: Ensured \(self.feedsAndFolders.count) folders for \(collections.count) collections")
|
||||
|
||||
// Remove folders without a corresponding collection
|
||||
let collectionFolders = Set(feedsAndFolders.map { $0.1 })
|
||||
let foldersWithoutCollections = localFolders.subtracting(collectionFolders)
|
||||
@@ -56,8 +54,10 @@ final class FeedlyMirrorCollectionsAsFoldersOperation: FeedlyOperation, FeedlyFe
|
||||
for unmatched in foldersWithoutCollections {
|
||||
account.removeFolder(unmatched)
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Removed %i folders: %@", foldersWithoutCollections.count, foldersWithoutCollections.map { $0.externalID ?? $0.nameForDisplay })
|
||||
|
||||
let folderCountForLog = foldersWithoutCollections.count
|
||||
let foldersForLog = foldersWithoutCollections.map { $0.externalID ?? $0.nameForDisplay }
|
||||
Feedly.logger.info("Feedly: Removed \(folderCountForLog) folders: \(foldersForLog)")
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -20,7 +20,6 @@ final class FeedlyOrganiseParsedItemsByFeedOperation: FeedlyOperation, FeedlyPar
|
||||
|
||||
private let account: Account
|
||||
private let parsedItemProvider: FeedlyParsedItemProviding
|
||||
private let log: OSLog
|
||||
|
||||
var parsedItemsByFeedProviderName: String {
|
||||
return name ?? String(describing: Self.self)
|
||||
@@ -33,10 +32,9 @@ final class FeedlyOrganiseParsedItemsByFeedOperation: FeedlyOperation, FeedlyPar
|
||||
|
||||
private var itemsKeyedByFeedId = [String: Set<ParsedItem>]()
|
||||
|
||||
init(account: Account, parsedItemProvider: FeedlyParsedItemProviding, log: OSLog) {
|
||||
init(account: Account, parsedItemProvider: FeedlyParsedItemProviding) {
|
||||
self.account = account
|
||||
self.parsedItemProvider = parsedItemProvider
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -59,9 +57,9 @@ final class FeedlyOrganiseParsedItemsByFeedOperation: FeedlyOperation, FeedlyPar
|
||||
}()
|
||||
dict[key] = value
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Grouped %i items by %i feeds for %@", items.count, dict.count, parsedItemProvider.parsedItemProviderName)
|
||||
|
||||
|
||||
Feedly.logger.info("Feedly: Grouped \(items.count) items by \(dict.count) feeds for \(self.parsedItemProvider.parsedItemProviderName)")
|
||||
|
||||
itemsKeyedByFeedId = dict
|
||||
}
|
||||
}
|
||||
+7
-9
@@ -16,13 +16,11 @@ final class FeedlyRefreshAccessTokenOperation: FeedlyOperation {
|
||||
let service: OAuthAccessTokenRefreshing
|
||||
let oauthClient: OAuthAuthorizationClient
|
||||
let account: Account
|
||||
let log: OSLog
|
||||
|
||||
init(account: Account, service: OAuthAccessTokenRefreshing, oauthClient: OAuthAuthorizationClient, log: OSLog) {
|
||||
init(account: Account, service: OAuthAccessTokenRefreshing, oauthClient: OAuthAuthorizationClient) {
|
||||
self.oauthClient = oauthClient
|
||||
self.service = service
|
||||
self.account = account
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -30,7 +28,7 @@ final class FeedlyRefreshAccessTokenOperation: FeedlyOperation {
|
||||
|
||||
do {
|
||||
guard let credentials = try account.retrieveCredentials(type: .oauthRefreshToken) else {
|
||||
os_log(.debug, log: log, "Could not find a refresh token in the keychain. Check the refresh token is added to the Keychain, remove the account and add it again.")
|
||||
Feedly.logger.error("Feedly: Could not find a refresh token in the keychain. Check the refresh token is added to the Keychain, remove the account and add it again")
|
||||
throw TransportError.httpError(status: 403)
|
||||
}
|
||||
|
||||
@@ -40,9 +38,9 @@ final class FeedlyRefreshAccessTokenOperation: FeedlyOperation {
|
||||
didFinish(with: error)
|
||||
return
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Refreshing access token.")
|
||||
|
||||
|
||||
Feedly.logger.info("Feedly: Refreshing access token")
|
||||
|
||||
// Ignore cancellation after the request is resumed otherwise we may continue storing a potentially invalid token!
|
||||
service.refreshAccessToken(with: refreshToken.secret, client: oauthClient) { result in
|
||||
self.didRefreshAccessToken(result)
|
||||
@@ -55,13 +53,13 @@ final class FeedlyRefreshAccessTokenOperation: FeedlyOperation {
|
||||
switch result {
|
||||
case .success(let grant):
|
||||
do {
|
||||
os_log(.debug, log: log, "Storing refresh token.")
|
||||
Feedly.logger.info("Feedly: Storing refresh token")
|
||||
// Store the refresh token first because it sends this token to the account delegate.
|
||||
if let token = grant.refreshToken {
|
||||
try account.storeCredentials(token)
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Storing access token.")
|
||||
Feedly.logger.info("Feedly: Storing access token")
|
||||
// Now store the access token because we want the account delegate to use it.
|
||||
try account.storeCredentials(grant.accessToken)
|
||||
|
||||
|
||||
+9
-10
@@ -22,17 +22,15 @@ final class FeedlyRequestStreamsOperation: FeedlyOperation {
|
||||
let collectionsProvider: FeedlyCollectionProviding
|
||||
let service: FeedlyGetStreamContentsService
|
||||
let account: Account
|
||||
let log: OSLog
|
||||
let newerThan: Date?
|
||||
let unreadOnly: Bool?
|
||||
|
||||
init(account: Account, collectionsProvider: FeedlyCollectionProviding, newerThan: Date?, unreadOnly: Bool?, service: FeedlyGetStreamContentsService, log: OSLog) {
|
||||
init(account: Account, collectionsProvider: FeedlyCollectionProviding, newerThan: Date?, unreadOnly: Bool?, service: FeedlyGetStreamContentsService) {
|
||||
self.account = account
|
||||
self.service = service
|
||||
self.collectionsProvider = collectionsProvider
|
||||
self.newerThan = newerThan
|
||||
self.unreadOnly = unreadOnly
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
@@ -46,15 +44,16 @@ final class FeedlyRequestStreamsOperation: FeedlyOperation {
|
||||
|
||||
for collection in collectionsProvider.collections {
|
||||
let resource = FeedlyCategoryResourceId(id: collection.id)
|
||||
let operation = FeedlyGetStreamContentsOperation(account: account,
|
||||
resource: resource,
|
||||
service: service,
|
||||
newerThan: newerThan,
|
||||
unreadOnly: unreadOnly,
|
||||
log: log)
|
||||
let operation = FeedlyGetStreamContentsOperation(
|
||||
account: account,
|
||||
resource: resource,
|
||||
service: service,
|
||||
newerThan: newerThan,
|
||||
unreadOnly: unreadOnly
|
||||
)
|
||||
queueDelegate?.feedlyRequestStreamsOperation(self, enqueue: operation)
|
||||
}
|
||||
|
||||
os_log(.debug, log: log, "Requested %i collection streams", collectionsProvider.collections.count)
|
||||
Feedly.logger.info("Feedly: Requested \(self.collectionsProvider.collections.count) collection streams")
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ protocol FeedlySearchOperationDelegate: AnyObject {
|
||||
|
||||
/// Find one and only one feed for a given query (usually, a URL).
|
||||
/// What happens when a feed is found for the URL is delegated to the `searchDelegate`.
|
||||
class FeedlySearchOperation: FeedlyOperation {
|
||||
final class FeedlySearchOperation: FeedlyOperation {
|
||||
|
||||
let query: String
|
||||
let locale: Locale
|
||||
|
||||
+3
-5
@@ -16,17 +16,15 @@ import os.log
|
||||
final class FeedlySendArticleStatusesOperation: FeedlyOperation {
|
||||
|
||||
private let database: SyncDatabase
|
||||
private let log: OSLog
|
||||
private let service: FeedlyMarkArticlesService
|
||||
|
||||
init(database: SyncDatabase, service: FeedlyMarkArticlesService, log: OSLog) {
|
||||
init(database: SyncDatabase, service: FeedlyMarkArticlesService) {
|
||||
self.database = database
|
||||
self.service = service
|
||||
self.log = log
|
||||
}
|
||||
|
||||
override func run() {
|
||||
os_log(.debug, log: log, "Sending article statuses...")
|
||||
Feedly.logger.info("Feedly: Sending article statuses")
|
||||
|
||||
database.selectForProcessing { result in
|
||||
if self.isCanceled {
|
||||
@@ -81,7 +79,7 @@ private extension FeedlySendArticleStatusesOperation {
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) {
|
||||
os_log(.debug, log: self.log, "Done sending article statuses.")
|
||||
Feedly.logger.info("Feedly: Finished sending article statuses")
|
||||
self.didFinish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import Secrets
|
||||
final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
|
||||
private let operationQueue = MainThreadOperationQueue()
|
||||
private let log: OSLog
|
||||
let syncUUID: UUID
|
||||
|
||||
var syncCompletionHandler: ((Result<Void, Error>) -> ())?
|
||||
@@ -34,9 +33,8 @@ final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
///
|
||||
/// Download articles for statuses at the union of those statuses without its corresponding article and those included in 3 (changed since last successful sync).
|
||||
///
|
||||
init(account: Account, feedlyUserId: String, lastSuccessfulFetchStartDate: Date?, markArticlesService: FeedlyMarkArticlesService, getUnreadService: FeedlyGetStreamIdsService, getCollectionsService: FeedlyGetCollectionsService, getStreamContentsService: FeedlyGetStreamContentsService, getStarredService: FeedlyGetStreamIdsService, getStreamIdsService: FeedlyGetStreamIdsService, getEntriesService: FeedlyGetEntriesService, database: SyncDatabase, downloadProgress: DownloadProgress, log: OSLog) {
|
||||
init(account: Account, feedlyUserId: String, lastSuccessfulFetchStartDate: Date?, markArticlesService: FeedlyMarkArticlesService, getUnreadService: FeedlyGetStreamIdsService, getCollectionsService: FeedlyGetCollectionsService, getStreamContentsService: FeedlyGetStreamContentsService, getStarredService: FeedlyGetStreamIdsService, getStreamIdsService: FeedlyGetStreamIdsService, getEntriesService: FeedlyGetEntriesService, database: SyncDatabase, downloadProgress: DownloadProgress) {
|
||||
self.syncUUID = UUID()
|
||||
self.log = log
|
||||
self.operationQueue.suspend()
|
||||
|
||||
super.init()
|
||||
@@ -44,38 +42,38 @@ final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
self.downloadProgress = downloadProgress
|
||||
|
||||
// Send any read/unread/starred article statuses to Feedly before anything else.
|
||||
let sendArticleStatuses = FeedlySendArticleStatusesOperation(database: database, service: markArticlesService, log: log)
|
||||
let sendArticleStatuses = FeedlySendArticleStatusesOperation(database: database, service: markArticlesService)
|
||||
sendArticleStatuses.delegate = self
|
||||
sendArticleStatuses.downloadProgress = downloadProgress
|
||||
self.operationQueue.add(sendArticleStatuses)
|
||||
|
||||
// Get all the Collections the user has.
|
||||
let getCollections = FeedlyGetCollectionsOperation(service: getCollectionsService, log: log)
|
||||
let getCollections = FeedlyGetCollectionsOperation(service: getCollectionsService)
|
||||
getCollections.delegate = self
|
||||
getCollections.downloadProgress = downloadProgress
|
||||
getCollections.addDependency(sendArticleStatuses)
|
||||
self.operationQueue.add(getCollections)
|
||||
|
||||
// Ensure a folder exists for each Collection, removing Folders without a corresponding Collection.
|
||||
let mirrorCollectionsAsFolders = FeedlyMirrorCollectionsAsFoldersOperation(account: account, collectionsProvider: getCollections, log: log)
|
||||
let mirrorCollectionsAsFolders = FeedlyMirrorCollectionsAsFoldersOperation(account: account, collectionsProvider: getCollections)
|
||||
mirrorCollectionsAsFolders.delegate = self
|
||||
mirrorCollectionsAsFolders.addDependency(getCollections)
|
||||
self.operationQueue.add(mirrorCollectionsAsFolders)
|
||||
|
||||
// Ensure feeds are created and grouped by their folders.
|
||||
let createFeedsOperation = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: mirrorCollectionsAsFolders, log: log)
|
||||
let createFeedsOperation = FeedlyCreateFeedsForCollectionFoldersOperation(account: account, feedsAndFoldersProvider: mirrorCollectionsAsFolders)
|
||||
createFeedsOperation.delegate = self
|
||||
createFeedsOperation.addDependency(mirrorCollectionsAsFolders)
|
||||
self.operationQueue.add(createFeedsOperation)
|
||||
|
||||
let getAllArticleIds = FeedlyIngestStreamArticleIdsOperation(account: account, userId: feedlyUserId, service: getStreamIdsService, log: log)
|
||||
let getAllArticleIds = FeedlyIngestStreamArticleIdsOperation(account: account, userId: feedlyUserId, service: getStreamIdsService)
|
||||
getAllArticleIds.delegate = self
|
||||
getAllArticleIds.downloadProgress = downloadProgress
|
||||
getAllArticleIds.addDependency(createFeedsOperation)
|
||||
self.operationQueue.add(getAllArticleIds)
|
||||
|
||||
// Get each page of unread article ids in the global.all stream for the last 31 days (nil = Feedly API default).
|
||||
let getUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: feedlyUserId, service: getUnreadService, database: database, newerThan: nil, log: log)
|
||||
let getUnread = FeedlyIngestUnreadArticleIdsOperation(account: account, userId: feedlyUserId, service: getUnreadService, database: database, newerThan: nil)
|
||||
getUnread.delegate = self
|
||||
getUnread.addDependency(getAllArticleIds)
|
||||
getUnread.downloadProgress = downloadProgress
|
||||
@@ -83,21 +81,21 @@ final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
|
||||
// Get each page of the article ids which have been update since the last successful fetch start date.
|
||||
// If the date is nil, this operation provides an empty set (everything is new, nothing is updated).
|
||||
let getUpdated = FeedlyGetUpdatedArticleIdsOperation(account: account, userId: feedlyUserId, service: getStreamIdsService, newerThan: lastSuccessfulFetchStartDate, log: log)
|
||||
let getUpdated = FeedlyGetUpdatedArticleIdsOperation(account: account, userId: feedlyUserId, service: getStreamIdsService, newerThan: lastSuccessfulFetchStartDate)
|
||||
getUpdated.delegate = self
|
||||
getUpdated.downloadProgress = downloadProgress
|
||||
getUpdated.addDependency(createFeedsOperation)
|
||||
self.operationQueue.add(getUpdated)
|
||||
|
||||
// Get each page of the article ids for starred articles.
|
||||
let getStarred = FeedlyIngestStarredArticleIdsOperation(account: account, userId: feedlyUserId, service: getStarredService, database: database, newerThan: nil, log: log)
|
||||
let getStarred = FeedlyIngestStarredArticleIdsOperation(account: account, userId: feedlyUserId, service: getStarredService, database: database, newerThan: nil)
|
||||
getStarred.delegate = self
|
||||
getStarred.downloadProgress = downloadProgress
|
||||
getStarred.addDependency(createFeedsOperation)
|
||||
self.operationQueue.add(getStarred)
|
||||
|
||||
// Now all the possible article ids we need have a status, fetch the article ids for missing articles.
|
||||
let getMissingIds = FeedlyFetchIdsForMissingArticlesOperation(account: account, log: log)
|
||||
let getMissingIds = FeedlyFetchIdsForMissingArticlesOperation(account: account)
|
||||
getMissingIds.delegate = self
|
||||
getMissingIds.downloadProgress = downloadProgress
|
||||
getMissingIds.addDependency(getAllArticleIds)
|
||||
@@ -107,11 +105,12 @@ final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
self.operationQueue.add(getMissingIds)
|
||||
|
||||
// Download all the missing and updated articles
|
||||
let downloadMissingArticles = FeedlyDownloadArticlesOperation(account: account,
|
||||
missingArticleEntryIdProvider: getMissingIds,
|
||||
updatedArticleEntryIdProvider: getUpdated,
|
||||
getEntriesService: getEntriesService,
|
||||
log: log)
|
||||
let downloadMissingArticles = FeedlyDownloadArticlesOperation(
|
||||
account: account,
|
||||
missingArticleEntryIdProvider: getMissingIds,
|
||||
updatedArticleEntryIdProvider: getUpdated,
|
||||
getEntriesService: getEntriesService
|
||||
)
|
||||
downloadMissingArticles.delegate = self
|
||||
downloadMissingArticles.downloadProgress = downloadProgress
|
||||
downloadMissingArticles.addDependency(getMissingIds)
|
||||
@@ -126,17 +125,17 @@ final class FeedlySyncAllOperation: FeedlyOperation {
|
||||
self.operationQueue.add(finishOperation)
|
||||
}
|
||||
|
||||
convenience init(account: Account, feedlyUserId: String, caller: FeedlyAPICaller, database: SyncDatabase, lastSuccessfulFetchStartDate: Date?, downloadProgress: DownloadProgress, log: OSLog) {
|
||||
self.init(account: account, feedlyUserId: feedlyUserId, lastSuccessfulFetchStartDate: lastSuccessfulFetchStartDate, markArticlesService: caller, getUnreadService: caller, getCollectionsService: caller, getStreamContentsService: caller, getStarredService: caller, getStreamIdsService: caller, getEntriesService: caller, database: database, downloadProgress: downloadProgress, log: log)
|
||||
convenience init(account: Account, feedlyUserId: String, caller: FeedlyAPICaller, database: SyncDatabase, lastSuccessfulFetchStartDate: Date?, downloadProgress: DownloadProgress) {
|
||||
self.init(account: account, feedlyUserId: feedlyUserId, lastSuccessfulFetchStartDate: lastSuccessfulFetchStartDate, markArticlesService: caller, getUnreadService: caller, getCollectionsService: caller, getStreamContentsService: caller, getStarredService: caller, getStreamIdsService: caller, getEntriesService: caller, database: database, downloadProgress: downloadProgress)
|
||||
}
|
||||
|
||||
override func run() {
|
||||
os_log(.debug, log: log, "Starting sync %{public}@", syncUUID.uuidString)
|
||||
Feedly.logger.info("Feedly: Starting sync \(self.syncUUID.uuidString, privacy: .public)")
|
||||
operationQueue.resume()
|
||||
}
|
||||
|
||||
override func didCancel() {
|
||||
os_log(.debug, log: log, "Cancelling sync %{public}@", syncUUID.uuidString)
|
||||
Feedly.logger.info("Feedly: Canceling sync \(self.syncUUID.uuidString, privacy: .public)")
|
||||
self.operationQueue.cancelAllOperations()
|
||||
syncCompletionHandler = nil
|
||||
super.didCancel()
|
||||
@@ -147,8 +146,8 @@ extension FeedlySyncAllOperation: FeedlyCheckpointOperationDelegate {
|
||||
|
||||
func feedlyCheckpointOperationDidReachCheckpoint(_ operation: FeedlyCheckpointOperation) {
|
||||
assert(Thread.isMainThread)
|
||||
os_log(.debug, log: self.log, "Sync completed: %{public}@", syncUUID.uuidString)
|
||||
|
||||
Feedly.logger.info("Feedly: Sync finished \(self.syncUUID.uuidString, privacy: .public)")
|
||||
|
||||
syncCompletionHandler?(.success(()))
|
||||
syncCompletionHandler = nil
|
||||
|
||||
@@ -162,8 +161,8 @@ extension FeedlySyncAllOperation: FeedlyOperationDelegate {
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
// Having this log is useful for debugging missing required JSON keys in the response from Feedly, for example.
|
||||
os_log(.debug, log: log, "%{public}@ failed with error: %{public}@.", String(describing: operation), error as NSError)
|
||||
|
||||
Feedly.logger.error("Feedly: Sync \(self.syncUUID.uuidString, privacy: .public) failed with error: \(error.localizedDescription)")
|
||||
|
||||
syncCompletionHandler?(.failure(error))
|
||||
syncCompletionHandler = nil
|
||||
|
||||
|
||||
Loaded 100 of 340 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user