Compare commits

...

724 Commits

Author SHA1 Message Date
Shadowfacts 2ee34acbad Fix remove attachment menu item not being marked destructive 2023-01-24 15:02:11 -05:00
Shadowfacts 6eee97759e Add context menu action to remove pinned timeline
Closes #334
2023-01-24 10:19:04 -05:00
Shadowfacts f88bf552af Reuse client ID/secret when trying to sign in to the same account again
Workaround for mastodon.social signins being flaky
2023-01-23 17:43:41 -05:00
Shadowfacts d2c7664073 Add profile suggestions to Explore on iPad 2023-01-23 17:10:26 -05:00
Shadowfacts e91249a876 Detect Misskey links properly 2023-01-23 16:59:24 -05:00
Shadowfacts 1eab964c0b Parse HTML in trending link card descriptions 2023-01-23 15:15:43 -05:00
Shadowfacts 2933ac491b Fix Open in Safari action not working 2023-01-23 10:35:23 -05:00
Shadowfacts 2958d2b1ac Change TrendingLinkCardCollectionViewCell to use CachedImageView 2023-01-22 18:21:58 -05:00
Shadowfacts 3262fe002b Add hover interaction to trending link cards 2023-01-22 17:37:41 -05:00
Shadowfacts 521e5ad5fc Make trend history view respond to preferred content size category 2023-01-22 17:23:22 -05:00
Shadowfacts 2b651b0bc4 Fix trending hashtag cells not adjusting to dynamic type 2023-01-22 17:23:19 -05:00
Shadowfacts 99b3532e64 Add description to trending link cards, fix not responding to dynamic type 2023-01-22 17:23:19 -05:00
Shadowfacts 2ea8e9cf1e Fix preview action on iPad Explore screen not working 2023-01-22 15:44:36 -05:00
Shadowfacts e8b7446117 Fix split view expand breaking when transferring trending statuses/hashtags/links VCs 2023-01-22 14:01:44 -05:00
Shadowfacts a47b9c0c75 Move trending statuses to Explore on iPad
See #171
2023-01-22 13:57:37 -05:00
Shadowfacts a75862b5cc Mask trending link card previews with same corner radius as cells 2023-01-22 12:08:22 -05:00
Shadowfacts 0738683ee3 Add search scopes
Closes #328
2023-01-22 11:41:38 -05:00
Shadowfacts 155f4036f9 Handle authentication required error for instance timelines 2023-01-22 11:18:43 -05:00
Shadowfacts 8181090763 Bump build number and update changelog 2023-01-21 23:01:55 -05:00
Shadowfacts 6328627a97 Fix extra spacing above content in conversation main status 2023-01-21 20:27:20 -05:00
Shadowfacts c6043d60ee Fix crash when inserting present items in empty timeline 2023-01-21 16:31:52 -05:00
Shadowfacts dd6813c058 Bump build number and update changelog 2023-01-21 15:31:35 -05:00
Shadowfacts 2229b332e0 Try to resolve statuses from links that match known patterns 2023-01-21 14:03:21 -05:00
Shadowfacts 63ed3b6e10 Add loading indicator to conversation screen 2023-01-21 13:17:11 -05:00
Shadowfacts ccd1672e72 Show highlight on expand thread cell selection 2023-01-21 13:14:16 -05:00
Shadowfacts addcc2dacc Rewrite conversation screen to use UICollectionView 2023-01-21 11:26:51 -05:00
Shadowfacts a49e9f2c1f Bump build number and update changelog 2023-01-21 11:24:19 -05:00
Shadowfacts b1421767dd Fix tapping expand thread cell not working 2023-01-20 14:17:15 -05:00
Shadowfacts 8ee916411e Further card tweaks 2023-01-20 13:58:40 -05:00
Shadowfacts 9d845bf6c1 Show loading indicator when restoring timeline state 2023-01-20 13:47:14 -05:00
Shadowfacts 9a2c24942a Fix SegmentedPageViewController next sub-page shortcut not working 2023-01-20 11:38:31 -05:00
Shadowfacts cca2a03b2f When routing the SplitNav responder chain through the root VC, go as deep into it as possible
Makes keyboard shortcuts from, e.g., TimelineVC accessible when the root is TimelinesPageVC

See #302
2023-01-20 11:34:44 -05:00
Shadowfacts 1a64bfcef8 Disallow keyboard focus in sidebar
Makes keyboard shortcuts from the split VC's primary content available

See #302
2023-01-20 11:33:28 -05:00
Shadowfacts 907810d98a Make link preview cards larger 2023-01-20 11:22:28 -05:00
Shadowfacts 23a4999196 Complete asynchronous swipe actions immediately
Fixes crash when the user things the action has failed and taps it
again, which results in an invalid completion handler later being called
2023-01-20 10:53:30 -05:00
Shadowfacts 3e0feba273 Fix collapse button disappearing when navigating away 2023-01-20 10:51:56 -05:00
Shadowfacts 468a559127 Fix crash when TimelinePosition's center status ID isn't in the list of IDs 2023-01-19 21:46:57 -05:00
Shadowfacts c03fc86300 Bump build number 2023-01-19 14:38:35 -05:00
Shadowfacts a33be0b556 Remove unused background audio mode 2023-01-19 13:13:08 -05:00
Shadowfacts 6aee926f00 Fix table views being too far inset on iPhone 2023-01-19 13:13:01 -05:00
Shadowfacts 13640be91d Bump build number and update changelog 2023-01-19 13:08:05 -05:00
Shadowfacts 5123cf20c3 Rename Delete Status -> Delete Post 2023-01-18 15:05:12 -05:00
Shadowfacts bf739b9f41 Add pagination to status actions account list 2023-01-18 15:02:56 -05:00
Shadowfacts 4211806b5f Add followers/following screen
Closes #323
2023-01-18 15:02:56 -05:00
Shadowfacts 88aada8d35 Add follower/ing counts to profile header 2023-01-18 14:02:23 -05:00
Shadowfacts 5623cedab3 Fix conversation reloading on appear 2023-01-18 13:59:42 -05:00
Shadowfacts ccfc8331fb Fix avatars not un-grayscaling on timeline 2023-01-18 11:37:15 -05:00
Shadowfacts 10803408cd Post status deleted notifications when load fails with not found 2023-01-17 20:04:48 -05:00
Shadowfacts fb7a7db6e8 Handle deleted statuses in status action account list 2023-01-17 20:02:03 -05:00
Shadowfacts 78cd1313fe Fix new conversation VC not responding to status bar taps 2023-01-17 19:36:12 -05:00
Shadowfacts db1bbf7148 Add delete status action 2023-01-17 19:32:50 -05:00
Shadowfacts 5f19adf2d0 Only show report action for other people's posts 2023-01-17 19:15:54 -05:00
Shadowfacts 6f006adbc1 Show better message when opening conv for deleted status
Also split conversation loading out into separate view controller
2023-01-17 19:15:54 -05:00
Shadowfacts 39bff06897 Fix profile header buttons not adjusting height for dynamic type size
Closes #317
2023-01-17 11:51:14 -05:00
Shadowfacts 68682ee291 Maybe fix race condition between iCloud sync and state restoration 2023-01-17 10:50:36 -05:00
Shadowfacts 5029b26b40 Bump build number and update changelog 2023-01-17 10:50:14 -05:00
Shadowfacts 907cf08400 Fix expand thread cell not adjusting to accent color pref 2023-01-16 17:54:56 -05:00
Shadowfacts e85d194e5f Make table and collection view focusable 2023-01-16 17:54:56 -05:00
Shadowfacts cfeb87d2ba Fix status collection cells being too far inset 2023-01-16 17:54:56 -05:00
Shadowfacts e4f3735c9f Don't use UIPageViewController for SegmentedPageViewController 2023-01-16 17:54:56 -05:00
Shadowfacts baa9dfe0f1 More logging 2023-01-16 15:51:03 -05:00
Shadowfacts 5e73439e7b Fix statuses being inset too much on iPhones 2023-01-16 14:21:42 -05:00
Shadowfacts 4b2776ee81 Fix conversation non-main status collapse button not adjusting to accent color preference 2023-01-16 11:54:09 -05:00
Shadowfacts 566df3e285 Bump build number and update changelog 2023-01-16 11:53:10 -05:00
Shadowfacts 0653d695d9 Fix various things not adjusting to accent color preference
Closes #325
2023-01-16 11:24:42 -05:00
Shadowfacts 4811747790 Fix crash when resuming search user activity in unloaded explore VC 2023-01-16 10:58:45 -05:00
Shadowfacts ed2519848c Prevent all pinned timelines from being removed 2023-01-16 10:55:32 -05:00
Shadowfacts b1374b12a3 More error reporting tweaks 2023-01-15 15:01:16 -05:00
Shadowfacts c5a25eecf1 Fix row separators not being inset to readable content width 2023-01-15 12:45:41 -05:00
Shadowfacts a4dbf3ddbb Add New List action to Add to List menu 2023-01-15 11:49:20 -05:00
Shadowfacts be3a61ebc7 Fix Send Report button not adapting to accent color 2023-01-15 11:48:16 -05:00
Shadowfacts ababa4b428 Add more logging around state restoration crash 2023-01-15 11:30:34 -05:00
Shadowfacts d75c2558ca Capture strong references in ToggleFollowHashtagService retry actions 2023-01-15 10:33:06 -05:00
Shadowfacts ac0dedfd3d Bump build number and update changelog 2023-01-15 10:30:17 -05:00
Shadowfacts 37563b6afd Fix @Published property being changed on background thread 2023-01-14 11:32:31 -05:00
Shadowfacts 937afc0dfd Add accent color preference 2023-01-14 11:32:31 -05:00
Shadowfacts 94c34e03dd Add reporting accounts and statuses 2023-01-14 11:03:39 -05:00
Shadowfacts 1ad556f9cf Fix crash when displaying poll finished notification 2023-01-13 15:27:48 -05:00
Shadowfacts 019f7d6d6a Fix crash if preferences change while there are cells that don't have statuses 2023-01-13 15:26:26 -05:00
Shadowfacts b4384d11f5 Delete Relationship when Account is deleted
Prevents errors when accessing dangling relationships w/o accounts
2023-01-13 10:31:51 -05:00
Shadowfacts 2ed8d22899 Fix crash when trying to restore activity for non-pinned timeline 2023-01-09 12:39:35 -04:00
Shadowfacts cce6413e2b Fix crash when trying to load deleted statuses for restoration 2023-01-08 17:56:21 -04:00
Shadowfacts 8fb0fb66e3 Start playing video attachments immediately on appear 2023-01-06 21:43:27 -04:00
Shadowfacts abe2bbdfd4 Bump build number and update changelog 2023-01-06 21:18:04 -04:00
Shadowfacts 1d9efc7fb5 Include status code in automatic mastodon error reports 2023-01-03 11:31:24 -05:00
Shadowfacts b17b7b7a24 Fix crash when inserting present items when there are no existing items 2023-01-02 17:18:30 -05:00
Shadowfacts 18d7917756 Add subjects for activity item sources 2023-01-02 17:16:31 -05:00
Shadowfacts cc401fce8c Allow sharing gifv attachments, improve share sheet behavior for images 2023-01-02 16:59:55 -05:00
Shadowfacts a5fc35d0b1 More tweaks to automatic error reporting 2023-01-02 15:14:28 -05:00
Shadowfacts acd48a6db4 When logging out, remove the scene's active account rather than the most-recently activated one, as they may not be the same 2023-01-02 11:41:47 -05:00
Shadowfacts b45d3fb80a Use WebURL for status URLs 2023-01-02 11:36:06 -05:00
Shadowfacts 3ea1ad5622 Bump build number and update changelog 2023-01-01 15:28:55 -05:00
Shadowfacts 5898da3234 Maybe fix race condition when account is loaded as profile statuses VC is dealloc'd 2023-01-01 15:27:25 -05:00
Shadowfacts 9dd966f639 Fix duplicate saved instances not being uniqued correctly 2023-01-01 15:27:25 -05:00
Shadowfacts 48662ef1f3 Bump build number and update changelog 2023-01-01 15:12:21 -05:00
Shadowfacts 854d48e54e Unique saved hashtag/instance items
This may happen when migrating to iCloud, if the same hashtag is saved
on multiple devices.
2023-01-01 14:49:04 -05:00
Shadowfacts d4c560d7fc Add createdAt to AccountPreferences and TimelinePosition to guard against race conditions when creating/migrating 2023-01-01 12:58:44 -05:00
Shadowfacts 91b7ce3008 Add pointer interaction to ToastView 2023-01-01 12:35:40 -05:00
Shadowfacts 4dca231a06 Add loading animation while syncing timeline position 2023-01-01 12:25:44 -05:00
Shadowfacts b81c83a250 Add iCloud env entitlement and ITSAppUsesNonExemptEncryption 2022-12-31 16:58:39 -05:00
Shadowfacts f9e619d9e7 Deduplicate updated timeline positions when handling remote changes 2022-12-31 16:58:20 -05:00
Shadowfacts ae7962ae50 Better Sentry messages 2022-12-31 16:57:43 -05:00
Shadowfacts 5027660b52 Maybe fix crash when restoring unloaded statuses due to race condition 2022-12-31 16:57:13 -05:00
Shadowfacts 358d81b5cf Fix crash when accessing SegmentedPageViewController before it's loaded 2022-12-31 16:46:00 -05:00
Shadowfacts 79b9108a8f Add CloudKit status indicator to advanced prefs 2022-12-31 11:24:42 -05:00
Shadowfacts 5ab22e742b Automatically report errors displayed to the user 2022-12-29 17:30:39 -05:00
Shadowfacts 4f655bb80a Change collection view deselect on appear to happen alongside nav pop 2022-12-28 15:01:21 -05:00
Shadowfacts e4f1309e2d Make everything follow the readable width 2022-12-26 12:22:17 -05:00
Shadowfacts bb40894778 Ensure all statuses are cached before returning 2022-12-26 12:09:57 -05:00
Shadowfacts 24b3fa1e3f Guard against race condition when loading card image 2022-12-26 11:27:58 -05:00
Shadowfacts 16cd045588 Show individual attachments uncropped inline in statuses 2022-12-25 14:13:59 -05:00
Shadowfacts 15a7cd5f65 Fix not being able to tap attachments in the timeline 2022-12-25 10:27:19 -05:00
Shadowfacts e676075d5b Fix spacing on toolbar when visibility and local-only items visible 2022-12-25 10:03:07 -05:00
Shadowfacts 967bff063b Tweak iCloud timeline sync 2022-12-25 09:59:35 -05:00
Shadowfacts 3cba0bce34 Update pinned timelines when changed remotely 2022-12-24 12:20:13 -05:00
Shadowfacts 60b182ac18 Sync timeline position using iCloud 2022-12-23 16:37:42 -05:00
Shadowfacts 619878ac85 Don't show Hide Reblogs/Replies prefs in Preferences, only in Customize Timelines 2022-12-23 16:37:42 -05:00
Shadowfacts 169f1a0191 Add haptic feedback to profile follow button 2022-12-23 11:19:37 -05:00
Shadowfacts fa31c28e92 Fix relationship change breaking header layout because the collection view wasn't resizing the cell 2022-12-22 18:51:55 -05:00
Shadowfacts f815d4e2e4 Replace VisualEffectImageButton with ProfileHeaderButton 2022-12-22 18:47:53 -05:00
Shadowfacts a3e5b29cfc Fix crash inserting present items when currentItems includes posts from since-unfollowed users 2022-12-22 17:57:17 -05:00
Shadowfacts 46cecde014 Add more prominent follow button to profile pages 2022-12-22 17:26:50 -05:00
Shadowfacts 86143c5887 Add window titles to main and compose scenes 2022-12-22 15:02:49 -05:00
Shadowfacts 0a1dc423d4 Fix compose attachment list buttons not using accent color on macOS 2022-12-22 14:54:41 -05:00
Shadowfacts 1cb0f1ae56 Fix non-mention notifications showing in Mentions tab on Pleroma
e0d97cd2a8 introduced a regression on Pleroma, because specifying the
allowed types of notifications in the Masto API was only added in 3.5
2022-12-22 14:41:56 -05:00
Shadowfacts 9f86158bb7 Add About screen 2022-12-22 13:59:39 -05:00
Shadowfacts 231b0ea830 Add Acknowledgements page 2022-12-21 11:59:40 -05:00
Shadowfacts 4dc108f782 Add pinned timeline customization 2022-12-20 23:37:12 -05:00
Shadowfacts 795146cde4 Cache lists in CoreData 2022-12-20 15:13:18 -05:00
Shadowfacts 975be17d13 Avoid doing unnecessary work for filtered statuses 2022-12-20 11:32:20 -05:00
Shadowfacts 32be76ebee Update UI in responds to remote changes of saved hashtags/instances 2022-12-19 13:56:46 -05:00
Shadowfacts d13b517128 Sync saved hashtags and instances over iCloud
Closes #160
2022-12-19 10:58:14 -05:00
Shadowfacts e0d97cd2a8 Fix unknown notifications appearing in the Mentions tab 2022-12-18 11:33:49 -05:00
Shadowfacts 8b718ce50b Only allow continuous scroll gestures to dismiss gallery 2022-12-17 17:55:05 -05:00
Shadowfacts ce708e2d16 Hide reblogs and hide replies filters
Closes #202
2022-12-17 13:40:15 -05:00
Shadowfacts 01467574d0 Don't show reblog swipe action when reblogging is forbidden
Closes #313
2022-12-17 13:09:33 -05:00
Shadowfacts 97a2278634 Fix previewing link in conversation main status activating link
Closes #311
2022-12-17 13:05:50 -05:00
Shadowfacts 4b2a263889 Better accessibility label for conversation toggle collapse button 2022-12-14 22:05:17 -05:00
Shadowfacts 1f37a5e7eb Bump build number and update changelog 2022-12-14 22:04:48 -05:00
Shadowfacts 77c9fac3ce Fix preferences not checking current account correctly when multiple scenes open 2022-12-14 21:27:50 -05:00
Shadowfacts a13d5d5a82 Fix crash when activating account in My Profile scene 2022-12-14 21:24:54 -05:00
Shadowfacts 23e4541eb7 Don't reload list timeline if edit screen is closed without making changes 2022-12-14 21:00:36 -05:00
Shadowfacts d4b9f71fd3 Remove old, unused code 2022-12-14 20:54:41 -05:00
Shadowfacts a9edeaf5b9 Apply filters to Trending Posts 2022-12-14 20:52:44 -05:00
Shadowfacts 1f6074e539 Fix monospace fonts not adjusting for Dynamic Type 2022-12-14 20:07:16 -05:00
Shadowfacts df7b62e14b Use KVO to invalidate LazilyDecoding properties 2022-12-14 19:46:02 -05:00
Shadowfacts cacc8a51cc Remove unused code 2022-12-14 10:15:15 -05:00
Shadowfacts 89ca0629b3 Move bundle ID prefix to xcconfig 2022-12-14 10:04:25 -05:00
Shadowfacts 360db07ef2 Fix URLs getting pasted as broken attachments
Closes #309
2022-12-14 09:47:17 -05:00
Shadowfacts f55a870964 Move development team setting to xcconfig
Closes #308
2022-12-13 23:58:44 -05:00
Shadowfacts 5ee140cdab Bump build number and update changelog 2022-12-13 21:26:28 -05:00
Shadowfacts ff4dff1147 Fix status icons flashing blue during expand/collapse
Closes #209
2022-12-13 20:56:08 -05:00
Shadowfacts ba1eed7a85 Add pointer effect to custom alert actions
Closes #306
2022-12-13 20:36:18 -05:00
Shadowfacts 0c9f6e02bd Fix controls reappearing when swiping between pages in gallery 2022-12-13 14:14:13 -05:00
Shadowfacts 565d17970f Make attachment description scrollable beyond a certain height
Closes #168
2022-12-13 14:07:16 -05:00
Shadowfacts dc3c2d027c Prevent statuses which are in the persisted timeline state from being pruned 2022-12-13 13:31:34 -05:00
Shadowfacts ba2c34fdd6 Persist timeline state using CoreData, rather than NSUserActivity
This allows persisting state for all the primary timelines, and across
all accounts.

Closes #297
Closes #293
2022-12-13 13:31:34 -05:00
Shadowfacts 3691c3f483 Actually encode the swipe action prefs 2022-12-12 23:09:18 -05:00
Shadowfacts 9c103103e8 Fix ToastableViewController automatic scroll view detection not handling collection views 2022-12-12 22:57:33 -05:00
Shadowfacts 382d8ef2c8 Fix Trending Posts appearing to reload forever 2022-12-12 22:51:50 -05:00
Shadowfacts 2891f47cb3 Fix statuses from the wrong timeline being restored into Home (again) 2022-12-12 22:47:16 -05:00
Shadowfacts 3c80ec8b43 Allow saving or following hashtag from Add screen 2022-12-12 22:06:55 -05:00
Shadowfacts 478ba3db28 Include followed hashtags in Explore and sidebar 2022-12-12 22:02:07 -05:00
Shadowfacts f96cd1b5e2 Copy showStatusesAutomatically when selecting conversation expand thread item
Closes #303
2022-12-12 21:06:05 -05:00
Shadowfacts 7f4ab57a1d Fix <li> bullets/numbers appearing black in dark mode
Closes #304
2022-12-12 21:00:12 -05:00
Shadowfacts 8caf93bf0a Add ScrollingSegmentedControl, and home/notifs/profiles to use it 2022-12-12 20:57:38 -05:00
Shadowfacts 9c4b68b09e Reorganize gestures 2022-12-12 20:56:14 -05:00
Shadowfacts b49e8d0279 Move Pachyderm to Packages folder 2022-12-11 14:25:25 -05:00
Shadowfacts 71a57e9859 Fix images copied from Safari pasting as URLs
Closes #301
2022-12-11 12:54:25 -05:00
Shadowfacts 081ef16e5e Fix My Profile item in sidebar not updating when avatar style changes
Closes #298
2022-12-10 19:41:45 -05:00
Shadowfacts b3ec259ce9 Fix status bar scroll to top not working in single-column navigation on iPad
Closes #296
2022-12-10 19:40:05 -05:00
Shadowfacts 4f48514d1a Actually only restore existing statuses 2022-12-08 20:15:12 -05:00
Shadowfacts f96acd33f2 Tweak timeline status VO labels to only include attachment text when not blurred 2022-12-06 22:29:03 -05:00
Shadowfacts cde061c77a Fix custom emoji not being stripped from usernames in VoiceOver labels 2022-12-06 22:26:08 -05:00
Shadowfacts a79b3cfd70 Fix gallery controls not being accessible, fix escape gesture not working
Closes #292
2022-12-06 22:21:59 -05:00
Shadowfacts 9a35f96c75 VoiceOver: Include attachment descriptions in timeline statuses
Closes #291
2022-12-06 22:14:23 -05:00
Shadowfacts 60767c6a7e Profile Directory screen VoiceOver improvements
Add label to filter button (and change icon to match other filters)

Make each profile a single accessibility element
2022-12-06 21:54:17 -05:00
Shadowfacts 57668886b2 Fix crash when scrolling through Local/Federated timeline with VoiceOver
It seems that the accessibility scroll mechanism does something like:
1. Find the next IndexPath to focus
2. Scroll to make it visible
3. Focus that cell

But because the timeline description cell is removed during the scroll,
the IndexPath that the accessibility system wants to focus becomes
invalid between steps 2 and 3, causing a crash when trying to focus it.

As a workaround, only remove the timeline description _item_ rather than
the header section so that section indices aren't affected.

Closes #290
2022-12-06 21:46:32 -05:00
Shadowfacts ffb5c76f7c Add preference to never blur attachments 2022-12-06 21:12:58 -05:00
Shadowfacts 00e8dd6345 Fix crash when previeiwng non-HTTP(S) link 2022-12-06 10:58:13 -05:00
Shadowfacts 7904462920 Fix serializing the nodeinfo version instead of the software version in breadcrumb 2022-12-05 22:24:33 -05:00
Shadowfacts 13d649bace Bump build number and update changelog 2022-12-05 22:24:10 -05:00
Shadowfacts bebe563e8f Further tweak persistent store migration 2022-12-05 19:32:59 -05:00
Shadowfacts 4be2258882 Fix saving expired filters not reenabling them
Closes #289
2022-12-05 19:01:32 -05:00
Shadowfacts 40ff8d0a2a VoiceOver: improve description of gap cell, add actions to specify direction 2022-12-05 18:43:32 -05:00
Shadowfacts 0dcb7e71c4 Also perform jump to present check when the timeline VC reappears onscreen 2022-12-05 18:27:23 -05:00
Shadowfacts 08878f2fb9 Re-add tusker:// scheme
Apparently it was accidentally removed in d661870401

Closes #287
2022-12-05 17:28:28 -05:00
Shadowfacts 3ea7e1057b Add preference to disable timeline state restoration 2022-12-05 17:24:01 -05:00
Shadowfacts fc8fcb76fd Fix crash when TimelineViewController tries to apply snapshot while not visible 2022-12-05 17:17:34 -05:00
Shadowfacts eac2a9b19f Move VoiceOver Jump to Present action to timeline pages segmented control 2022-12-05 17:13:45 -05:00
Shadowfacts 0ce57d1308 More fiddling with how Jump to Present works
Now, when loading present items, they're inserted into the data source
immediately along with a gap. If the user taps Jump to Present, then a
new snapshot _with only the present items_ will be applied (which allows
infinite scrolling to work properly when they scroll back down) and the
view scrolled-to-top. Tapping Go Back, then, applies the original
snapshot (i.e., the current one from when Jump to Present was tapped)
and restores the scroll position.
2022-12-05 17:09:11 -05:00
Shadowfacts 97dec0f9d2 Add accessibility hint for segmented controls 2022-12-05 16:25:16 -05:00
Shadowfacts b64c748b73 Add Jump to Present VoiceOver action
Closes #288
2022-12-04 22:06:04 -05:00
Shadowfacts 77ab2c3753 Fix Trending Posts reloading on every appearance 2022-12-04 22:03:48 -05:00
Shadowfacts b90262bfd0 Tweak fav/reblog counts pref text 2022-12-04 19:50:15 -05:00
Shadowfacts 581f4b24bd Add Sentry breadcrumb for instance software/version 2022-12-04 18:26:06 -05:00
Shadowfacts 5f3d9da9f8 Only try to restore statuses that exist in the cache
This could result in discontinuities in the restored timeline, but I'm
not sure there's anything better we could do.
2022-12-04 17:34:28 -05:00
Shadowfacts 41775e5d19 Actually migrate to new persistent store locations 2022-12-04 17:33:09 -05:00
Shadowfacts 044d34d20f Bump build number and update changelog 2022-12-04 15:40:00 -05:00
Shadowfacts f1b1732e5c Fix filter HTML to attributed string conversion optimization not being applied 🤦‍♂️ 2022-12-04 15:36:26 -05:00
Shadowfacts 1da2b17a76 Fix dynamic type not applying to timeline status content 2022-12-04 15:35:54 -05:00
Shadowfacts e49725e06d Bump build number and update changelog 2022-12-04 14:57:22 -05:00
Shadowfacts 669404d6f8 Copy local-only status from replied-to post
Closes #280
2022-12-04 14:03:12 -05:00
Shadowfacts 2e21742264 Add Cmd+Enter keyboard shortcut for sending post
Closes #283
2022-12-04 14:01:09 -05:00
Shadowfacts 7763d08816 VoiceOver: Fix not being able to select account from conversation main status cell 2022-12-04 13:51:05 -05:00
Shadowfacts 726be85223 VoiceOver: Fix profile relationship label not being read 2022-12-04 13:51:05 -05:00
Shadowfacts 19bf6cbf18 VoiceOver: Add show profile rotor action to timeline statuses
Closes #285
2022-12-04 13:51:05 -05:00
Shadowfacts df07fa85d5 Fix unsatisfiable constraints warning for ZeroHeightCollectionViewCell 2022-12-04 12:17:31 -05:00
Shadowfacts e3e55de55b Fix hide filter action not working on profiles 2022-12-04 12:11:52 -05:00
Shadowfacts 54857a3bf3 Avoid converting HTML to attributed string twice when displaying a status cell for the first time
Now, when Filterer performs the conversion, the status cell can reuse
the attributed string.
2022-12-04 12:08:22 -05:00
Shadowfacts b28f616e85 Don't apply expired filters 2022-12-04 11:55:46 -05:00
Shadowfacts 97c7104dbc Don't update constraints in StatusContentContainer.setCollapsed unless the state actually changes 2022-12-04 11:14:19 -05:00
Shadowfacts 6501343f24 Reapply filters on when they change 2022-12-04 10:54:02 -05:00
Shadowfacts fabe339215 VoiceOver: Indicate filtered posts, make double tapping expand them 2022-12-03 23:20:19 -05:00
Shadowfacts e1886509d3 Filter statuses on profiles 2022-12-03 23:11:09 -05:00
Shadowfacts 8ad48784d9 Fix V2 filter actions not saving 2022-12-03 23:11:09 -05:00
Shadowfacts 75e9c9f986 Fix home/list filters not applying to lists 2022-12-03 23:11:09 -05:00
Shadowfacts a17afe247c Better filter cell and animation for showing filtered post 2022-12-03 23:11:09 -05:00
Shadowfacts 81abcfcf7b Timeline filtering! 2022-12-03 22:16:43 -05:00
Shadowfacts 7e5d8675c2 Extract HTML to attributed string converter to separate helper 2022-12-03 18:58:19 -05:00
Shadowfacts cde3109203 Rename StatusState to CollapseState 2022-12-03 18:21:49 -05:00
Shadowfacts fcf95ba8c1 Filters view UI tweaks 2022-12-03 15:22:10 -05:00
Shadowfacts f71804f094 Extract filter create/update/delete logic into separate services 2022-12-03 14:40:12 -05:00
Shadowfacts 83ca7f1321 Creating filters UI 2022-12-03 14:40:12 -05:00
Shadowfacts 16a1e4008b V2 filters API, CoreData, and editing UI 2022-12-03 12:29:11 -05:00
Shadowfacts 518a8eba0a Start doing filters UI 2022-12-02 22:03:28 -05:00
Shadowfacts 8d56a6450e Fix mute account time not being 1 week 2022-12-02 21:39:05 -05:00
Shadowfacts 8896bfbc59 Consistent "OK" capitalization 2022-12-02 18:06:15 -05:00
Shadowfacts 4ca57f8c76 Better case-insensitive sorting for lists 2022-12-01 18:26:48 -05:00
Shadowfacts c9fa11cc3b Fetch filters and store in CoreData 2022-11-30 22:16:33 -05:00
Shadowfacts 0247c50650 Fix invalid names being used for persistent store 2022-11-30 21:35:52 -05:00
Shadowfacts eca06cb14a Fix too much space on profile header view above description 2022-11-30 21:13:48 -05:00
Shadowfacts c07e2cfdd8 Add more possibilities to relationship label on profile header 2022-11-30 17:05:18 -05:00
Shadowfacts db7615d26f Fix Edit List Accounts search field being jammed in the corner on iPad 2022-11-30 16:53:11 -05:00
Shadowfacts 2f0acad866 Return to previous item when the selected list/hashtag/instance is removed from the sidebar 2022-11-30 16:47:06 -05:00
Shadowfacts a2b3fc0628 Fix saved/followed hashtag lookups being case-sensitive 2022-11-30 16:46:18 -05:00
Shadowfacts e005b70071 Fix creating list on iPad not showing Edit List screen immediately 2022-11-30 16:34:12 -05:00
Shadowfacts b515664db3 Fix creating list on iPad overwriting previous item navigation stack 2022-11-30 16:34:05 -05:00
Shadowfacts 948eff1f7e Workaround for crash when pressing Cmd+1/2/... on macOS
See #253

The actions won't work, but it's better than crashing :/
2022-11-29 23:19:19 -05:00
Shadowfacts f1a39c2faa Add follow/unfollow hashtag actions 2022-11-29 23:14:36 -05:00
Shadowfacts ab8e498cee Refactor menu actions to allow presenting from menu bar items 2022-11-29 23:14:36 -05:00
Shadowfacts c6da754875 Indicate when a followed hashtag caused a post to appear in the home timeline 2022-11-29 23:14:36 -05:00
Shadowfacts 97d5b955a0 Store followed hashtags
The followed hashtags may not load until after the timeline request
completes, and we want to be able to show the hashtag indicator (or at
least make a best effort attempt) immediately.
2022-11-29 23:14:36 -05:00
Shadowfacts 80f9800fd6 Completely replace all items when jumping to present 2022-11-29 20:53:00 -05:00
Shadowfacts 0485400c1f Tweak how InstanceFeatures is updated 2022-11-29 20:52:39 -05:00
Shadowfacts 811aac35d7 Fix timeline statuses not getting deselected when entering split nav
Closes #275
2022-11-29 10:29:40 -05:00
Shadowfacts a77b090435 Fix mute screen layout on iPad
Closes #276
2022-11-29 10:23:00 -05:00
Shadowfacts 21874b0966 Organize expanded custom emoji picker by category
Closes #223
2022-11-28 22:13:06 -05:00
Shadowfacts 08c63a2f84 Add indicator for locked profiles 2022-11-28 21:53:45 -05:00
Shadowfacts 97f00e9d6f Indicate pending follow requests, feedback on successful async menu actions
Closes #265
2022-11-28 21:41:56 -05:00
Shadowfacts a97a7e0aea Fix attachments disappearing from status cells in certain circumstances 2022-11-28 20:40:24 -05:00
Shadowfacts cf870916c9 Fix links in conversation main status not being activatable with VoiceOver
Closes #272
2022-11-28 19:14:08 -05:00
Shadowfacts 7297566060 Fix some swipe actions getting called off the main thread 2022-11-28 19:14:08 -05:00
Shadowfacts 4f28fec62a Add links/mentions/hashtag to VoiceOver rotor in timelines
Closes #231
2022-11-28 19:14:08 -05:00
Shadowfacts c01bc4d840 Compose screen VoiceOver improvements 2022-11-28 18:40:35 -05:00
Shadowfacts ea6698a2d8 State restoration for non-home timeline pages 2022-11-28 16:33:19 -05:00
Shadowfacts 1e950b5ccb State restoration for presented and edited drafts
Closes #270
2022-11-28 16:09:29 -05:00
Shadowfacts 3e5a3c81b5 Add cache size info to Advanced prefs 2022-11-28 14:05:35 -05:00
Shadowfacts a5506aeab6 Add more tracing for notifications missing statuses
See #274
2022-11-27 21:54:58 -05:00
Shadowfacts 23b76a7276 Better crash messages for sidebar collapse/expand failures 2022-11-27 21:46:21 -05:00
Shadowfacts d8f503351b Limit edit list accounts search to accounts the user follows 2022-11-27 21:44:17 -05:00
Shadowfacts d5887f1f02 Add post edited notifications
Closes #238
2022-11-27 11:50:14 -05:00
Shadowfacts e04cdd16d6 Add preferences for status cell swipe actions
Closes #249
2022-11-26 20:26:26 -05:00
Shadowfacts c256fb4cbd When refreshing timeline, hide activity indicator as soon as loadNewer completes 2022-11-26 17:33:58 -05:00
Shadowfacts 21299c8eb8 Fix error when refreshing timeline with no items 2022-11-26 17:33:07 -05:00
Shadowfacts 527706154a Fix long status table view cells not getting collapsed 2022-11-26 17:28:55 -05:00
Shadowfacts 07c86b6949 Fix gifv attachments not being centered
Closes #271
2022-11-25 13:20:31 -05:00
Shadowfacts 92cf938e99 Fix cells not being deselected in account list and status action account list 2022-11-24 12:30:56 -05:00
Shadowfacts f23d3dfa3f Bump build number and update changelog 2022-11-24 12:24:38 -05:00
Shadowfacts 23f9e200dc Fix potential crash when trying to save timeline state 2022-11-24 12:14:19 -05:00
Shadowfacts 366834e2e4 Tweak timeline state restoration to maintain scroll position of center item 2022-11-24 11:05:56 -05:00
Shadowfacts d409d26478 Fix pressing CW button in Compose not toggling field visibility
Bring back the wrapper view, turn's out it was load bearing. We need to
be able to observe both the ui state and the draft object, while also
updating the observed draft object when the ui state's draft changes,
and this seems like the most straightforward way of doing that.
2022-11-23 14:07:03 -05:00
Shadowfacts 76fc73de95 Bump build number and update changelog 2022-11-23 12:25:27 -05:00
Shadowfacts 40800f964d Fix jump to present not scrolling all the way to the top 2022-11-23 11:58:52 -05:00
Shadowfacts 9f7d16a70e Don't show duplicate actions in status cell more actions menu 2022-11-23 11:47:00 -05:00
Shadowfacts c2cb0a0c5a Timeline state restoration 2022-11-23 11:35:25 -05:00
Shadowfacts 272f35417b Rewrite account list VC using UICollectionView 2022-11-22 15:38:40 -05:00
Shadowfacts 848c3dd950 Rewrite status action account list to use UICollectionView 2022-11-22 15:29:17 -05:00
Shadowfacts dfeb39b31f Fix selecting draft not working
Closes #263
2022-11-22 14:00:41 -05:00
Shadowfacts bab5226f2a Fix albums in asset picker not being sorted by name 2022-11-22 13:57:56 -05:00
Shadowfacts 88cfbfb1f3 Improve reblog indicator on statuses
Closes #225
2022-11-22 11:48:59 -05:00
Shadowfacts 49f1d6339f Fix crash when toggling collapse in Trending Posts
Closes #262
2022-11-22 11:47:57 -05:00
Shadowfacts 3e7cb443fa Correct post content type warning
Hometown does not support formatting
2022-11-22 11:39:47 -05:00
Shadowfacts b5c8a38b9b Add preference for using twitter-style keyboard 2022-11-22 11:06:21 -05:00
Shadowfacts ab19922530 Indicate verified profile links
Closes #241
2022-11-22 11:00:52 -05:00
Shadowfacts 45c844b065 Separate Shared Albums section in asset picker
Closes #244
2022-11-21 23:21:21 -05:00
Shadowfacts 47b838a386 Change timeline gap-filling to do a proper job of maintaining the bottom-relative scroll position 2022-11-21 22:47:44 -05:00
Shadowfacts 276691efbf Embiggen gallery share/close buttons
Closes #257
2022-11-20 21:37:57 -05:00
Shadowfacts 0a8d50cc27 Fix double-tap to zoom in gallery not working
Closes #256
2022-11-20 15:48:29 -05:00
Shadowfacts 11e81acbc1 Fix toasts not adjusting font for Dynamic Type 2022-11-20 14:15:21 -05:00
Shadowfacts fb2c9b341c Fix custom alert action icon getting squished when Dynamic Type is on
Closes #254
2022-11-20 14:12:00 -05:00
Shadowfacts 810ae71832 Make poll options in Compose reorderable with drag/drop 2022-11-20 14:06:45 -05:00
Shadowfacts 001a73af3c Workaround for profile header changing size when statuses are loaded in the background
Closes #250
2022-11-20 13:57:51 -05:00
Shadowfacts c8375b742a Make more actions button on profiles more prominent 2022-11-19 14:29:21 -05:00
Shadowfacts 9feef054fc Fix list timeline VC presenting edit screen repeatedly 2022-11-19 14:22:26 -05:00
Shadowfacts bf87ae7a7d Add Add to List menu action to accounts
Closes #247
2022-11-19 14:22:26 -05:00
Shadowfacts f8de6f9e10 Fix follow/block/mute actions showing up on user's own account 2022-11-19 14:10:19 -05:00
Shadowfacts ab47fa776e Store lists on MastodonController 2022-11-19 14:08:39 -05:00
Shadowfacts 7178473f34 Fix compose toolbar being hidden by software keyboard on iPadOS 15
Closes #252
2022-11-19 13:35:34 -05:00
Shadowfacts c8319d8af2 Remove old and debug code 2022-11-19 13:11:29 -05:00
Shadowfacts 9ff1452c68 Show jump to present toast if necessary when scene re-appears 2022-11-19 13:09:37 -05:00
Shadowfacts ce534c4a05 Actual gap cell implementation 2022-11-19 11:15:14 -05:00
Shadowfacts 0fddf94292 Timeline jump to present 2022-11-18 20:49:15 -05:00
Shadowfacts 8276e99d27 Timeline gaps and gap filling 2022-11-18 17:29:55 -05:00
Shadowfacts a5ad8e43b1 Disable attachment colorspace conversion on Mastodon v4 2022-11-15 21:45:42 -05:00
Shadowfacts ce7ce3ac92 Fix crash when requests race with own account
If the notifications/etc load first, and the table view cells are
created, mastodonController.account may still be nil
2022-11-14 21:38:24 -05:00
Shadowfacts 99a1c76cb1 Clean up instance type/feature detection
Add akkoma detection
2022-11-14 21:17:08 -05:00
Shadowfacts 603e989879 Fix error when server responds with rich cards 2022-11-14 19:39:18 -05:00
Shadowfacts dd82283341 Bump build number and update changelog 2022-11-13 18:40:40 -05:00
Shadowfacts af2d9e7eb8 Fix pleroma version detection 2022-11-13 18:24:46 -05:00
Shadowfacts 06ad46e639 Fix confirm reblog alert not adjusting to Dynamic Type
Closes #246
2022-11-13 17:15:06 -05:00
Shadowfacts 71f97d41c4 Fix certain instance features not being detected properly 2022-11-13 17:08:15 -05:00
Shadowfacts df131f32c6 Fix reblog visibility dropdown displaying even when unsupported 2022-11-13 17:07:57 -05:00
Shadowfacts 77dece36d0 Fix Hometown versions not being parsed correctly 2022-11-13 17:05:08 -05:00
Shadowfacts 1a767ff910 Fix crash when opening My Profile on iPad 2022-11-13 14:30:00 -05:00
Shadowfacts 220c8050b1 Re-add pointer effects to Compose toolbar buttons 2022-11-13 14:15:44 -05:00
Shadowfacts d4fa9c96e8 Add context menu action to delete draft 2022-11-13 14:03:51 -05:00
Shadowfacts 22b5d62ba1 Make GIF attachments animate in the Compose screen 2022-11-13 14:01:54 -05:00
Shadowfacts b9bdd29986 Fix GIFs dragged from Finder posting as static images
Closes #239
2022-11-13 13:46:19 -05:00
Shadowfacts f848bbf7c4 Remove unneeded ComposeContainerView 2022-11-12 22:59:11 -05:00
Shadowfacts 0fe9edfdbc Fix crash when opening Drafts screen on macOS 2022-11-12 22:59:11 -05:00
Shadowfacts 6d2830cf78 Rewrite Compose toolbar with SwiftUI
Fixes buttons not being accessible with VoiceOver
Fixes content overflowing on small devices

Closes #232
Closes #218
2022-11-12 22:59:11 -05:00
Shadowfacts 7294ff6e1a Status VoiceOver improvements
Closes #229
Closes #230
2022-11-12 15:17:30 -05:00
Shadowfacts 3fd62552b3 Hide redundant info from VoiceOver in mute screen 2022-11-12 14:45:30 -05:00
Shadowfacts fa5abc27f7 Make profile fields view VoiceOver accessible 2022-11-12 14:43:47 -05:00
Shadowfacts ccc47e204d Fix InstanceFeatures not correctly using pleroma version 2022-11-12 14:34:57 -05:00
Shadowfacts bf3f735062 Focus CW field immediately when CW enabled, move focus to main text view when return key pressed
Closes #226
2022-11-12 14:16:05 -05:00
Shadowfacts de0198946e Fix keyboard reappearing after pressing Post button on Compose screen 2022-11-12 13:52:36 -05:00
Shadowfacts 072a77b58e Cleanup previewing actions code 2022-11-11 23:35:30 -05:00
Shadowfacts eb7fe22863 Add mute action to profiles
Closes #201
2022-11-11 23:35:30 -05:00
Shadowfacts f1511039ef Add domain block action to profiles 2022-11-11 22:44:58 -05:00
Shadowfacts 5c479e3bf0 Convert wide-gamut images to sRGB before uploading 2022-11-11 21:02:38 -05:00
Shadowfacts 0413f326a0 Add block action to accounts
Closes #208
2022-11-11 19:09:34 -05:00
Shadowfacts 9d1c3f1410 Fix error when decoding notification that has a status field but is null 2022-11-11 18:48:58 -05:00
Shadowfacts 802a0ac9ba Fix scope selector in Profile Directory being flipped 2022-11-11 18:30:09 -05:00
Shadowfacts 9da986e3b8 Tweak heuristic for showing profile fields in single column 2022-11-11 18:26:59 -05:00
Shadowfacts e6a5b899be Add context menu action for deleting lists on iPad 2022-11-11 18:20:16 -05:00
Shadowfacts 60bf3b2e33 Fix potential crash when deleting list 2022-11-11 18:16:44 -05:00
Shadowfacts b465838b71 Fix renaming list not updating UI
Closes #213
2022-11-11 18:08:44 -05:00
Shadowfacts 21bd716844 Fix crash when creating list fails
Closes #212
2022-11-11 17:54:25 -05:00
Shadowfacts 523fb91b21 Add scope to search following accounts when editing list
Also fixes crash when loading or editing list

Closes #216
Closes #221
2022-11-11 17:33:48 -05:00
Shadowfacts d8bf770902 Instance selector tweaks
Closes #234
Closes #237
2022-11-10 17:05:51 -05:00
Shadowfacts 10aa32d9cc Don't use UIPageViewController for profiles
Closes #228
2022-11-10 17:00:46 -05:00
Shadowfacts 7474969969 Workaround for AVPlayerViewController controls not respecting safe area
Closes #176
2022-11-09 21:46:52 -05:00
Shadowfacts 319b5458fc Fix refreshing not loading initial when previous attempt failed
Closes #214
2022-11-09 19:15:08 -05:00
Shadowfacts f7304a011c Fix images not being cached
Fixes #219
2022-11-09 18:56:59 -05:00
Shadowfacts 94dc5d3177 Fix not being able to tap links in profile fields
Closes #211
2022-11-09 18:51:27 -05:00
Shadowfacts 6d692c2730 Rewrite Drafts screen with SwiftUI 2022-11-09 18:18:31 -05:00
Shadowfacts d0f8691560 Fix draft cells become untappably small 2022-11-09 17:20:56 -05:00
Shadowfacts 9a43ab5a13 Fix caret not scrolling into view when focusing compose text views
Closes #233
2022-11-09 17:18:17 -05:00
Shadowfacts 01124b76a3 Add Duckable package, make Compose screen duckable 2022-11-08 22:17:01 -05:00
Shadowfacts 7600954f4b Refactor ComposeView to use a single List for everything 2022-11-07 22:58:01 -05:00
Shadowfacts 5a5c67e445 Try to prevent pruning accounts that still have statuses referencing them 2022-11-07 18:47:46 -05:00
Shadowfacts 68c3affacf Bump build number and update changelog 2022-11-05 18:31:22 -04:00
Shadowfacts e40f4faa8e Rewrite TrendingStatusesViewController to use collection view 2022-11-05 15:13:20 -04:00
Shadowfacts b56c6c37ec Fix crash when ProfileHeaderView tries to create observers after ProfileVC is deinit'd
Can happen if the network is slow and the user closes the profile screen before the header loads
2022-11-05 14:42:40 -04:00
Shadowfacts 999118798c Fix inserting pinned items that already exist when refreshing profile 2022-11-05 14:38:08 -04:00
Shadowfacts 84cf755332 Fix drawing VC background flickering in dark mode
Closes #199
2022-11-05 14:29:45 -04:00
Shadowfacts 5bd7c0ad2b Add preference to prevent blurring media behind CW
Closes #203
2022-11-05 13:20:55 -04:00
Shadowfacts 7fe06d42ce Consider content height, not just char count, when collapsing posts
Closes #205
2022-11-05 13:11:36 -04:00
Shadowfacts 20986ba3f0 Add preference for default reply visibility
Closes #207
2022-11-05 12:20:30 -04:00
Shadowfacts 97a95c435e Improve performance when displaying posts with many custom emojis
Closes #204
2022-11-05 11:00:14 -04:00
Shadowfacts b9555cf7dd Dynamic type support in assorted places 2022-11-04 22:32:40 -04:00
Shadowfacts 590b9f0bcc Dynamic type support on notifications screen 2022-11-04 22:32:34 -04:00
Shadowfacts ca2ceaea56 Remove now-unused confirm load more table view cell 2022-11-04 22:32:34 -04:00
Shadowfacts 96d8a79d42 Dynamic type support in Explore screen 2022-11-04 21:47:42 -04:00
Shadowfacts 11233f7d25 Dyanmic type support in profile header view 2022-11-04 21:39:47 -04:00
Shadowfacts a991e0f429 Dynamic Type support in status cells 2022-11-04 16:52:37 -04:00
Shadowfacts bfdce07d81 Fix compose reply avatar being wrongly aligned for 1-line statuses 2022-11-03 19:14:52 -04:00
Shadowfacts f5953655c5 Set merge policy on managed object contexts and maybe fix some CoreData errors? 2022-11-03 18:56:06 -04:00
Shadowfacts 6bc4993d81 Fix favorite/reblog menu actions not working 2022-11-03 18:48:39 -04:00
Shadowfacts 68646c4b4d Fix objc associated objects not working in release builds 2022-11-03 18:37:32 -04:00
Shadowfacts 38b0d57118 Improve CoreData error reporting 2022-11-03 10:27:45 -04:00
Shadowfacts b38c24b347 Bump build number and update changelog 2022-11-02 23:48:53 -04:00
Shadowfacts a6d51cee3c More fiddling with the sentry script 2022-11-02 23:47:14 -04:00
Shadowfacts 7bdbd9f71a Handle task cancellation in MastodonController.run 2022-11-02 23:00:29 -04:00
Shadowfacts b47876dc3d Fix retain cycle due to account follow action workaround 2022-11-02 22:59:44 -04:00
Shadowfacts 4644475bc7 Fix crashes when ProfileStatusesVC doesn't finish loading until ProfileVC is deinit'd 2022-11-02 22:53:07 -04:00
Shadowfacts 16ba292afa Remove debug print 2022-11-02 22:34:40 -04:00
Shadowfacts c7f3bac330 Add sterner warning about post content type 2022-11-02 22:06:08 -04:00
Shadowfacts abb8352c92 Fix ImageCache.get completion not being called when image isn't loaded 2022-11-02 22:06:08 -04:00
Shadowfacts 59d866aa23 Ditch custom image request grouping, rely on URLSession's 2022-11-02 22:06:08 -04:00
Shadowfacts ba032412eb Fix timeline reloading every time VC appears
Caused by changes to TimelineLikeController required to let list
timelines reload from scratch
2022-11-02 22:06:07 -04:00
Shadowfacts 5de0c034f4 Remove old TimelineTableViewController 2022-11-01 21:11:13 -04:00
Shadowfacts b1d83f2746 Switch hashtag/instance/list timelines to use new collection view impl 2022-11-01 21:10:41 -04:00
Shadowfacts 658c08010d Re-add undo scroll-to-top to timelines/profiles 2022-11-01 20:49:07 -04:00
Shadowfacts 6a5753fac8 Fix crash when tapping Load More button with Disable Infinite Scrolling 2022-10-31 17:45:36 -04:00
Shadowfacts 8da89986df Fix find instance VC requiring double dismiss 2022-10-31 17:39:57 -04:00
Shadowfacts c7e39cb041 Use short descriptions in instance selector when available 2022-10-31 17:35:50 -04:00
Shadowfacts b755607895 Fix crash when TimelineStatusTableViewCell outlives its containing VC 2022-10-31 17:33:33 -04:00
Shadowfacts 508eef8c07 Nothing to see here 2022-10-31 17:33:33 -04:00
Shadowfacts a18dfc38af Fix crash when refreshing profile before it has loaded 2022-10-31 17:33:33 -04:00
Shadowfacts 95f9fad673 Tweak Sentry config 2022-10-31 17:33:33 -04:00
Shadowfacts 4857b507b1 Send CoreData saving errors to Sentry 2022-10-31 12:26:09 -04:00
Shadowfacts bca7bd3586 Tweak sentry upload script and fix using dist build config in debug 2022-10-31 12:25:54 -04:00
Shadowfacts 9978e392a2 Bump build number and update changelog 2022-10-31 12:25:37 -04:00
Shadowfacts cc33cf18f2 Workaround for follow menu item never resolving on macOS
See #198
2022-10-30 18:54:14 -04:00
Shadowfacts c5921bc4cb Add option to disable automatic crash reporting 2022-10-30 18:17:53 -04:00
Shadowfacts 91450ced7c Use Sentry for crash reporting 2022-10-30 17:10:58 -04:00
Shadowfacts 5afd9e83eb Shhh 2022-10-30 14:47:36 -04:00
Shadowfacts d05275020f Tweak timeline status cell spacing 2022-10-29 21:18:01 -04:00
Shadowfacts c420c236d9 Whoops 2022-10-29 21:06:27 -04:00
Shadowfacts d5433e9b91 Fix crash when opening profile view controller with uncached account
E.g., by tapping a mention in a status
2022-10-29 18:55:13 -04:00
Shadowfacts cbbe9ec11f Fix crash in profile due to accessing data source before it exists
This could happen if an account is updated in the background while a
profile is on screen and the user has not visited all of the tabs.
2022-10-29 18:40:41 -04:00
Shadowfacts 0e06d47687 Fix status collapse changes not animating on profiles 2022-10-29 18:27:24 -04:00
Shadowfacts c907b7257a Bump build number and update changelog 2022-10-29 18:27:12 -04:00
Shadowfacts 10239d14c9 Fix selected segment not updating on profiles when switching tabs with keyboard shortcuts 2022-10-29 15:08:03 -04:00
Shadowfacts 2344275ff9 Enable blurhash in debug
Capping the size at 32x32 means this is fast enough even in un-optimized builds
2022-10-29 14:19:43 -04:00
Shadowfacts e0ffa1d9c5 Cap blurhash image size at 32x32 2022-10-29 14:19:43 -04:00
Shadowfacts 77a6654ff2 Fix crash when generating blurhash image for AttachmentView that hasn't been laid out
It was passing a negative size into the blurhash decoder, which is invalid

Instead, cap the size at 32x32 (letting the image view scale it up when rendering)
2022-10-29 14:19:43 -04:00
Shadowfacts 43aee0ec67 Add pointer interaction to avatar in timeline status cell 2022-10-29 14:19:43 -04:00
Shadowfacts d95ba82e5b Improve pointer interaction on new status cell action buttons
Closes #195
2022-10-29 14:19:43 -04:00
Shadowfacts b6d8232951 Fix replies appearing multiple times in drafts 2022-10-29 14:19:43 -04:00
Shadowfacts bb9cef55ea Don't remove persistent data when clearing cache 2022-10-29 14:19:43 -04:00
Shadowfacts 67718d8fe4 Fix wrong logs getting sent with crash reports 2022-10-29 14:19:43 -04:00
Shadowfacts 71a2029752 Switch everything to new profile view controller 2022-10-28 21:38:56 -04:00
Shadowfacts 6bb1f3b7dc Finish converting profiles to collection views 2022-10-28 21:31:18 -04:00
Shadowfacts 2469d285bc Initial implementation of profile switching with collection views 2022-10-28 19:17:33 -04:00
Shadowfacts 5f410213e2 Start converting profile statuses to collection view 2022-10-28 19:17:33 -04:00
Shadowfacts bb3e1b44b1 Hide live text controls when other gallery controls are hidden
Closes #189
2022-10-28 19:16:00 -04:00
Shadowfacts 868df25417 Disable pruning offscreen rows in new timelines
I don't think this is actually necessary, the system should kill us
often enough that the amount of items in the data source doesn't become
unmanageable.

Making modifications to the data source in viewDidDisappear was causing
the collection view's contentOffset to change to be scrolled to top
(roughly) when the view became visible again.

Disabling it also fixes several issues caused by updating the data
source even when there were no changes.

Closes #193
Closes #192
Closes #187
Closes #186
2022-10-28 19:05:07 -04:00
Shadowfacts 2801f65e67 Fix reblog labels in new cells not being tappable
Closes #197
2022-10-28 18:48:30 -04:00
Shadowfacts cccde29e6c Fix crash when long-pressing Send Report button on iPad
Closes #190
2022-10-27 23:11:21 -04:00
Shadowfacts aa0629d202 Don't dismiss issue reporter when email is cancelled
Closes #191
2022-10-27 23:10:00 -04:00
Shadowfacts ba209fa4d2 Protect DiskCache.fileStates with a lock
Closes #194
2022-10-27 23:06:50 -04:00
Shadowfacts d224f47b8c Fix long content warnings getting truncated in new status cells
Closes #185
2022-10-11 17:04:31 -04:00
Shadowfacts ffb0ceba20 Remove old XCB code 2022-10-11 10:10:55 -04:00
Shadowfacts 22022f5ef6 Bump build number and update changelog 2022-10-10 19:04:26 -04:00
Shadowfacts 1ac72bc363 Fix collection view cells not deselecting in split nav controller on iPad 2022-10-10 18:58:07 -04:00
Shadowfacts dcc8f38f3d Fix key commands not working inside split nav controller on iPad
Fixes #179
2022-10-10 18:58:07 -04:00
Shadowfacts 8cf217d2ba Fix crash when trying to prune rows before statuses have loaded 2022-10-10 16:21:08 -04:00
Shadowfacts 7d66117fab Fix mentions from Misskey opening browser instead of profile view 2022-10-10 14:31:26 -04:00
Shadowfacts 9c0c1f87f8 Fix links/mentions/hashtags in timeline statuses not being tappable 2022-10-10 14:26:47 -04:00
Shadowfacts 7a2d8e78eb Attempt the third at making debug logging work in TestFlight 2022-10-10 14:25:25 -04:00
Shadowfacts c15a5fc90f Fix reblog statuses being selected in timeline 2022-10-10 14:23:27 -04:00
Shadowfacts 212ce69ffd Log when status unexpectedly doesn't have URL 2022-10-10 14:21:12 -04:00
Shadowfacts 7470b053c6 Bump build number and update changelog 2022-10-09 22:02:17 -04:00
Shadowfacts d1b4b39e86 Fix MultiThreadDictionary crash on iOS 15 due to using existential types
See #178
2022-10-09 21:53:58 -04:00
Shadowfacts b43f0d5bd9 Bump build number and update changelog 2022-10-09 20:53:45 -04:00
Shadowfacts 035034430e Fix crash when hovering with the cursor over certain text views
Closes #183
2022-10-09 20:49:08 -04:00
Shadowfacts a703b7cc0a Prune offscreen rows on new timeline 2022-10-09 20:11:00 -04:00
Shadowfacts e78bec8409 Fix sensitive attachments not being hidden in new timeline 2022-10-09 19:15:41 -04:00
Shadowfacts 412e4a4dc5 Fix public timeline descriptions not working
Closes #182
2022-10-09 19:11:34 -04:00
Shadowfacts 81e10326d3 Add logging to persistent store 2022-10-09 17:09:55 -04:00
Shadowfacts 20f88ef161 Fix debug logs not working
Apparently only values in Info.plist do substitution
2022-10-09 16:46:40 -04:00
Shadowfacts bce0f8ef18 Bump build number and update changelog 2022-10-09 14:46:48 -04:00
Shadowfacts d661870401 Include log data in issue/crash reports 2022-10-09 14:26:44 -04:00
Shadowfacts afa1a733f4 Remove old XCB docs 2022-10-09 13:53:14 -04:00
Shadowfacts 1b186725ce Re-add timeline context menus 2022-10-08 23:47:42 -04:00
Shadowfacts 164a8e26c4 Fix not being able to press attachments in new status cells 2022-10-08 19:10:21 -04:00
Shadowfacts cadcc1a92a Don't navigate to profile when tapping name stack in timeline status
Otherwise it's too difficult to open short posts
2022-10-08 16:53:48 -04:00
Shadowfacts bcb3c24027 Fix context menu presentation animation getting clipped in new status cells 2022-10-08 16:53:48 -04:00
Shadowfacts fd6a4ba41c Fix update timestamp work item firing too frequently
A reconfiguration would schedule a new work item without cancelling the
old one, resulting in the timestamp updating multiple times in quick
succession (noticeable for statuses <60s old).
2022-10-08 16:53:48 -04:00
Shadowfacts 3ab82b2dbb Fix attachments/cards flickering in new cells on reconfiguration 2022-10-08 16:53:48 -04:00
Shadowfacts 1ed218d5e3 Fix new status cells not showing meta indicators or reblog button visibility 2022-10-08 16:53:48 -04:00
Shadowfacts 0fee770411 Fix crash when displaying new status cells with polls 2022-10-08 15:12:17 -04:00
Shadowfacts 5b116c0d4e More logging! 2022-10-08 15:12:10 -04:00
Shadowfacts b7a4f7e30f Make tapping content warning label toggle expand/collapse 2022-10-08 15:03:50 -04:00
Shadowfacts ba1300b1b7 Re-add status cell dragging 2022-10-08 15:01:23 -04:00
Shadowfacts 817ef0c2cc New timeline key commands 2022-10-08 14:53:21 -04:00
Shadowfacts 18ee621489 Status cell swipe actions 2022-10-08 14:33:07 -04:00
Shadowfacts ddf5094acf Only show collapse button on collapsible statuses 2022-10-08 13:21:01 -04:00
Shadowfacts 133921848d Extract favoriting/reblogging to separate services
Allows displaying error popups and retrying
2022-10-08 13:19:32 -04:00
Shadowfacts 46db70d58b Fix building in release mode
When handleEvent dispatches to the other methods, it crashes the compiler
during an optimization pass. Seems to be related to:
https://github.com/apple/swift/issues/61350
2022-10-08 11:45:02 -04:00
Shadowfacts 21958eb77f Merge branch 'develop' into collection-timelines 2022-10-08 11:01:19 -04:00
Shadowfacts b30f149dc9 Use mutex on iOS 15 instead of os_unfair_lock
See #178
2022-10-08 10:57:59 -04:00
Shadowfacts 9b83566482 Fix TuskerTests not compiling 2022-10-08 10:55:55 -04:00
Shadowfacts b688631937 Update status cells on status changes 2022-10-06 22:36:55 -04:00
Shadowfacts 4d654358d7 Extract a bunch of common stuff to StatusCollectionViewCell protocol 2022-10-05 23:19:30 -04:00
Shadowfacts 24e90de672 Status cell interaction 2022-10-05 22:28:10 -04:00
Shadowfacts 780e8b09b7 Status cell UI 2022-10-05 21:39:58 -04:00
Shadowfacts 2196663d94 Make StatusContentContainer play nice with hiding subviews 2022-10-04 22:48:42 -04:00
Shadowfacts 7085ac01cb Timeline status collection view cell collapsing 2022-10-04 00:02:41 -04:00
Shadowfacts 81671d73c7 Start converting timeline status to UICollectionViewCell 2022-10-04 00:01:16 -04:00
Shadowfacts a38c89a17f Re-add public timeline descriptions 2022-10-01 15:32:06 -04:00
Shadowfacts 253fb8d27d Extract more things to TimelineLikeCollectionViewController 2022-10-01 15:08:51 -04:00
Shadowfacts a682c8f5cc Extract a bunch of timeline view controller stuff to separate protocol 2022-09-24 11:39:12 -04:00
Shadowfacts d18a4b3c42 Fixing loadInitial happening multiple times 2022-09-24 11:31:52 -04:00
Shadowfacts 426b31d46c Initial TimelineLikeController + TimelineViewController implementation 2022-09-24 10:49:06 -04:00
Shadowfacts 5c09b1910f Cleanup/reorganize some things 2022-09-19 22:52:52 -04:00
Shadowfacts fe72d8faec Remove x-callback-url support
Closes #1
2022-09-19 22:44:27 -04:00
Shadowfacts b560bcd8dc Prevent loading indicator from potentially being added multiple times
Not sure how this could happen, but it's caused 1 crash in the wild so w/e
2022-09-19 22:35:27 -04:00
Shadowfacts 85ced7ff5f Bump build number and update changelog 2022-09-19 15:05:10 -04:00
Shadowfacts 5ac76ef9c4 Revert "Maybe fix timeline discontinuities"
This reverts commit 43b4976ed7.

That commit reintroduced #166
2022-09-18 22:37:18 -04:00
Shadowfacts 123a512d3c Bump build number and update changelog 2022-09-18 22:14:54 -04:00
Shadowfacts d141ed7d03 Enable reblog with visibility on Pleroma 2022-09-18 22:01:57 -04:00
Shadowfacts 95e120afd6 Fix large image controls not being hidden on iPhone 14 Pro 2022-09-18 11:30:50 -04:00
Shadowfacts ca8a214cf6 Add reblog with visibility menu to reblog confirmation alert 2022-09-18 11:28:33 -04:00
Shadowfacts 7161861d36 Add API param for reblog visibility 2022-09-18 11:28:33 -04:00
Shadowfacts c6c8f63e39 Fix compose reply view not working after ContentTextView refactor, use named CoordinateSpace for calculating scroll offset in reply avatar view 2022-09-18 11:28:33 -04:00
Shadowfacts e9962997a6 Show preview of status in reblog confirmation alert
Closes #121
2022-09-17 20:27:36 -04:00
Shadowfacts f2ab1778c5 Replace expanded emoji picker with SwiftUI 2022-09-15 21:49:50 -04:00
Shadowfacts 0f71d61b88 Fix crash when there are duplicate emojis
Closes #164
2022-09-15 21:10:52 -04:00
Shadowfacts 80c4fcce82 Use AnyAccount instead of EitherAccount for compose autocomplete 2022-09-15 21:05:18 -04:00
Shadowfacts 8f8d50efbd Bring back StatusProtocol 2022-09-15 21:04:53 -04:00
Shadowfacts 43b4976ed7 Maybe fix timeline discontinuities
See #174
2022-09-15 20:54:28 -04:00
Shadowfacts ff3681627b Fix reblog status cell not showing selection background in spacer
Closes #175
2022-09-15 20:45:45 -04:00
Shadowfacts 35d21fb725 Switch to stable, hash-based account IDs
#160
2022-09-12 23:05:35 -04:00
Shadowfacts bbfb3b0a7a Add loading indicator to DiffableTimelineLikeTableViewController 2022-09-12 22:05:19 -04:00
Shadowfacts 8b78a5e7ad Don't parent background managed object contexts to view context
Otherwise, certain operations require the background contexts to
interact with the view context, which can block the main thread from
accessing the view context (potentially causing hitches if the view
context access is in a critical path, like cell fetching).
2022-09-11 23:00:51 -04:00
Shadowfacts 66c17006d1 Fix poll votes displaying random number
i have no idea where the number was coming from
2022-09-11 22:35:09 -04:00
Shadowfacts 8a911f238b Fix emojis getting set without setting emoji identifier 2022-09-11 22:20:46 -04:00
Shadowfacts 77c44c323f Use os_unfair_lock for MultiThreadDictionary instead of DispatchQueue 2022-09-11 22:20:46 -04:00
Shadowfacts c2d1fe45d8 Update for iPhone 14 series 2022-09-07 18:43:46 -04:00
Shadowfacts 24591cee05 Improve account switching animation 2022-08-01 21:29:24 -04:00
Shadowfacts 50dd785ef8 ContentTextView cleanup 2022-07-31 19:39:14 -04:00
Shadowfacts af2e95ea39 Fix apparent crash when tapping tab bar item of selected tab 2022-07-11 15:07:11 -04:00
Shadowfacts 4fa1bd7268 Fix crash due to nested navigation controllers 2022-07-11 14:59:01 -04:00
Shadowfacts ea07e6aef6 Simplify timeline status cell layout, fix due to missing constraint
Fixes crash when re-showing timeline actions after being hidden
2022-07-11 14:42:49 -04:00
Shadowfacts 5e7a1e5974 Bump build number and update changelog 2022-07-09 12:05:17 -04:00
Shadowfacts 9b3cc61dcb Update WebURL to version with IDNA support
Closes #163
2022-07-09 11:45:27 -04:00
Shadowfacts 0c37b99a68 i don't even remember 2022-07-09 11:26:37 -04:00
Shadowfacts f96d1d780c Enable data detectors on main status text view
Tapping detected items doesn't work because it conflicts with our tap
gesture recognizer, but long pressing does
2022-07-09 11:25:23 -04:00
Shadowfacts 5a5364ad3b Use iOS 16 API for disabling compose attachment list scrolling 2022-07-09 11:02:01 -04:00
Shadowfacts 5b70c713b2 Two column navigation on iPad 2022-07-06 17:47:40 -04:00
Shadowfacts efb96eddf3 Fix compiling for Catalyst 2022-07-02 11:33:15 -07:00
Shadowfacts 5cb25c8c1f Move trending hashtags/links to Explore tab on iPad 2022-06-30 19:53:40 -07:00
Shadowfacts 700cc2c67c temp env var 2022-06-30 19:24:49 -07:00
Shadowfacts a9e0bffe5f Bump deployment target to iOS 15 2022-06-30 19:04:08 -07:00
Shadowfacts 512e0e9053 Fix passing invalid points to CoreGraphics when building trend history graph 2022-06-30 18:15:13 -07:00
Shadowfacts b842389449 Convert trending hashtags to collection view 2022-06-30 18:15:13 -07:00
Shadowfacts cc10a13785 TextKit 2, baby 2022-06-29 00:12:45 -07:00
Shadowfacts f9c3ad5921 Bring back interactive keyboard dismissal on compose screen 2022-06-28 17:30:04 -07:00
Shadowfacts 0960699699 Fix building for iOS 14 2022-06-28 17:29:46 -07:00
Shadowfacts c6e06fe9f3 Use SwiftUI for sheet presentation detents on iOS 16 2022-06-28 17:29:46 -07:00
Shadowfacts 10f6a68065 Use new-style self-sizing cells on iOS 16 2022-06-28 17:29:46 -07:00
Shadowfacts 037b717e60 Include filename extension for attachments
Fixes posting attachments on pleroma resulting in them served as
application/octet-stream, even though we're sending the mime type as well
2022-06-28 17:29:46 -07:00
Shadowfacts 9fa352d4f8 Fix retain cycle in DiffableTimelineLikeTableViewController 2022-06-28 17:29:46 -07:00
Shadowfacts 73345bb927 Always used stacked search field in instance selector 2022-06-28 17:29:46 -07:00
Shadowfacts f5385b0a1d Use context menu for filter/sort on profile directory 2022-06-28 17:29:46 -07:00
Shadowfacts 46fbbdc99a Always use stacked search bar placement on iPadOS 16 2022-06-10 23:44:52 -04:00
Shadowfacts 6ef8c92d09 Update to recommended Xcode settings 2022-06-10 23:44:52 -04:00
Shadowfacts 08b7cf013b Use browser-style navigation bars on iPad 2022-06-10 23:44:52 -04:00
Shadowfacts f702df2f15 Add context menu action for deleting draft so it's accessible by cursor 2022-06-10 23:44:52 -04:00
Shadowfacts 92efee6f46 Fix crash when loading older/newer notifications on Pixelfed
Damn Pixelfed returning nonsensical pagination links

Closes #166
2022-06-10 23:44:52 -04:00
Shadowfacts facf039f97 Live text in gallery view 2022-06-10 23:44:52 -04:00
Shadowfacts d7f35cd1e4 Bring back interactive keyboard dismissal on Compose screen 2022-06-10 23:44:52 -04:00
Shadowfacts 332637e0d9 Add edit menu actions 2022-06-10 23:44:52 -04:00
Shadowfacts 6d6fd3d49d Maybe fix crash in sceneDidEnterBackground 2022-06-10 23:44:52 -04:00
Shadowfacts b4675a97c7 Add missing awaits due to changed overload resolution 2022-06-10 23:44:52 -04:00
Shadowfacts 02e3417c27 Full size attachment previews on Compose screen (iOS 16)
Closes #110
2022-06-10 23:44:44 -04:00
Shadowfacts f5ac2616ad Disable unnecessary UIAppearance hacks on iOS 16 2022-06-07 09:42:33 -04:00
Shadowfacts 01bb37b0f6 Fix warning 2022-06-06 23:58:43 -04:00
Shadowfacts a4d43889ce Fix crash when opening conversations in new windows 2022-06-06 23:00:57 -04:00
Shadowfacts 4991da1622 Add favorite/reblog menu actions on iOS 16 2022-06-06 22:58:14 -04:00
Shadowfacts f106cc78bb Fall back to Foundation URL if WebURL parsing fails
WebURL doesn't support Unicode domains/IDNA
2022-05-17 11:57:59 -04:00
Shadowfacts 2617d22819 Show notifications for other people's posts
Closes #161
2022-05-17 10:36:33 -04:00
Shadowfacts dbdf1d39bd Bump build number and update changelog 2022-05-17 10:31:56 -04:00
Shadowfacts 54ff3893a6 Slightly improve ActionNotificationGroupTableViewCell layout 2022-05-17 10:19:04 -04:00
Shadowfacts 0168c05259 More detailed error message for decoding hashtag urls 2022-05-17 10:18:28 -04:00
Shadowfacts 65e75afa8b Fix using -[NSObject description] instead of attachmentDescription field 2022-05-16 22:53:27 -04:00
Shadowfacts 90809811c1 Clean up ActionNotificationGroupTableViewCell avatar fetching code 2022-05-16 22:52:04 -04:00
Shadowfacts 0f6e9c97cc Bump build number and update changelog 2022-05-15 17:40:01 -04:00
Shadowfacts 98516e3802 Fix multiple lines of emojis (e.g., wordle) getting smushed together 2022-05-15 15:42:48 -04:00
Shadowfacts 68b03838a2 Fix saved hashtags sorting being case-sensitive 2022-05-15 10:37:38 -04:00
Shadowfacts 1f0025b101 Fix Send Message action not working on iPad/Mac 2022-05-15 10:34:39 -04:00
Shadowfacts b46f007f64 Fix Cmd+N shortcut for Compose not working on Mac (Catalyst or Designed
for iPad)
2022-05-15 10:34:24 -04:00
Shadowfacts ecab33bdce Better generics for LazilyDecoding 2022-05-13 17:33:07 -04:00
Shadowfacts cc0da2ec54 Fix user activities not continuing when passed at launch
Fix crash when continuing user activities on iPad
2022-05-13 17:10:18 -04:00
Shadowfacts a2868739c2 Fix crash when poll voting fails 2022-05-13 10:00:11 -04:00
Shadowfacts 2f75510889 Disable transparent nav bar in conversation vc 2022-05-11 19:15:56 -04:00
Shadowfacts 46332cd1b9 Jump to statuses below parent when expanding subthread in conversation 2022-05-11 19:12:28 -04:00
Shadowfacts 21e9ca990d Use async/await for conversation loading 2022-05-11 19:10:38 -04:00
Shadowfacts 1a02319894 Fix using old style for show all statuses bar button item when showing a
conversation that initially expands all statuses
2022-05-11 11:33:18 -04:00
Shadowfacts 4a95ccccdb Show expand thread indicator when there are additional replies to an
intermediate post in thread authored by a single person
2022-05-11 11:20:01 -04:00
Shadowfacts d3187ce2c4 Move saved instances and hashtags to CoreData 2022-05-10 22:58:30 -04:00
Shadowfacts ed0643c4ad Change explore swipe action titles 2022-05-10 22:58:30 -04:00
Shadowfacts 1e2947ceba Fix crash when accept/reject follow request fails 2022-05-10 22:58:30 -04:00
Shadowfacts ddcb13dd28 Fix notifications sometimes getting deleted in group merging
Closes #156
2022-05-10 22:58:25 -04:00
Shadowfacts c71bf3ba23 Fix displaying toasts from non-main queue 2022-05-09 15:55:35 -04:00
Shadowfacts 3e5c441b24 Fix crash when refreshing polls 2022-05-09 15:54:27 -04:00
Shadowfacts 0b6c16b0a6 Fix newly created statuses/accounts not having lastFetchedAt set
awakeFromFetch is only called on existing objects
2022-05-06 10:24:50 -04:00
Shadowfacts 5f566724bb Fix compose CW field overflowing 2022-05-03 20:14:55 -04:00
Shadowfacts 4a89ae3cfe Don't cache state of follow menu action
Fixes #151
2022-05-02 17:59:03 -04:00
Shadowfacts 56a0518c80 Add toast error messages to menu actions 2022-05-01 23:06:59 -04:00
Shadowfacts bf8a294676 Split MenuActionProvider from MenuPreviewProvider 2022-05-01 23:05:23 -04:00
Shadowfacts c069712c22 Don't include Open in Tusker on Catalyst 2022-05-01 21:50:16 -04:00
Shadowfacts d04957ba41 Remove reference counting system
Delete statuses/accounts that haven't been fetched in a week
2022-05-01 21:50:16 -04:00
Shadowfacts 8cc08cf4c0 Fix crash when displaying polls on Catalyst in Optimize for Mac
Closes #152
2022-05-01 21:50:11 -04:00
Shadowfacts 1b917f6bed Fix saved hashtags not getting persisted 2022-05-01 12:05:38 -04:00
Shadowfacts 514e569bd5 Fast account switching on iPad 2022-05-01 11:53:12 -04:00
Shadowfacts a22059a1a1 Show current user avatar in sidebar 2022-04-30 13:05:20 -04:00
Shadowfacts 2cfefc9432 Add "Add Account" placeholder to fast account switcher 2022-04-30 11:46:14 -04:00
Shadowfacts 2f7c7bae5e Extract status posting to separate class, convert to async/await 2022-04-30 11:11:22 -04:00
Shadowfacts 3f04d74dd6 Better error messages when exporting video fails 2022-04-27 23:33:29 -04:00
Shadowfacts 4dd8c1d692 Add subtitles to visibility context menu items
Closes #155
2022-04-27 23:21:08 -04:00
Shadowfacts eb9a5aeb42 Perform grouping with existing notifications when refreshing
Closes #88
2022-04-26 22:57:46 -04:00
Shadowfacts 7465abe0a9 Fix crash when loading account 2022-04-26 22:11:19 -04:00
Shadowfacts 20dab7c77a Handle missing account emojis on pixelfed instances 2022-04-26 17:50:23 -04:00
Shadowfacts 4e105e0fbc Fix table view cell gesture blocking toast long-press
Fixes #149
2022-04-26 13:29:22 -04:00
Shadowfacts d2f1d78aa2 Fix crash when preferences are changed before own account is loaded 2022-04-25 18:53:51 -04:00
Shadowfacts 360f52d0cf Don't crash when saving persistent store fails 2022-04-25 18:51:16 -04:00
Shadowfacts 8c888906c9 Bump build number and update changelog 2022-04-25 16:30:52 -04:00
Shadowfacts d611aeb035 Change selector names because apparently App Store Connect thinks the old ones are SPI now 2022-04-25 16:30:44 -04:00
Shadowfacts 0e888d35eb Revert "Fix refreshing skipping items"
This reverts commit 77007dcea0.
2022-04-17 11:44:35 -04:00
Shadowfacts 98bb230817 Fix crash when disabling hide status actions in timeline 2022-04-09 15:05:49 -04:00
Shadowfacts 3d6d9b2a91 Fix crash due to empty html element 2022-04-09 15:05:39 -04:00
Shadowfacts bc9a700383 Improve expanded emoji picker layout on iPad 2022-04-09 12:14:37 -04:00
Shadowfacts 62c7a30bbc Add emoji picker button to compose
Closes #144
2022-04-09 12:14:19 -04:00
Shadowfacts abf6ff8115 Unify compose screen input accessory toolbars 2022-04-09 11:42:32 -04:00
Shadowfacts a718721537 Fix crash if getting pending crash report fails 2022-04-08 18:45:09 -04:00
Shadowfacts 4f99d3c6e1 Add preference to disable status action buttons in timelines
Closes #145
2022-04-08 18:42:15 -04:00
Shadowfacts a2fc1652d1 Enable sidebar toggle button and gesture
Closes #146
2022-04-08 17:47:02 -04:00
Shadowfacts 77007dcea0 Fix refreshing skipping items
Closes #147
2022-04-08 17:09:14 -04:00
Shadowfacts dc818524b2 Bump build number and update changelog 2022-04-06 22:05:13 -04:00
Shadowfacts d1ba1105b5 Fix Pachyderm not depending on WebURLFoundationExtras 2022-04-06 21:50:07 -04:00
Shadowfacts 89a9bfba47 Fix crash when refreshing while logged in to a Pixelfed account
Closes #142
2022-04-06 21:48:04 -04:00
Shadowfacts 2798a199aa Fix some pixelfed hashtags not being decodable 2022-04-06 21:34:40 -04:00
Shadowfacts 3d0402c1e0 Fix potential deadlock when infinite scrolling is disabled
Fixes crash when used with Pixelfed
2022-04-04 09:59:45 -04:00
Shadowfacts af0c9c92b6 Fix warning when a post appears in both the pinned and regular sections of a profile 2022-04-02 20:34:31 -04:00
Shadowfacts 0a7709526f Bump build number and update changelog 2022-04-02 20:24:02 -04:00
Shadowfacts 9ec821f6b3 Nix the xcworkspace, convert Pachyderm to a Swift package
Closes #138
2022-04-02 19:28:10 -04:00
Shadowfacts 5c4474dc87 Only show Trending Posts/Links on new enough Mastodon versions 2022-04-02 13:18:14 -04:00
Shadowfacts 829ecf06da Add Trending Posts/Links to sidebar 2022-04-02 12:03:11 -04:00
Shadowfacts cb2bb215d3 Change sidebar Discover section to be collapsible 2022-04-02 12:03:11 -04:00
Shadowfacts 916c6fba0d Fix Send Message action not setting visibility to direct 2022-04-02 12:03:11 -04:00
Shadowfacts 8473f32781 Add Trending Links 2022-04-02 12:03:11 -04:00
Shadowfacts 240ccf23a4 Add Trending Posts 2022-04-02 12:03:11 -04:00
Shadowfacts e49859e5ea Add preference to disable Discover 2022-04-02 12:03:11 -04:00
Shadowfacts c6d158a8a3 Don't display error message on login cancellation 2022-04-01 21:00:46 -04:00
Shadowfacts 7e90fe2401 Fix all profile statuses appearing as pinned on PixelFed 2022-04-01 21:00:46 -04:00
Shadowfacts cab78a4aa4 Remove unnecessary IssueReporterDelegate 2022-03-30 09:58:50 -04:00
Shadowfacts 7da139be4d Redact request paths in error reporter 2022-03-29 22:37:39 -04:00
Shadowfacts 2444783edf Add error reporter to Client.Error toast on long-press 2022-03-29 22:37:26 -04:00
Shadowfacts 727615a818 Fix crash when providing account actions before own account is loaded 2022-03-29 12:52:14 -04:00
Shadowfacts 6e3089f025 Use WebURL for parsing links in HTML 2022-03-29 12:40:16 -04:00
Shadowfacts e09b0ff4e3 Fix crash when AccountTableViewCell is cached by a
SearchResultsTableViewController that has since decremented the
reference count of the cell's account
2022-03-29 12:34:54 -04:00
Shadowfacts 830eea5e95 Fix crash when attempting to prune offscreen rows without content sections 2022-03-29 12:20:32 -04:00
Shadowfacts 705fbbe343 Fix deadlock when loading assets after requesting authorization 2022-03-29 12:07:57 -04:00
Shadowfacts 12bcf52764 Improve error reporting for onboarding, use async/await 2022-03-29 11:58:11 -04:00
Shadowfacts f31c909517 Fix a race condition when refreshing My Profile before initial load is complete 2022-03-28 23:02:32 -04:00
Shadowfacts 781c37fbae Fix crash when refreshing My Profile
Closes #140
2022-03-28 22:23:33 -04:00
Shadowfacts 930ec7ccff Handle gotosocial gif attachments 2022-02-16 22:12:56 -05:00
Shadowfacts de93d6e171 Make Account.avatar optional for gotosocial 2022-02-16 22:12:47 -05:00
Shadowfacts 80c79ded3b Bump build number and update changelog, fix building weburl 2022-02-16 22:11:24 -05:00
Shadowfacts 126b0ae90a Extend disk cache expiry times
The cache keys are URLs, and Mastodon changes the url if the a new image is uploaded for avatar/header
2022-02-06 14:36:01 -05:00
Shadowfacts d6a847bfcc Use background image preparation apis on iOS 15
Closes #128
2022-02-06 10:24:48 -05:00
Shadowfacts 9b33059089 Fix crash when ProfileHeaderView leaks 2022-02-06 10:20:06 -05:00
Shadowfacts 804fdb439d Fix offscreen row pruning removing all rows from profile statuses 2022-02-06 10:19:38 -05:00
Shadowfacts 6ba5f70615 Fix pinned statuses from foreign instances not showing on Mastodon 2022-02-03 23:16:31 -05:00
Shadowfacts 54c01be7ff Use WebURL for more lenient parsing of external URLs
Fixes #136
2022-02-03 23:11:29 -05:00
Shadowfacts 6e964ff601 Profile directory can have a little shadow, as a treat 2022-01-25 21:34:41 -05:00
Shadowfacts 73d33ae730 Fix pleroma not being detected 2022-01-25 21:34:41 -05:00
Shadowfacts 434d975767 Fix crash when ownInstanceLoaded callback is called multiple times 2022-01-25 21:34:41 -05:00
Shadowfacts 41a31c23b7 Allow posting local-only from Glitch instances
See #130
2022-01-24 22:49:51 -05:00
Shadowfacts 02461ad46c Support local only posts on Hometown
Closes #130
2022-01-23 23:45:46 -05:00
Shadowfacts 072e68e97b Add nodeinfo request and InstanceFeatures 2022-01-23 23:26:49 -05:00
Shadowfacts 6879acbe02 Add local-only post icon 2022-01-23 23:22:34 -05:00
Shadowfacts ace503ad3d Use username on compose screen when there is no display name 2022-01-23 11:06:23 -05:00
Shadowfacts e12a82b476 Show local only posts on hometown instances
#130
2022-01-23 10:58:36 -05:00
Shadowfacts 51cb7c3edf Store local only post data 2022-01-23 10:57:32 -05:00
Shadowfacts 2198e2bf3e Allow development against local instances with self-signed certificates 2022-01-23 10:56:36 -05:00
Shadowfacts 6138fc7748 Add select more photos option to asset picker 2022-01-23 10:55:07 -05:00
Shadowfacts dc1eb3d6f0 Remove old code 2022-01-21 11:13:47 -05:00
Shadowfacts fa1482a152 Fix crash when fetching attachment data fails 2022-01-21 11:10:03 -05:00
Shadowfacts e65ed3e773 Fix crash when ProfileHeaderView leaks 2022-01-21 11:09:55 -05:00
Shadowfacts eca7f31e82 Use stringsdict for favorites/reblogs count 2021-11-25 12:38:05 -05:00
Shadowfacts 2b22180191 Remove TimelineLikeTableViewController
Everything now uses DiffableTimelineLike
2021-11-25 12:29:35 -05:00
Shadowfacts 654b5d9c59 Convert ProfileStatusesViewController to DiffableTimelineLike 2021-11-25 12:27:59 -05:00
Shadowfacts 777d1f378c Fix hashtag history view background being opaque 2021-11-24 15:15:34 -05:00
Shadowfacts 3b132ab4dc Enable context menus and drag and drop for trending hashtags 2021-11-24 15:12:25 -05:00
Shadowfacts d1083116e0 Use a single disptach queue for attachment/card thumbnails 2021-11-24 15:02:35 -05:00
Shadowfacts 7b79cec0ed Remove old comments 2021-11-22 23:41:06 -05:00
Shadowfacts 50cbbb86fc Fix instance selector activity indicator background color 2021-11-22 23:23:52 -05:00
Shadowfacts 5a914ea5a3 Don't show Mute action when not applicable to status 2021-11-22 23:23:19 -05:00
Shadowfacts ca5ac8b826 Fix crash due to leaked ProfileHeaderView not having a
mastodonController
2021-11-22 21:38:00 -05:00
Shadowfacts 2b50609e5c Fix animating poll configuration button size change when selected option
changes
2021-11-20 11:37:09 -05:00
Shadowfacts 57cb0614a9 Fix keyboard getting dismissed when scrolling autocomplete suggestions
Presentation controller takes care of dismissing keyboard when swipe
down in main scroll view starts
2021-11-20 11:28:37 -05:00
Shadowfacts eccb1043db Bump build number and update changelog 2021-11-13 22:40:26 -05:00
Shadowfacts 9768097488 Match gif playback progress through animation
Closes #8
2021-11-13 14:52:02 -05:00
Shadowfacts f5e9f71586 Use link replacement length from instance config if available 2021-11-11 13:44:24 -05:00
Shadowfacts 9f8b14d180 Replace Gifu with CGImageAnimation
Closes #44
2021-11-11 13:26:11 -05:00
Shadowfacts 10a3cbbe9c Improve padding on multi-line poll options 2021-11-10 17:25:13 -05:00
Shadowfacts b917120f17 Fix crash when conversation loading fails 2021-11-10 17:25:05 -05:00
Shadowfacts 30ef9cc6d0 Extract compose image into separate view 2021-11-10 16:57:27 -05:00
Shadowfacts 948c792e5d Fix crash when leaving timeline VC that was showing timeline description message and doesn't have any statuses 2021-11-07 23:22:48 -05:00
Shadowfacts 2df703ab71 Add haptic feedback to header view tab switcher to match home/notifications 2021-11-07 18:22:21 -05:00
Shadowfacts 1ec85ca095 Use video thumbnails from API when possible 2021-11-07 15:10:18 -05:00
Shadowfacts 5a26739b78 Remove old compilation condition 2021-11-07 14:35:14 -05:00
Shadowfacts 36a78f1a3c Improve emoji loading behavior
Use transparent placeholders to prevent wrong initial layout when some
or all emojis aren't cached.
2021-11-07 14:23:56 -05:00
Shadowfacts 1c0291b1dd Unify emoji replacement code 2021-11-07 13:11:49 -05:00
Shadowfacts e7d9e3780e Remove non-required app icon 2021-10-28 20:28:21 -04:00
Shadowfacts 83d4af2303
Fix interactive gallery dismiss going wrong direction when gesture starts out very slow 2021-09-21 23:46:22 -04:00
Shadowfacts 7c5076d01a
Fix dismissing gallery presented by modally-presented VC removing the
gallery's presenting VC from the view hierarchy

Closes #132
2021-09-21 23:30:38 -04:00
Shadowfacts e61823b78f Update LIVC comments for iPhones 13 2021-09-19 12:43:38 -04:00
Shadowfacts 4d52ac4d34
Support new Mastodon instance configuration 2021-09-12 16:32:23 -04:00
Shadowfacts aced0a63c9
Bump build number and update changelog 2021-08-15 22:43:32 -04:00
Shadowfacts 1e54235ff5 Hide public timeline description when user begins scrolling rather than
after cell moves offscreen

Fixes description getting dismissed prematurely on iOS 14 and hitching
when the cell moves offscreen
2021-08-15 22:29:14 -04:00
Shadowfacts e6e5554edf Fix fast account switcher animation weirdness when 1 account only 2021-08-15 19:29:26 -04:00
Shadowfacts 9026f487ec Convert notifications to use DiffableTimelineLikeTableViewController 2021-08-15 19:25:29 -04:00
Shadowfacts c0097ba752 Fix potential race condition with DiffableTimelineLikeTableViewController 2021-08-15 18:44:23 -04:00
Shadowfacts f109253bba Show toast when there are no new posts 2021-08-15 18:27:30 -04:00
Shadowfacts 1fda4248ec Add activity indicator to instance selector 2021-08-15 11:02:19 -04:00
Shadowfacts 7781c5252b Display toast on load errors 2021-08-15 10:37:37 -04:00
Shadowfacts 7f4bf52050 Add toast system 2021-08-15 10:37:20 -04:00
Shadowfacts ba0d179de5 Fix AccountSwtichingContainerViewController not sending sceneDidEnterBackground to children 2021-08-15 10:37:04 -04:00
Shadowfacts 71b6f1bdf0 Alphabetize things in Xcode 2021-08-14 18:27:22 -04:00
Shadowfacts 09ec4a920c
Fix retain cycle in ProfileViewController 2021-08-14 10:25:32 -04:00
Shadowfacts 7edf0fdb93
Fix crash when replying to post with preformatted text 2021-08-12 21:03:11 -04:00
Shadowfacts 99e06441f0
Fix crash when getting account relationship fails
UIDeferredMenuElement completion handler should only be called from the
main thread
2021-08-12 19:41:00 -04:00
Shadowfacts 85e1e131f6
Fix crash when fetching recommended instances fails 2021-08-12 19:36:28 -04:00
Shadowfacts 1d79918a94
Fix crash when refreshing before anything is loaded 2021-08-08 10:26:51 -04:00
Shadowfacts 340d13b1fa
Fix crash when reloading list timelines 2021-08-08 10:19:18 -04:00
Shadowfacts cf1000a4df
Fix loadOlder being called excessively on public timelines 2021-08-08 10:09:38 -04:00
Shadowfacts b781b56efd
Add public timeline descriptions 2021-08-08 10:09:28 -04:00
Shadowfacts 10a8a85bfc
Enable object lifetime optimization 2021-08-07 11:06:07 -04:00
Shadowfacts 6d8a014cc7 Bump build number and update changelog 2021-06-27 19:02:51 -04:00
Shadowfacts 60c88ded5e Require iOS 15 for Disable Infinite Scrolling 2021-06-27 17:17:39 -04:00
Shadowfacts 1e7a6af0bf Fix TimelineTableVC item hash including status state
Fixes crash when refreshing on iOS 14
2021-06-27 15:52:22 -04:00
Shadowfacts f8b79ef34f Fix app extension build number 2021-06-27 10:37:03 -04:00
Shadowfacts 4cf56685b5 Disable profile screen compose button when logged out 2021-06-27 10:31:02 -04:00
Shadowfacts fdcd2aa540 Add Open in New Window context menu action to sidebar items 2021-06-27 10:30:53 -04:00
Shadowfacts 667d30a710 Fix crash when editing accounts in a list
Closes #127
2021-06-26 18:54:59 -04:00
Shadowfacts b0f23e46ba Let Xcode update the stupid package name 2021-06-26 18:52:12 -04:00
Shadowfacts 9b30b48016 Bump build number and update changelog 2021-06-26 18:28:38 -04:00
Shadowfacts bd49683e13 Fix not being able to select assets on iOS 15 beta 2 2021-06-26 17:18:04 -04:00
Shadowfacts c22945b1e7 Use sheetPresentationController property 2021-06-26 17:02:17 -04:00
Shadowfacts 0a16a2e261 Fix potential data races 2021-06-26 16:51:54 -04:00
Shadowfacts b95819cada Fix crash when switching accounts 2021-06-26 16:42:56 -04:00
Shadowfacts dc1ea1bed9 Fix timeline momentum scrolling stopping due to adding footer section 2021-06-26 15:54:10 -04:00
Shadowfacts 5f9fe505d5 Add pref to disable infinite scrolling on timelines
Closes #125
2021-06-25 23:28:43 -04:00
Shadowfacts 5b8e97287e Convert TimelineTableViewController to use DiffableTimelineLikeTableViewController 2021-06-20 22:27:38 -04:00
Shadowfacts 49572c1fec Add DiffableTimelineLikeTableViewController 2021-06-20 22:27:29 -04:00
Shadowfacts ebb0770198 Add context menu action to remove attachments in Compose 2021-06-18 11:32:17 -04:00
440 changed files with 31032 additions and 10496 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
Dist.xcconfig
Tusker.xcconfig
.DS_Store
MyPlayground.playground/

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "Gifu"]
path = Gifu
url = git://github.com/kaishin/Gifu.git
[submodule "Embassy"]
path = Embassy
url = https://github.com/envoy/Embassy.git

View File

@ -1,5 +1,586 @@
# Changelog
## 2023.2 (68)
Bugfixes:
- Fix crash when inserting present items in empty timeline
- Fix extra spacing above content in conversation main status
## 2023.2 (67)
Features/Improvements:
- Try to resolve remote statuses and show conversation screen when tapping status links
- Add loading indicator to conversation screen
- Improve collapse/expand animation on conversation screen
## 2023.2 (66)
Features/Improvements:
- Improve design of link preview card
- Show loading indicator during timeline state restoration
Bugfixes:
- iPadOS/macOS: Fix some keyboard shortcuts not working
- Fix crash when restoring timeline state
- Fix status collapse button disappearing when navigating away
- Fix crash when status swipe action takes too long to complete
- Fix tapping expand thread cell not working
## 2023.1 (64)
Features/Improvements:
- Add Delete Post action to statuses
- Add follower/following counts and lists to profiles
- Show better message when opening conversation for deleted status
- Add pagination for showing all accounts that favorited/reblogged a status
Bugfixes:
- Fix race condition causing crash when syncing timeline position from iCloud
- Fix profile header buttons not adjusting to Dynamic Type
- Don't show report button for your own posts
- Fix avatars on timeline not reverting from grayscale when turning off preference
## 2023.1 (63)
Bugfixes:
- Fix status cells being inset too much on iPhones
- Fix more things not adjusting to accent color preference
- Fix various views not being keyboard focusable
- Add more logging around state restoartion crash
## 2023.1 (62)
Features/Improvements:
- Add New List action in Add to List menu
Bugfixes:
- Fix crash when retrying follow hashtag
- Fix separators on timeline not being properly inset
- Fix various elements not adjusting to the accent color preference
- Prevent all pinned timelines from being removed, which would previously crash
- Fix crash when handling search activity
## 2023.1 (61)
Features/Improvements:
- Add report UI
- Add accent color preference
- Start playing videos immediately when gallery opens
Bugfixes:
- Fix crash when trying to load deleted status for state restoration/sync
- Fix crash when trying to restore state for non-pinned timeline
- Fix crash due to relationships being cached longer than their corresponding accounts
- Fix crash if preferences change when there are cells that haven't yet been displayed
- Fix crash when displaying poll finished notifications
## 2023.1 (60)
Features/Improvements:
- Allow sharing gifv attachments
- Add email subject when sharing status/account
Bugfixes:
- Fix crash when inserting present items after navigating away from and returning to timeline
- Fix error decoding statuses from certain instances
- When logging out, remove the scene's active account rather than the most recently activated
## 2022.1 (59)
This build is a hotfix for a crash when migrating saved instances to iCloud.
## 2022.1 (58)
Features/Improvements:
- Sync timeline positions via iCloud
- Add pinned timelines customization (synced via iCloud)
- Sync saved hashtags & instances via iCloud
- Add filters for hiding reblogs and replies from home timeline
- Show uncropped attachments in the timeline for posts that have only one attachment
- Add more prominent Follow button to profile pages
- Add About and Acknowledgements pages to Preferences
- Automatically report certain kinds of errors
- iPadOS/macOS: Add window titles to indicate which account is in use
- iPadOS: Limit content to readable width
- VoiceOver: Improve label for toggle collapse button in conversation view
Bugfixes:
- Fix attachments in timeline somtimes being untappable
- Fix previewing links in the main status in a conversation activating the link
- Don't show reblog swipe action when reblogging is forbidden
- Fix unknown notifications appearing in the Mentions view
- Fix crash when fetching present items in certain circumstances
- Fix relationship (following/blocked/etc.) change breaking profile header layout
- Fix crash when restored timeline state includes unloaded statuses
- macOS: Fix add attachment buttons not matching system accent color
## 2022.1 (53)
Features/Improvements:
- Apply filters to Trending Posts
- Don't reload List timelines if Edit screen is closed without changes
Bugfixes:
- Fix URLs getting pasted as broken attachments in the Compose screen
- Fix monspace fonts not adjusting to Dynamic Type setting
- Fix crash when activating account from Preferences when My Profile is opened in a separate window
- Fix Preferences showing wrong account as current when multiple windows with different accounts are open
## 2022.1 (52)
Features/Improvements:
- Save and restore position for all timelines and all accounts
- As a side effect of this change, the first time you launch with this update, the timeline position will be lost
- Add preference to never blur attachments
- New segmented control for timeline switcher that scrolls when there's not enough space
- Copy status expand all setting when viewing More Replies in a converstaion
- Include followed hashtags in the Explore screen and iPad sidebar
- Allow saving or following hashtag from Add Hashtag screen
- Scroll long attachment descriptions in the gallery
- VoiceOver: Improve Profile Directory
- VoiceOver: Include attachment descriptions in timeline items when not marked as sensitive
Bugfixes:
- Fix swipe actions preference not persisting
- Fix rich text list bullets/numbers appearing black in dark mode
- Fix crash when previewing non-HTTP(S) link
- Fix images from Safari pasting as URLs rather than attachments
- Fix Trending Posts appearing to reload forever
- Fix controls reappearing when swiping between pages in the attachments gallery
- Fix reblog confirmation alert actions missing hover effect
- Fix status reply/visibility/local icons flashing blue when expanding a status
- iPad: Fix My Profile item sidebar item not updating when avatar style changes
- iPad: Fix tapping status bar not scrolling to top in single-column navigation mode
- VoiceOver: Fix crash when scrolling through local/federated timeline
- VoiceOver: Fix escape gesture not working in attachment gallery
- VoiceOver: Fix custom emoji not being stripped from display names
## 2022.1 (51)
Features/Improvements:
- Clarify text for conversation main status favorite/reblog count preference
- Improve timeline refresh behavior
- Present posts are inserted automatically, creating a gap
- Tapping the Jump to Present bubble scrolls to the top and removes everything below the gap
- Add preference to disable timeline state restoration (Preferences -> Behavior)
- VoiceOver: Add Jump to Present action on the timeline selector segmented control
- VoiceOver: Add accessibility hint for segmented controls when using the group navigation mode
- VoiceOver: Improve description of timeline gap and add actions to load in a specific direction
Bugfixes:
- Fix crash due to change cache location on disk
- Fix potential crash when trying to restore statuses that aren't available
- Fix saving expired filters not re-enabling them
- Fix tusker:// URL scheme not working
- Fix Trending Posts reloading constantly
- Fix crash when timeline tries to refresh while in the background
## 2022.1 (50)
This is a hotfix for Dynamic Type not working in the timeline. The previous build's changelog is included below.
## 2022.1 (49)
The major new feature of this build is filters! Filters are editable by pressing the Filters button in the top-left corner of the Home tab. Filters are currently applied to timelines and profiles (filtering conversations and notifications will be added in a future build).
Features/Improvements:
- Filters
- Edit/create filters
- Apply filters to timelines and profiles
- Add preference to customize swipe actions on status cells (Preferences -> Appearance -> Leading/Trailing Swipe Actions)
- Show notifications for edited posts
- Add more details to the relationship label on profiles
- "Follows you", "You follow", "You follow each other", and "You block"
- Add state restoration for Federated and Local timelines
- Also fixes an issue where posts from other timelines would appear in the home timeline after a relaunch
- Add state restoration for Compose screen
- Organize expanded custom emoji picker by category
- Add indicator for locked profiles
- Add cache size info to Advanced preferences
- Indicate when a followed hashtag caused a post to appear in the home timeline
- Add hashtag follow/unfollow actions
- Completely replace timeline items after Jump to Present used
- Fixes infinite scroll not being usable after jumping
- iPad/Mac: Add Cmd+Return shortcut for sending post on the Compose screen
- VoiceOver: Hide redundant information on Compose screen
- VocieOver: Add links/mentions/hashtags to actions rotor on statuses
- VoiceOver: Add show profile action to timeline statuses
Bugfixes:
- Fix gifv attachments appearing off-center
- Fix long status on certain screens not getting collapsed
- Fix error when refreshing a timeline with no items
- Fix cells in account list and status action account list not being deselected when navigating back
- Limit search in Edit List screen to accounts the user follows
- Fix attachments disappearing from statuses on the Conversation screen
- Fix extra space gap appearing in profile headers below avatar
- Fix mute duration options not including 1 week
- Hometown: Fix local-only state not being copied from the replied-to post
- iPad: Fix timeline statuses not getting deselected when entering split navigation
- iPad: Fix Mute screen using pointless two-column layout
- iPad: Fix creating a list from the sidebar making the previous tab inaccessible
- iPad: Fix creating a list not showing the Edit List screen automatically
- iPad: Fix selected sidebar item becoming out-of-sync when deleting a list/hashtag/instance
- Mac: Workaround for pressing Cmd+1/2/... crashing
- This prevents the crash, but the actions remain unusable due to a macOS bug
- VoiceOver: Fix escape gesture not working on Compose screen
- VoiceOver: Fix links in conversation main status not being selectable
- VoiceOver: Fix profile relationship not being read
- VoiceOver: Fix not being able to select profile from conversation main status
Known Issues:
- Filters are not applied to notifications and conversations
## 2022.1 (48)
This build is a hotfix for the CW button in the Compose screen not working. The previous build's changelog is attached below.
Bugfixes:
- Fix pressing CW button in Compose not showing the content warning field
- Tweak timeline state restoration to try and maintain the scroll position of the middle item on screen, rather than the top one
## 2022.1 (46)
The headlining feature is state restoration and timeline gaps! When you re-open the app after it's been closed for a while, it will remember your position in the timeline and allow you to keep reading from there. It will also let you jump all the way to the present.
Features/Improvements:
- Timeline state restoration, timeline gaps, and jump-to-present
- Allow posting wide color gamut images on Mastodon 4
- Add Add to List menu action to profiles
- Improve More Actions button visibility on dark profile header images
- Make poll options in the Compose screen reorderable with drag & drop
- Embiggen Share/Close controls in the gallery to make them easier to tap
- Separate section for Shared Albums in the Compose attachment picker
- Indicate verified profile links with a checkmark and popover explaining what it means
- Add a preference for using the Twitter-style keyboard with @ and # (Preferences -> Composing -> Show @ and # on Keyboard)
- Improve reblog indicator in timeline
Bugfixes:
- Fix not being able to select an existing draft to edit it
- Fix double-tap to zoom in the gallery not working
- Fix crash when toggling collapsed posts in Trending Posts
- Fix albums in asset picker not being sorted by name
- Fix profile headers getting squished when statuses are loaded while the profile is offscreen
- Fix error loading posts when server returns rich cards
- Fix Akkoma instnaces not being detected as supporting Pleroma features
- Fix crash when launching the app in slow network conditions
- Fix lists not updating in the UI when renamed
- Fix follow/block/mute actions displaying on the user's own profile
- Fix Edit List screen being presented repeatedly when switching tabs back to Explore with a list open
- Fix reblog visibility icon getting squished in the reblog confirmation dialog when Dynamic Type is active
- Fix toasts not adjusting to Dynamic Type size
- Don't show duplicate reply/favorite/reblog actions in the status More Actions menu
- iPadOS 15: Fix toolbar in Compose window being obscured by the keyboard
## 2022.1 (45)
Features/Improvements:
- iPhone: Temporarily hide the Compose screen by swiping down to access the rest of the applies
- Add Block, Domain Block, and Mute actions to accounts
- Don't change scroll position when switch sections in the Profile screen
- Use URL keyboard in the instance selector and clarify that you can enter any domain
- iPad: Add context menu action for deleting lists in sidebar
- Tweak conditions in which profile fields are shown in a single column, rather than two
- Convert wide color gamut images to sRGB before uploading
- The Mastodon backend does not support wide-gamut images and does a poor job of conversion, so the conversion is performed locally
- Focus content warning field immediately when CW button is pressed
- Move focus to main text field when return key is pressed while editing the content warning
- Make GIF attachments animate on the Compose screen
- VoiceOver: Make profile fields accessible
- VoiceOver: Only read content warning and not content for CW'd posts
- VoiceOver: Expand collapsed posts when performing double-tap
- VoiceOver: Announce visibility of followers-only & direct posts
- VoiceOver: Make Compose toolbar accessible
Bugfixes:
- Fix tapping links in profile fields
- Fix crash when creating/editing list fails
- Fix renaming a list not updating it elsewhere in the UI
- Fix instance-local/everywhere scope selector in Profile Directory being flipped
- Fix context menu previews of attachments not working
- Fix caret not scrolling into view when opening Compose
- Fix cells in the Drafts list being too small to tap
- Fix refresh failing when initial load failed
- Fix video controls in the gallery being too close to the edge of the screen
- Fix error when decoding malformed notifications
- Fix reblog with visibility not being available on Hometown instances
- Fix visibility dropdown being shown in confirm reblog alert even when unavailable
- Fix confirm reblog alert not adjusting to Dynamic Type
- Fix layout issues with replies on Compose screen
- macOS: Fix GIFs dragged from Finder posting static images
Known Issues:
- Drag/drop to add attachments when composting a post does not work
## 2022.1 (44)
Features/Improvements:
- Dynamic Type support
- Improve performance when displaying statuses with large numbers of custom emojis
- Add preference for default reply visibility
- Add preference to turn off blurring media in posts with content warnings
Bugfixes:
- Fix drawing background flashing between black/white in dark mode
- Fix undo scroll-to-top not working in release builds
- Fix favorite and reblog menu actions not working
- Fix avatar in compose being wrongly aligned on short statuses
- Fix posts that are tall but have few characters not getting collapsed
- Fix crash when profile screen is closed for the profile loads
## 2022.1 (43)
Features/Improvements:
- Re-add undo scroll-to-top by tapping the status bar a second time
- Convert hashtag/list/instance timelines to use new timeline implementation
- Clarify warning on Post Content Type preference
Bugfixes:
- Fix crash when refreshing profile before it loaded
- Fix crash when tapping Load More when infinite scrolling is disabled
- Fix crash when profile screen is closed before loading finishes
- Fix having to tap Cancel twice to dismiss Find Instance screen
## 2022.1 (42)
Features/Improvements:
- Add automatic crash reporting
- Tweak spacing on timeline statuses
Bugfixes:
- Fix status collapse/expand not animating on profiles
- Fix crash when opening profile for unloaded account (e.g., by tapping mentions)
- macOS: Add workaround for Follow/Unfollow menu item never loading
## 2022.1 (41)
Features/Improvements:
- Rewrite profile screens to use new timeline implementation
- Disable Infinite Scrolling preference (Preferences -> Digital Wellness) now applies to profiles
- Improve behavior when switching tabs on profiles
- Improve pointer interaction on timeline status cells
Bugfixes:
- Fix crash when loading images in certain circumstances
- Fix gallery dismissal leaving status bar hidden and breaking future gallery dismisses
- Fix timeline scroll position changing after dismissing gallery
- Fix images flickering when switching back to the Home tab
- Fix crash reporter being dismissed when sending email is cancelled
- Fix crash when long pressing Send Report button in crash reporter on iPad
- Fix Live Text controls not hiding when other gallery controls are hidden
- Fix replies appearing multiple times in Drafts list
- Fix crash when displaying blur hash images on Pleroma
## 2022.1 (40)
Bugfixes:
- Fix selecting reblogged statuses in the timeline
- Fix links/mentions/hashtags in the timeline not being tappable
- Fix mentions from Misskey opening in the browser rather than the profile screen
- Fix crash when leaving timeline tab before it finished loading
- Fix status cells in the timeline not deselected when tapped in split navigation mode on iPad
- Fix keyboard shortcuts not working on iPad
## 2022.1 (39)
This is a(nother) hotfix for the previous build. Their changelogs are included below.
Bugfixes:
- Fix instance selector screen crashing on iOS 15
## 2022.1 (38)
This is a hotfix for the previous build. Its changelog is included below.
Bugfixes:
- Fix sensitive attachments not being hidden on the timeline
- Fix timeline descriptions appearing repeatedly
- iPadOS: Fix occasional crash when hovering over text
## 2022.1 (37)
This is the first build with the rewritten/rearchitected timeline screen. In future builds, this will roll out to the notifications and profile screens as well, but for now it's only used in the home tab. If you encounter crashes or errors, please report them. If you see a blue error bubble pop up, you can long-press it to send an error report.
Features/Improvements:
- Display error messages when favoriting/reblogging fails
Bugfixes:
- iOS 15: (hopefully) fix lock-related crash
- Fix crash when loading indicator is shown multiple times
Known Issues:
- Videos played from the timeline do not enter picture-in-picture mode when backgrounding the app
- Status expand/collapse animations on other screens do not match timelines
Other:
- X-Callback-URL support has been removed
## 2022.1 (36)
This build is a hotfix for a crash when refreshing on Pixelfed.
## 2022.1 (35)
Features/Improvements:
- Add loading indicator to timelines/notifications/profiles
- Show status preview in reblog confirmation dialog (Preferences -> Behavior -> Require confirmation Before Reblogging)
- Add reblogging with unlisted/private visibility (requires reblog confirmation to be enabled)
- Fix controls not hiding on iPhone 14 Pro
- Improve account switching animation
Bugfixes:
- Fix crash when resizing window on iPad
- Fix poll vote count displaying random number
- Fix crash when opening emoji picker on instances that have duplicate emojis
## 2022.1 (33)
Features/Improvements:
- Show notifications when subscribed to other people's posts
- Use context menu for filter/sort in Profile Directory
- Enable data detectors (flight numbers, addresses, shippment numbers, phone numbers, currency (iOS 16), and physical units (iOS 16)) for the main status in Conversation
- iPadOS: Two column navigation
- In potrait orientation with the sidebar hidden, or in landscape, Tusker uses two column navigation on iPad
- Selecting something will open a second column in which navigation takes place
- The second column can be closed from its top level
- You can drill down farther inside the second column
- Selecting a different item in the first column replaces the second column
- iPadOS: Move Trending Hashtags/Links to Explore screen (formerly Search)
- Trending Statuses and Profile Directory will also be moved in a future version
- iPadOS: Add context menu action for deleting drafts
- iOS 16: Add Live Text to images in the gallery view
- iOS 16: Show favorite/reblog context menu actions
- iOS 16: Show full size previews when long-pressing attachments on the Compose screen
- iOS 16: Show formatting actions in edit menu on Compose screen
Bugfixes:
- Fix attachments on Pleroma not being served as the correct content type
- Fix not being able to open some hashtags with non-ASCII characters
- Fix crash when leaving the app shortly after opening it
- Fix crash when loading notifications on Pixelfed
- Fix crash due to retain cycle when changing preferences
- iPadOS: Fix crash when opening a conversation in a new window
## 2022.1 (31)
Bugfixes:
- Fix not being able to post attachments with descriptions
- Fix potential crash when displaying certain notifications
- More detailed error message when decoding invalid URLs
## 2022.1 (30)
Features/Improvements:
- Add fast account switching on iPad
- Add "Add Account" option to fast account switcher
- Show "# more replies" indicator in conversation in more circumstances
- When refreshing notifications, new ones are grouped with existing notifications
- Add subtitles to explain post visibility options
- Improve error messages when posting a video fails
- Display error messages instead of crashing when certain actions fail
Bugfixes:
- Fix Shortcuts actions not working in some circumstances
- Fix CW field growing wider than the screen
- Fix saved hashtags not persisting
- Fix not being able to long-press error-message bubbles
- Fix follow context menu item not updating after following
- Fix not being able to log in to certain Pixelfed instances
- Fix crash when closing the app
- Fix crash when loading profile screen
- Fix crash when refreshing polls
- Fix crash when poll voting fails
- Fix crash when accepting/rejecting a follow request fails
- Fix saved hashtags being sorted with case-sensitivity
- Fix multiple lines of text with emojis getting squashed together
- iPad: Fix Shortcuts actions showing wrong window type
- Mac: Fix Cmd+N shortcut not opening Compose window
- iPad/Mac: Fix Send Message action not mentioning account
## 2022.1 (27)
Features/Improvements:
- Add emoji picker button to Compose screen toolbar
- Preference to disable reply/like/reblog/more buttons on statuses in the timeline
- iPad: Sidebar toggle button
Bugfixes:
- Fix crash when displaying malformed statuses
## 2022.1 (26)
This build contains hotfixes for several crashes that may occur when logged-in to a Pixelfed account.
## 2022.1 (25)
Features/Improvements:
- Improve error reporting for non-crash errors
- Long-press on the blue error bubble to send a report
- Improve error feedback during login process
- Add Trending Post and Trending Links on Mastodon 3.5
- Add Digital Wellness preference to disable Discover
- Basic support for GotoSocial
- Reduce app file size
Bugfixes:
- Fix all statues appearing as pinned on Pixelfed
- Fix crash when refreshing My Profile
- Fix My Profile never loading in some circumstances
- Fix crash the first time the attachment picker is opened
- Fix crash when closing certain screens
- Fix certain links in posts not being detected
## 2022.1 (24)
Features/Improvements:
- Local only posts (Glitch/Hometown)
- Show indicator for local only posts
- Add local only option to Compose screen
- Add extend selection button to asset picker when the limited library was used
- Improve profile directory UI
- Improve scrolling performance with large attachments on older devices
Bugfixes:
- Fix crash when closing Preferences
- Fix crash when posting attachment fails
- Fix scrolling through compose autocomplete suggestions dismissing keyboard
- Only show Mute action on your own posts
## 2021.1 (23)
Features/Improvements:
- Synchronize GIF playback through animations and in gallery
- Known Issue: This does not currently work with GIFVs used by Mastodon instances.
Bugfixes:
- Fix crash when a conversation fails to load
- Fix gallery dismissal breaking public timelines
- Fix gallery dismissal going in the wrong direction when the gesture was started slowly
## 2021.1 (22)
This is the first public beta build of Tusker, so if you're just joining us, welcome! Not too many new features this build, mostly bugfixes, so test everything and generally use the app.
Features/Improvements:
- Add timeline descriptions the first time you view federated/local
- Show messages when loading posts fails or when there are no newer posts
Bugfixes:
- Fix crash after editing lists
- Fix crash when refreshing before anything is loaded
- Fix crash when fetching recommended instances fails
- Fix crash when replying to posts with code formatting
- Fix crash when changing preferences after switching accounts
## 2021.1 (21)
This is a quick follow-up to the previous build with fixes for a couple major crashes. Unfortunately, due to a bug in iOS 14, the Disable Infinite Scrolling preference now requires the iOS 15 beta to use. It may return in a future build if I can find a workaround, but it's disabled in the meantime.
Features/Improvements:
- iPadOS 15: Add Open in New Window context menu action to sidebar items
Bugfixes:
- Fix crash when editing accounts in a list
- Fix crash when refreshing timeline on iOS 14
- Fix(ish) crash when opening collapsed status with Disable Infinite Scrolling active on iOS 15
## 2021.1 (20)
This is a big one! In addition to a bunch of fixes for anyone on the iOS 15 beta, there are a couple of big ticket features, including the Open in Tusker action extension and the Disable Infinite Scrolling preference.
Features/Improvements:
- Add Open in Tusker action extension
- Quickly search for any URL in Tusker
- In a share sheet, scroll to the bottom, tap "Edit Actions..." and turn on the "Open in Tusker" action
- Add Digital Wellness preference to disable infinite scrolling
- Add fast account switching indicator to My Profile tab
- Improve VoiceOver accessibility of polls and timeline statuses
- iPadOS: Create multiple main windows for different accounts by dragging from an account in Preferences
- iPadOS: Delete attachments on Compose screen by right-clicking and selecting Delete
- iPadOS 15: Add Open in New Window context menu action to most things
- iPadOS 15: Allow dragging the Compose sheet into a separate window
Bugfixes:
- Fix being unable to commit previewed account from timeline status
- Fix crash when searching fails
- Fix poll option percentages being cut off
- Fix polls not collapsing inside CWs
- Fix More button on profiles not being accessible with VoiceOver
- Fix VoiceOver reading profile fields in incorrect order
- Fix gallery animations jittering on devices with square screens (iPads, non-notched iPhones)
- Fix CW text jumping around post collapse animation
- iOS 15: Fix crash due when showing Draw Something screen in Compose
- iPadOS 14/iOS 15: Fix navigation bar turning transparent after opening the attachment gallery
- iPadOS 14/iOS 15: Fix drag-selecting poll options initiating a status cell drag interaction
- iPadOS: Fix crash when loading a previously-opened conversation window
- iPadOS 15: Fix showing Compose screen when keyboard focus moves through the sidebar
Known Issues:
- Disable Infinite Scrolling preference only affects timelines, not notifications or profiles
- iPadOS 15: The Compose sheet cannot be dismissed by swiping down
- iPadOS 15: Keyboard focus is stuck in the sidebar
## 2021.1 (19)
This is an emergency fix for Tusker breaking when connecting to Mastodon instances on 3.4.0rc1.

View File

@ -1,355 +0,0 @@
# X-Callback-URLs in Tusker
Tusker supports inter-app-communication using the [X-Callback-URL standard](http://x-callback-url.com/).
In short, requests are performed by opening the URL `tusker://x-callback-url/[request]` (where `[request]` is one of the requests listed below) with a variety of parameters.
## Callbacks
X-Callback-URLs support three types of callbacks: on success, on cancellation, and on error. Callbacks are specified as query parameters whose keys identify which callback (`x-success`, `x-cancel`, and `x-error`) and whose values are other URLs that should be opened to run the callback.
Data is passed to callbacks by adding additional query parameters to the callback URL. The `x-error` callback always returns a description of the error in the `error` parameter. Other data is provided depending on the request.
### JSON Responses
By default, callback data is included in URL query parameters of the callback URL. If the `json=true` parameter is provided, the response data will be encoded as JSON, converted to [Base64](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding), and provided in the `response` query parameter of the callback.
## Silent Requests
Tusker X-Callback-URL requests can be performed silently, without user confirmation. Each source app requires user permission on the first attempted silent action.
To perform a silent request:
1. Provide the `silent=true` URL query parameter in the request.
2. Specify the `x-source` parameter. It must be a (human interpretable) name of the source application/service. If `x-source` is not specified, the error callback will be invoked with the error message:
```
Cannot perform silent action without source app, x-source parameter must be specified.
```
3. Depending on the current permission state of the source app, one of several things will happen:
1. If the permission is **undecided** (i.e. the user has neither accepted nor rejected the silent action request), an alert will be displayed notifying the user that the source app has requested permission to silently perform actions. After the user either accepts or rejects the request, execution will continue with that permission state.
2. **Accepted**: the request will be carried out silently and the appropriate callback executed.
3. **Rejected**: the request will be performed with the confirmation UI, as if the `silent` parameter had been false/unprovided.
The silent actions permission state of a given source app is not exposed in the callback.
## Other Notes
#### Instance-Local IDs
Instance-local IDs are provided for many responses and accept in place of URLs/URIs/qualified names in many requests. When possible, instance-local IDs should be preferred requests using them can often be performed faster because there's no need to perform a search query or make requests to remote instances.
#### Qualified Usernames
Qualified username refers to the domain-qualified identifier of an account. For example, `shadowfacts@social.shadowfacts.net`. They do not include a leading `@`.
#### Dates
Dates in responses are encoded as Unix timestamps.
## Requests
- [Accounts](#accounts)
- [`showAccount`](#showaccount)
- [`getCurrentUser`](#getcurrentuser)
- [`getAccount`](#getaccount)
- [`followUser`](#followuser)
- [Statuses](#statuses)
- [`showStatus`](#showstatus)
- [`getStatus`](#getstatus)
- [`postStatus`](#poststatus)
- [`favoriteStatus`](#favoritestatus)
- [`reblogStatus`](#reblogstatus)
- [Notifications](#notifications)
- [`getNotification`](#getnotification)
- [`getNotifications`](#getnotifications)
- [`dismissNotification`](#dismissnotification)
- [`dismissAllNotifications`](#dismissallnotifications)
- [Instances](#instances)
- [`getCurrentInstance`](#getcurrentinstance)
- [Misc](#misc)
- [`search`](#search)
### Accounts
#### `showAccount`
Presents the given account in Tusker.
##### Request
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------------------------------------ | -------- |
| `accountID` (string) | The instance-local ID of the account | Yes |
| `accountURL` (URL) | The URL of the remote account | Yes |
| `acct` (string) | The [qualified username](#qualifiedusernames) of the account | Yes |
##### Response
No data if successful.
#### `getCurrentUser`
Retrieves the currently logged-in user.
##### Request
No parameters.
##### Response:
| Parameter (type) | Description | Optional |
| ---------------------- | --------------------------------------------- | -------- |
| `username` (string) | The [qualified username](#qualifiedusernames) | No |
| `displayName` (string) | The display name | No |
| `locked` (bool) | Whether the user's account is locked | No |
| `followers` (int) | The number of followers the user has | No |
| `following` (int) | The number of accounts user is following | No |
| `url` (URL) | The URL of the user's account | No |
| `avatarURL` (URL) | The URL of the user's avatar image | No |
| `headerURL` (URL) | The URL of the user's header image | No |
#### `getAccount`
Retrieves the given account details. One of `accountID`, `accountURL`, or `acct` must be provided.
##### Request
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------------------------------------ | -------- |
| `accountID` (string) | The instance-local ID of the account | Yes |
| `accountURL` (URL) | The URL/URI of the account | Yes |
| `acct` (string) | The [qualified username](#qualifiedusernames) of the account | Yes |
##### Response
| Parameter (type) | Description | Optional |
| ---------------------- | ------------------------------------------- | -------- |
| `username` (string) | The qualified username | No |
| `displayName` (string) | The display name | No |
| `locked` (bool) | Whether the account is locked | No |
| `followers` (int) | The number of followers the account has | No |
| `following` (int) | The number of accounts account is following | No |
| `url` (URL) | The URL of the account | No |
| `avatarURL` (URL) | The URL of the account's avatar image | No |
| `headerURL` (URL) | The URL of the account's header image | No |
#### `followUser`
Follows the given account from the logged-in user's account. One of `accountID`, `accountURL`, or `acct` must be provided.
##### Request
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------------------------------------ | -------- |
| `accountID` (string) | The instance-local ID of the account | Yes |
| `accountURL` (URL) | The URL/URI of the account | Yes |
| `acct` (string) | The [qualified username](#qualifiedusernames) of the account | Yes |
##### Response
| Parameter (type) | Description | Optional |
| ---------------- | ------------------------------- | -------- |
| `url` (URL) | The URL of the followed account | No |
### Statuses
#### `showStatus`
Presents the given status in Tusker.
##### Request
| Parameter (type) | Description | Optional |
| ------------------- | ----------------------------------- | -------- |
| `statusID` (string) | The instance-local ID of the status | Yes |
| `statusURL` (URL) | The URL of a remote status | Yes |
##### Response
No data if successful.
#### `getStatus`
Retrieves the given status details. One of `statusID` or `statusURL` must be provided.
##### Request
| Parameter (type) | Description | Optional |
| ------------------- | ------------------------------------------------------------ | -------- |
| `statusID` (string) | The instance-local ID of the status | Yes |
| `statusURL` (URL) | The URL/URI of the status | Yes |
| `html` (bool) | Whether to return the content as HTML or plain-text only. Default: `false` (plain-text). | Yes |
##### Response
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------------------------------------ | -------- |
| `url` (URL) | The URL of the status | Yes |
| `uri` (string) | The URI of the status | No |
| `id` (string) | The instance-local ID of the status | |
| `account` (string) | The [qualified username](#qualifiedusernames) of the account that posted (or reblogged if `reblog` is present) the status | No |
| `inReplyTo` (string) | The instance-local ID of the status that this status is a reply to | Yes |
| `posted` (date) | The date the status was posted | No |
| `content` (string) | The content of the status (HTML if the `html` parameter was true, plain-text otherwise) | No |
| `reblog` (string) | The **instance-local** ID of the status that this is a reblog of. If not present, this status was not a reblog. | Yes |
#### `postStatus`
Posts a status from the logged-in user's account.
Can be performed silently.
##### Request
| Parameter (type) | Description | Optional |
| ------------------- | ------------------------------------------------------------ | -------- |
| `mentioning` (bool) | The [qualified username](#qualifiedusernames) to mention in the status | Yes |
| `text` (string) | The text to post/pre-fill the status text field with | Yes |
##### Response
| Parameter (type) | Description | Optional |
| -------------------- | ---------------------------- | -------- |
| `statusURL` (URL) | The URL of the posted status | Yes |
| `statusURI` (string) | The URI of the posted status | No |
#### `favoriteStatus`
Favorites the given status from the logged-in user's account. One of `statusID` or `statusURL` must be provided.
Can be performed silently.
##### Request
| Parameter (type) | Description | Optional |
| ------------------- | ----------------------------------- | -------- |
| `statusID` (string) | The instance-local ID of the status | Yes |
| `statusURL` (URL) | The URL/URI of a status | Yes |
##### Response
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------- | -------- |
| `statusURL` (URL) | The URL of the favorited status | Yes |
| `statusURI` (string) | The URI of the favorited status | No |
#### `reblogStatus`
Reblogs the given status from the logged-in user's account. One of `statusID` or `statusURL` must be provided.
Can be performed silently.
##### Request
| Parameter (type) | Description | Optional |
| ------------------- | ----------------------------------- | -------- |
| `statusID` (string) | The instance-local ID of the status | Yes |
| `statusURL` (URL) | The URL/URI of a status | Yes |
##### Response
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------- | -------- |
| `statusURL` (URL) | The URL of the reblogged status | Yes |
| `statusURI` (string) | The URI of the reblogged status | No |
### Notifications
#### `getNotification`
Retrieves the given notification details.
##### Request
| Parameter (type) | Description | Optional |
| ------------------------- | ----------------------------------------- | -------- |
| `notificationID` (string) | The instance-local ID of the notification | No |
##### Response
| Parameter (type) | Description | Optional |
| -------------------- | ------------------------------------------------------------ | -------- |
| `kind` (string) | One of `mention`, `reblog`, `favourite`, or `follow` | No |
| `date` (date) | The date the notification was created. | No |
| `accountID` (string) | The instance-local ID of the account that sent the notification | No |
| `statusID` (string) | The instance-local ID of the status associated with the notification. Not applicable for `kind=follow`. | Yes |
#### `getNotifications`
Retrieves the most recent notifications.
##### Request
| Parameter (type) | Description | Optional |
| ---------------- | ---------------------------------------------------- | -------- |
| `count` (int) | The number of notifications to retrieve. Default: 20 | Yes |
##### Response
| Parameter (type) | Description | Optional |
| ------------------------ | ---------------------------------------------------------- | -------- |
| `notifications` (string) | A comma-delimited array of instance-local notification IDs | No |
#### `dismissNotification`
Dismisses the given notification.
##### Request
| Parameter (type) | Description | Optional |
| ----------------------- | ----------------------------------------- | -------- |
| `notification` (string) | The instance-local ID of the notification | No |
##### Response
No response data if successful.
#### `dismissAllNotifications`
Dismisses all notifications.
##### Request
No parameters.
##### Response
No data if successful.
### Instances
#### `getCurrentInstance`
Retrieves the current instance details.
##### Request
No parameters.
##### Response
| Parameter (type) | Description | Optional |
| ------------------------- | ------------------------------------------------------- | -------- |
| `uri` (string) | The instance URI | No |
| `name` (string) | The instance name | No |
| `description` (string) | The instance description | No |
| `contactAccount` (string) | The instance-local ID of the instance's contact account | No |
### Misc
#### `search`
Performs a search in Tusker with the given query
##### Request
| Parameter (type) | Description | Optional |
| ---------------- | ------------------------ |--------- |
| `query` (string) | The search query to use. | No |
##### Response
No data if successful.

1
Gifu

@ -1 +0,0 @@
Subproject commit 9b1a6461aa3b5f66cb0ed3a50c5523db0b4fb007

View File

@ -24,8 +24,6 @@
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionJavaScriptPreprocessingFile</key>
<string>Action</string>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsAttachmentsWithMinCount</key>
@ -35,6 +33,8 @@
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
<key>NSExtensionJavaScriptPreprocessingFile</key>
<string>Action</string>
<key>NSExtensionServiceAllowsFinderPreviewItem</key>
<true/>
<key>NSExtensionServiceAllowsTouchBarItem</key>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>

View File

@ -1,84 +0,0 @@
//
// Hashtag.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
public class Hashtag: Codable {
public let name: String
public let url: URL
public let history: [History]?
public init(name: String, url: URL) {
self.name = name
self.url = url
self.history = nil
}
private enum CodingKeys: String, CodingKey {
case name
case url
case history
}
}
extension Hashtag {
public class History: Codable {
public let day: Date
public let uses: Int
public let accounts: Int
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let day = try? container.decode(Date.self, forKey: .day) {
self.day = day
} else if let unixTimestamp = try? container.decode(Double.self, forKey: .day) {
self.day = Date(timeIntervalSince1970: unixTimestamp)
} else if let str = try? container.decode(String.self, forKey: .day),
let unixTimestamp = Double(str) {
self.day = Date(timeIntervalSince1970: unixTimestamp)
} else {
throw DecodingError.dataCorruptedError(forKey: .day, in: container, debugDescription: "day must be either date or UNIX timestamp")
}
if let uses = try? container.decode(Int.self, forKey: .uses) {
self.uses = uses
} else if let str = try? container.decode(String.self, forKey: .uses),
let uses = Int(str) {
self.uses = uses
} else {
throw DecodingError.dataCorruptedError(forKey: .uses, in: container, debugDescription: "uses must either be int or string containing int")
}
if let accounts = try? container.decode(Int.self, forKey: .accounts) {
self.accounts = accounts
} else if let str = try? container.decode(String.self, forKey: .accounts),
let accounts = Int(str) {
self.accounts = accounts
} else {
throw DecodingError.dataCorruptedError(forKey: .accounts, in: container, debugDescription: "accounts must either be int or string containing int")
}
}
private enum CodingKeys: String, CodingKey {
case day
case uses
case accounts
}
}
}
extension Hashtag: Equatable, Hashable {
public static func ==(lhs: Hashtag, rhs: Hashtag) -> Bool {
return lhs.name == rhs.name
}
public func hash(into hasher: inout Hasher) {
hasher.combine(url)
}
}

View File

@ -1,87 +0,0 @@
//
// Instance.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
public class Instance: Decodable {
public let uri: String
public let title: String
public let description: String
public let email: String?
public let version: String
public let urls: [String: URL]
public let thumbnail: URL?
public let languages: [String]?
public let stats: Stats?
// pleroma doesn't currently implement these
public let contactAccount: Account?
// MARK: Unofficial additions to the Mastodon API.
public let maxStatusCharacters: Int?
// we need a custom decoder, because all API-compatible implementations don't return some data in the same format
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.uri = try container.decode(String.self, forKey: .uri)
self.title = try container.decode(String.self, forKey: .title)
self.description = try container.decode(String.self, forKey: .description)
self.email = try container.decodeIfPresent(String.self, forKey: .email)
self.version = try container.decode(String.self, forKey: .version)
if let urls = try? container.decodeIfPresent([String: URL].self, forKey: .urls) {
self.urls = urls
} else {
self.urls = [:]
}
self.languages = try? container.decodeIfPresent([String].self, forKey: .languages)
self.contactAccount = try? container.decodeIfPresent(Account.self, forKey: .contactAccount)
self.stats = try? container.decodeIfPresent(Stats.self, forKey: .stats)
self.thumbnail = try? container.decodeIfPresent(URL.self, forKey: .thumbnail)
if let maxStatusCharacters = try? container.decodeIfPresent(Int.self, forKey: .maxStatusCharacters) {
self.maxStatusCharacters = maxStatusCharacters
} else if let str = try? container.decodeIfPresent(String.self, forKey: .maxStatusCharacters),
let maxStatusCharacters = Int(str, radix: 10) {
self.maxStatusCharacters = maxStatusCharacters
} else {
self.maxStatusCharacters = nil
}
}
private enum CodingKeys: String, CodingKey {
case uri
case title
case description
case email
case version
case urls
case thumbnail
case languages
case stats
case contactAccount = "contact_account"
case maxStatusCharacters = "max_toot_chars"
}
}
extension Instance {
public class Stats: Decodable {
public let domainCount: Int?
public let statusCount: Int?
public let userCount: Int?
private enum CodingKeys: String, CodingKey {
case domainCount = "domain_count"
case statusCount = "status_count"
case userCount = "user_count"
}
}
}

View File

@ -1,23 +0,0 @@
//
// Mention.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
public class Mention: Codable {
public let url: URL
public let username: String
public let acct: String
public let id: String
private enum CodingKeys: String, CodingKey {
case url
case username
case acct
case id
}
}

View File

@ -1,19 +0,0 @@
//
// Pachyderm.h
// Pachyderm
//
// Created by Shadowfacts on 9/8/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Pachyderm.
FOUNDATION_EXPORT double PachydermVersionNumber;
//! Project version string for Pachyderm.
FOUNDATION_EXPORT const unsigned char PachydermVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Pachyderm/PublicHeader.h>

View File

@ -1,24 +0,0 @@
//
// InstanceType.swift
// Pachyderm
//
// Created by Shadowfacts on 9/11/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import Foundation
public enum InstanceType {
case mastodon, pleroma
}
public extension Instance {
var instanceType: InstanceType {
let lowercased = version.lowercased()
if lowercased.contains("pleroma") {
return .pleroma
} else {
return .mastodon
}
}
}

View File

@ -1,54 +0,0 @@
//
// NotificationGroup.swift
// Pachyderm
//
// Created by Shadowfacts on 9/5/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import Foundation
public class NotificationGroup {
public let notifications: [Notification]
public let id: String
public let kind: Notification.Kind
public let statusState: StatusState?
init?(notifications: [Notification]) {
guard !notifications.isEmpty else { return nil }
self.notifications = notifications
self.id = notifications.first!.id
self.kind = notifications.first!.kind
if kind == .mention {
self.statusState = .unknown
} else {
self.statusState = nil
}
}
public static func createGroups(notifications: [Notification], only allowedTypes: [Notification.Kind]) -> [NotificationGroup] {
var groups = [[Notification]]()
for notification in notifications {
if allowedTypes.contains(notification.kind) {
if let lastGroup = groups.last, let firstNotification = lastGroup.first, firstNotification.kind == notification.kind, firstNotification.status?.id == notification.status?.id {
groups[groups.count - 1].append(notification)
continue
} else if groups.count >= 2 {
let secondToLastGroup = groups[groups.count - 2]
if allowedTypes.contains(groups[groups.count - 1][0].kind), let firstNotification = secondToLastGroup.first, firstNotification.kind == notification.kind, firstNotification.status?.id == notification.status?.id {
groups[groups.count - 2].append(notification)
continue
}
}
}
groups.append([notification])
}
return groups.map {
NotificationGroup(notifications: $0)!
}
}
}
extension NotificationGroup: Identifiable {}

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,34 +0,0 @@
//
// PachydermTests.swift
// PachydermTests
//
// Created by Shadowfacts on 9/8/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import XCTest
@testable import Pachyderm
class PachydermTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}

9
Packages/Duckable/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

View File

@ -0,0 +1,31 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Duckable",
platforms: [
.iOS(.v15),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Duckable",
targets: ["Duckable"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Duckable",
dependencies: []),
.testTarget(
name: "DuckableTests",
dependencies: ["Duckable"]),
]
)

View File

@ -0,0 +1,3 @@
# Duckable
A package that allows modally-presented view controllers to be 'ducked' to make the content behind them accessible (à la Mail.app).

View File

@ -0,0 +1,44 @@
//
// API.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
public protocol DuckableViewController: UIViewController {
var duckableDelegate: DuckableViewControllerDelegate? { get set }
func duckableViewControllerMayAttemptToDuck()
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat)
func duckableViewControllerDidFinishAnimatingDuck()
}
extension DuckableViewController {
public func duckableViewControllerMayAttemptToDuck() {}
public func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {}
public func duckableViewControllerDidFinishAnimatingDuck() {}
}
public protocol DuckableViewControllerDelegate: AnyObject {
func duckableViewControllerWillDismiss(animated: Bool)
}
extension UIViewController {
@available(iOS 16.0, *)
public func presentDuckable(_ viewController: DuckableViewController, animated: Bool, isDucked: Bool = false) -> Bool {
var cur: UIViewController? = self
while let vc = cur {
if let container = vc as? DuckableContainerViewController {
container.presentDuckable(viewController, animated: animated, isDucked: isDucked, completion: nil)
return true
} else {
cur = vc.parent
}
}
return false
}
}

View File

@ -0,0 +1,12 @@
//
// DetentIdentifier.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
extension UISheetPresentationController.Detent.Identifier {
static let bottom = Self("\(Bundle.main.bundleIdentifier!).bottom")
}

View File

@ -0,0 +1,89 @@
//
// DuckAnimationController.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
@available(iOS 16.0, *)
class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
let owner: DuckableContainerViewController
let needsShrinkAnimation: Bool
init(owner: DuckableContainerViewController, needsShrinkAnimation: Bool) {
self.owner = owner
self.needsShrinkAnimation = needsShrinkAnimation
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.2
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard case .ducked(let duckable, placeholder: let placeholder) = owner.state,
let presented = transitionContext.viewController(forKey: .from) else {
transitionContext.completeTransition(false)
return
}
guard transitionContext.isAnimated else {
transitionContext.completeTransition(true)
return
}
let container = transitionContext.containerView
if needsShrinkAnimation {
duckable.duckableViewControllerWillAnimateDuck(withDuration: 0.2, afterDelay: 0.2)
let presentedFrameInContainer = container.convert(presented.view.bounds, from: presented.view)
let heightToSlide = container.bounds.height - container.safeAreaInsets.bottom - detentHeight - presentedFrameInContainer.minY
let slideAnimator = UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1)
slideAnimator.addAnimations {
container.transform = CGAffineTransform(translationX: 0, y: heightToSlide + 10)
}
slideAnimator.addCompletion { _ in
duckable.duckableViewControllerDidFinishAnimatingDuck()
transitionContext.completeTransition(true)
}
slideAnimator.startAnimation()
placeholder.view.transform = CGAffineTransform(translationX: 0, y: 10)
let bounceAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
placeholder.view.transform = .identity
container.transform = CGAffineTransform(translationX: 0, y: heightToSlide)
}
bounceAnimator.startAnimation(afterDelay: 0.3)
let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
presented.view.layer.opacity = 0
}
fadeAnimator.startAnimation(afterDelay: 0.3)
} else {
duckable.duckableViewControllerWillAnimateDuck(withDuration: 0.2, afterDelay: 0)
placeholder.view.transform = CGAffineTransform(translationX: 0, y: 10)
let bounceAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
placeholder.view.transform = .identity
container.transform = CGAffineTransform(translationX: 0, y: -10)
}
bounceAnimator.startAnimation(afterDelay: 0.2)
let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
presented.view.layer.opacity = 0
}
fadeAnimator.addCompletion { _ in
duckable.duckableViewControllerDidFinishAnimatingDuck()
transitionContext.completeTransition(true)
}
fadeAnimator.startAnimation(afterDelay: 0.2)
}
}
}

View File

@ -0,0 +1,239 @@
//
// DuckableContainerViewController.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
let duckedCornerRadius: CGFloat = 10
let detentHeight: CGFloat = 44
@available(iOS 16.0, *)
public class DuckableContainerViewController: UIViewController, DuckableViewControllerDelegate {
public let child: UIViewController
private var bottomConstraint: NSLayoutConstraint!
private(set) var state = State.idle
public var duckedViewController: DuckableViewController? {
if case .ducked(let vc, placeholder: _) = state {
return vc
} else {
return nil
}
}
public init(child: UIViewController) {
self.child = child
super.init(nibName: nil, bundle: nil)
swizzleSheetController()
}
required init?(coder: NSCoder) {
fatalError()
}
public override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .black
child.beginAppearanceTransition(true, animated: false)
addChild(child)
child.didMove(toParent: self)
child.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(child.view)
child.endAppearanceTransition()
bottomConstraint = child.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
NSLayoutConstraint.activate([
child.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
child.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
child.view.topAnchor.constraint(equalTo: view.topAnchor),
bottomConstraint,
])
}
func presentDuckable(_ viewController: DuckableViewController, animated: Bool, isDucked: Bool, completion: (() -> Void)?) {
guard case .idle = state else {
if animated,
case .ducked(_, placeholder: let placeholder) = state {
UIImpactFeedbackGenerator(style: .soft).impactOccurred()
let origConstant = placeholder.topConstraint.constant
UIView.animateKeyframes(withDuration: 0.4, delay: 0) {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.5) {
placeholder.topConstraint.constant = origConstant - 20
self.view.layoutIfNeeded()
}
UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5) {
placeholder.topConstraint.constant = origConstant
self.view.layoutIfNeeded()
}
}
}
return
}
if isDucked {
state = .ducked(viewController, placeholder: createPlaceholderForDuckedViewController(viewController))
configureChildForDuckedPlaceholder()
} else {
state = .presentingDucked(viewController, isFirstPresentation: true)
doPresentDuckable(viewController, animated: animated, completion: completion)
}
}
private func doPresentDuckable(_ viewController: DuckableViewController, animated: Bool, completion: (() -> Void)?) {
viewController.duckableDelegate = self
let nav = UINavigationController(rootViewController: viewController)
nav.modalPresentationStyle = .custom
nav.transitioningDelegate = self
present(nav, animated: animated) {
self.configureChildForDuckedPlaceholder()
completion?()
}
}
public func duckableViewControllerWillDismiss(animated: Bool) {
state = .idle
bottomConstraint.isActive = false
bottomConstraint = child.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
bottomConstraint.isActive = true
child.view.layer.cornerRadius = 0
setOverrideTraitCollection(nil, forChild: child)
}
func createPlaceholderForDuckedViewController(_ viewController: DuckableViewController) -> DuckedPlaceholderViewController {
let placeholder = DuckedPlaceholderViewController(for: viewController, owner: self)
placeholder.view.translatesAutoresizingMaskIntoConstraints = false
placeholder.beginAppearanceTransition(true, animated: false)
self.addChild(placeholder)
placeholder.didMove(toParent: self)
self.view.addSubview(placeholder.view)
placeholder.endAppearanceTransition()
let placeholderTopConstraint = placeholder.view.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: -detentHeight)
placeholder.topConstraint = placeholderTopConstraint
NSLayoutConstraint.activate([
placeholder.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
placeholder.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
placeholder.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
placeholderTopConstraint
])
// otherwise the layout changes get lumped in with the system animation
UIView.performWithoutAnimation {
self.view.layoutIfNeeded()
}
return placeholder
}
func duckViewController() {
guard case .presentingDucked(let viewController, isFirstPresentation: _) = state else {
return
}
let placeholder = createPlaceholderForDuckedViewController(viewController)
state = .ducked(viewController, placeholder: placeholder)
configureChildForDuckedPlaceholder()
dismiss(animated: true)
}
private func configureChildForDuckedPlaceholder() {
bottomConstraint.isActive = false
bottomConstraint = child.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -detentHeight - 4)
bottomConstraint.isActive = true
child.view.layer.cornerRadius = duckedCornerRadius
child.view.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
child.view.layer.masksToBounds = true
}
@objc func unduckViewController() {
guard case .ducked(let viewController, placeholder: let placeholder) = state else {
return
}
state = .presentingDucked(viewController, isFirstPresentation: false)
doPresentDuckable(viewController, animated: true) {
placeholder.view.removeFromSuperview()
placeholder.willMove(toParent: nil)
placeholder.removeFromParent()
}
}
func sheetOffsetDidChange() {
if case .presentingDucked(let duckable, isFirstPresentation: _) = state {
duckable.duckableViewControllerMayAttemptToDuck()
}
}
enum State {
case idle
case presentingDucked(DuckableViewController, isFirstPresentation: Bool)
case ducked(DuckableViewController, placeholder: DuckedPlaceholderViewController)
}
}
@available(iOS 16.0, *)
extension DuckableContainerViewController: UIViewControllerTransitioningDelegate {
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
let controller = UISheetPresentationController(presentedViewController: presented, presenting: presenting)
controller.delegate = self
controller.prefersGrabberVisible = true
controller.selectedDetentIdentifier = .large
controller.largestUndimmedDetentIdentifier = .bottom
controller.detents = [
.custom(identifier: .bottom, resolver: { context in
return detentHeight
}),
.large(),
]
return controller
}
public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if case .ducked(_, placeholder: _) = state {
return DuckAnimationController(
owner: self,
needsShrinkAnimation: isDetentChangingDueToGrabberAction
)
} else {
return nil
}
}
}
@available(iOS 16.0, *)
extension DuckableContainerViewController: UISheetPresentationControllerDelegate {
public func presentationController(_ presentationController: UIPresentationController, willPresentWithAdaptiveStyle style: UIModalPresentationStyle, transitionCoordinator: UIViewControllerTransitionCoordinator?) {
guard let snapshot = child.view.snapshotView(afterScreenUpdates: false) else {
setOverrideTraitCollection(UITraitCollection(userInterfaceLevel: .elevated), forChild: child)
return
}
snapshot.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(snapshot)
NSLayoutConstraint.activate([
snapshot.leadingAnchor.constraint(equalTo: child.view.leadingAnchor),
snapshot.trailingAnchor.constraint(equalTo: child.view.trailingAnchor),
snapshot.topAnchor.constraint(equalTo: child.view.topAnchor),
snapshot.bottomAnchor.constraint(equalTo: child.view.bottomAnchor),
])
setOverrideTraitCollection(UITraitCollection(userInterfaceLevel: .elevated), forChild: child)
transitionCoordinator!.animate { context in
snapshot.layer.opacity = 0
} completion: { _ in
snapshot.removeFromSuperview()
}
}
public func sheetPresentationControllerDidChangeSelectedDetentIdentifier(_ sheetPresentationController: UISheetPresentationController) {
if sheetPresentationController.selectedDetentIdentifier == .bottom {
duckViewController()
}
}
}

View File

@ -0,0 +1,71 @@
//
// DuckedPlaceholderView.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
@available(iOS 16.0, *)
class DuckedPlaceholderViewController: UIViewController {
private unowned let owner: DuckableContainerViewController
private let navBar = UINavigationBar()
var topConstraint: NSLayoutConstraint!
init(for duckableViewController: DuckableViewController, owner: DuckableContainerViewController) {
self.owner = owner
super.init(nibName: nil, bundle: nil)
let item = UINavigationItem()
item.title = duckableViewController.navigationItem.title
item.titleView = duckableViewController.navigationItem.titleView
navBar.setItems([item], animated: false)
}
required init?(coder: NSCoder) {
fatalError()
}
override func viewDidLoad() {
super.viewDidLoad()
setBackgroundColor()
view.layer.cornerRadius = duckedCornerRadius
view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.05
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(placeholderTapped)))
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
navBar.standardAppearance = appearance
navBar.isUserInteractionEnabled = false
navBar.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(navBar)
NSLayoutConstraint.activate([
navBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
navBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
navBar.topAnchor.constraint(equalTo: view.topAnchor),
])
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
setBackgroundColor()
}
private func setBackgroundColor() {
// when just using .systemBackground and setting the override trait collection for the placeholder VC,
// the color doesn't change until after the dismiss animation occurs (but only when tapping the grabber to duck, not when swiping)
view.backgroundColor = .systemBackground.resolvedColor(with: UITraitCollection(traitsFrom: [traitCollection, UITraitCollection(userInterfaceLevel: .elevated)]))
}
@objc private func placeholderTapped() {
owner.unduckViewController()
}
}

View File

@ -0,0 +1,33 @@
//
// Swizzler.swift
// Duckable
//
// Created by Shadowfacts on 11/7/22.
//
import UIKit
import os.log
private var hasInitialized = false
var isDetentChangingDueToGrabberAction = false
@available(iOS 16.0, *)
func swizzleSheetController() {
guard !hasInitialized else {
return
}
hasInitialized = true
var originalIMP: IMP?
let imp = imp_implementationWithBlock({ (self: UISheetPresentationController, param: AnyObject) in
let original = unsafeBitCast(originalIMP!, to: (@convention(c) (UISheetPresentationController, AnyObject) -> Void).self)
isDetentChangingDueToGrabberAction = true
original(self, param)
isDetentChangingDueToGrabberAction = false
} as @convention(block) (UISheetPresentationController, AnyObject) -> Void)
let sel = [":", "PrimaryAction", "GrabberDidTrigger", "dropShadowView", "_"].reversed().joined()
originalIMP = class_replaceMethod(UISheetPresentationController.self, Selector(sel), imp, "v@:@")
if originalIMP == nil {
os_log(.fault, log: .default, "Unable to initialize Duckable grabber tap hook")
}
}

View File

@ -0,0 +1,34 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Pachyderm",
platforms: [
.iOS(.v14),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Pachyderm",
targets: ["Pachyderm"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/karwa/swift-url.git", branch: "main"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Pachyderm",
dependencies: [
.product(name: "WebURL", package: "swift-url"),
.product(name: "WebURLFoundationExtras", package: "swift-url"),
]),
.testTarget(
name: "PachydermTests",
dependencies: ["Pachyderm"]),
]
)

View File

@ -0,0 +1,3 @@
# Pachyderm
A description of this package.

View File

@ -68,29 +68,32 @@ public class Client {
@discardableResult
public func run<Result>(_ request: Request<Result>, completion: @escaping Callback<Result>) -> URLSessionTask? {
guard let request = createURLRequest(request: request) else {
completion(.failure(Error.invalidRequest))
guard let urlRequest = createURLRequest(request: request) else {
completion(.failure(Error(request: request, type: .invalidRequest)))
return nil
}
let task = session.dataTask(with: request) { data, response, error in
let task = session.dataTask(with: urlRequest) { data, response, error in
if let error = error {
completion(.failure(.networkError(error)))
completion(.failure(Error(request: request, type: .networkError(error))))
return
}
guard let data = data,
let response = response as? HTTPURLResponse else {
completion(.failure(.invalidResponse))
completion(.failure(Error(request: request, type: .invalidResponse)))
return
}
guard response.statusCode == 200 else {
let mastodonError = try? Client.decoder.decode(MastodonError.self, from: data)
let error: Error = mastodonError.flatMap { .mastodonError($0.description) } ?? .unexpectedStatus(response.statusCode)
completion(.failure(error))
let type: ErrorType = mastodonError.flatMap { .mastodonError(response.statusCode, $0.description) } ?? .unexpectedStatus(response.statusCode)
completion(.failure(Error(request: request, type: type)))
return
}
guard let result = try? Client.decoder.decode(Result.self, from: data) else {
completion(.failure(.invalidModel))
let result: Result
do {
result = try Client.decoder.decode(Result.self, from: data)
} catch {
completion(.failure(Error(request: request, type: .invalidModel(error))))
return
}
let pagination = response.allHeaderFields["Link"].flatMap { $0 as? String }.flatMap(Pagination.init)
@ -103,13 +106,15 @@ public class Client {
func createURLRequest<Result>(request: Request<Result>) -> URLRequest? {
guard var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: true) else { return nil }
components.path = request.path
components.path = request.endpoint.path
components.queryItems = request.queryParameters.isEmpty ? nil : request.queryParameters.queryItems
guard let url = components.url else { return nil }
var urlRequest = URLRequest(url: url, timeoutInterval: timeoutInterval)
urlRequest.httpMethod = request.method.name
urlRequest.httpBody = request.body.data
urlRequest.setValue(request.body.mimeType, forHTTPHeaderField: "Content-Type")
if let mimeType = request.body.mimeType {
urlRequest.setValue(mimeType, forHTTPHeaderField: "Content-Type")
}
if let accessToken = accessToken {
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
}
@ -150,6 +155,24 @@ public class Client {
}
}
public func nodeInfo(completion: @escaping Callback<NodeInfo>) {
let wellKnown = Request<WellKnown>(method: .get, path: "/.well-known/nodeinfo")
run(wellKnown) { result in
switch result {
case let .failure(error):
completion(.failure(error))
case let .success(wellKnown, _):
if let url = wellKnown.links.first(where: { $0.rel == "http://nodeinfo.diaspora.software/ns/schema/2.0" }),
let components = URLComponents(string: url.href),
components.host == self.baseURL.host {
let nodeInfo = Request<NodeInfo>(method: .get, path: Endpoint(stringLiteral: components.path))
self.run(nodeInfo, completion: completion)
}
}
}
}
// MARK: - Self
public static func getSelfAccount() -> Request<Account> {
return Request<Account>(method: .get, path: "/api/v1/accounts/verify_credentials")
@ -206,21 +229,25 @@ public class Client {
}
// MARK: - Filters
public static func getFilters() -> Request<[Filter]> {
return Request<[Filter]>(method: .get, path: "/api/v1/filters")
public static func getFiltersV1() -> Request<[FilterV1]> {
return Request<[FilterV1]>(method: .get, path: "/api/v1/filters")
}
public static func createFilter(phrase: String, context: [Filter.Context], irreversible: Bool? = nil, wholeWord: Bool? = nil, expiresAt: Date? = nil) -> Request<Filter> {
return Request<Filter>(method: .post, path: "/api/v1/filters", body: ParametersBody([
public static func createFilterV1(phrase: String, context: [FilterV1.Context], irreversible: Bool? = nil, wholeWord: Bool? = nil, expiresIn: TimeInterval? = nil) -> Request<FilterV1> {
return Request<FilterV1>(method: .post, path: "/api/v1/filters", body: ParametersBody([
"phrase" => phrase,
"irreversible" => irreversible,
"whole_word" => wholeWord,
"expires_at" => expiresAt
"expires_in" => expiresIn,
] + "context" => context.contextStrings))
}
public static func getFilter(id: String) -> Request<Filter> {
return Request<Filter>(method: .get, path: "/api/v1/filters/\(id)")
public static func getFilterV1(id: String) -> Request<FilterV1> {
return Request<FilterV1>(method: .get, path: "/api/v1/filters/\(id)")
}
public static func getFiltersV2() -> Request<[FilterV2]> {
return Request(method: .get, path: "/api/v2/filters")
}
// MARK: - Follows
@ -238,6 +265,10 @@ public class Client {
return Request<Account>(method: .post, path: "/api/v1/follows", body: ParametersBody(["uri" => acct]))
}
public static func getFollowedHashtags() -> Request<[Hashtag]> {
return Request(method: .get, path: "/api/v1/followed_tags")
}
// MARK: - Lists
public static func getLists() -> Request<[List]> {
return Request<[List]>(method: .get, path: "/api/v1/lists")
@ -267,9 +298,17 @@ public class Client {
}
// MARK: - Notifications
public static func getNotifications(excludeTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
public static func getNotifications(allowedTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
"exclude_types" => excludeTypes.map { $0.rawValue }
"types" => allowedTypes.map { $0.rawValue }
)
request.range = range
return request
}
public static func getNotifications(excludedTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
"exclude_types" => excludedTypes.map { $0.rawValue }
)
request.range = range
return request
@ -284,19 +323,29 @@ public class Client {
return Request<[Report]>(method: .get, path: "/api/v1/reports")
}
public static func report(account: Account, statuses: [Status], comment: String) -> Request<Report> {
public static func report(
account: String,
statuses: [String],
comment: String,
forward: Bool,
category: String,
ruleIDs: [String]
) -> Request<Report> {
return Request<Report>(method: .post, path: "/api/v1/reports", body: ParametersBody([
"account_id" => account.id,
"comment" => comment
] + "status_ids" => statuses.map { $0.id }))
"account_id" => account,
"comment" => comment,
"forward" => forward,
"category" => category,
] + "status_ids" => statuses + "rule_ids" => ruleIDs))
}
// MARK: - Search
public static func search(query: String, types: [SearchResultType]? = nil, resolve: Bool? = nil, limit: Int? = nil) -> Request<SearchResults> {
public static func search(query: String, types: [SearchResultType]? = nil, resolve: Bool? = nil, limit: Int? = nil, following: Bool? = nil) -> Request<SearchResults> {
return Request<SearchResults>(method: .get, path: "/api/v2/search", queryParameters: [
"q" => query,
"resolve" => resolve,
"limit" => limit,
"following" => following,
] + "types" => types?.map { $0.rawValue })
}
@ -315,7 +364,8 @@ public class Client {
language: String? = nil,
pollOptions: [String]? = nil,
pollExpiresIn: Int? = nil,
pollMultiple: Bool? = nil) -> Request<Status> {
pollMultiple: Bool? = nil,
localOnly: Bool? = nil /* hometown only, not glitch */) -> Request<Status> {
return Request<Status>(method: .post, path: "/api/v1/statuses", body: ParametersBody([
"status" => text,
"content_type" => contentType.mimeType,
@ -326,6 +376,7 @@ public class Client {
"language" => language,
"poll[expires_in]" => pollExpiresIn,
"poll[multiple]" => pollMultiple,
"local_only" => localOnly,
] + "media_ids" => media?.map { $0.id } + "poll[options]" => pollOptions))
}
@ -343,7 +394,7 @@ public class Client {
}
// MARK: - Instance
public static func getTrends(limit: Int? = nil) -> Request<[Hashtag]> {
public static func getTrendingHashtags(limit: Int? = nil) -> Request<[Hashtag]> {
let parameters: [Parameter]
if let limit = limit {
parameters = ["limit" => limit]
@ -353,6 +404,26 @@ public class Client {
return Request<[Hashtag]>(method: .get, path: "/api/v1/trends", queryParameters: parameters)
}
public static func getTrendingStatuses(limit: Int? = nil) -> Request<[Status]> {
let parameters: [Parameter]
if let limit = limit {
parameters = ["limit" => limit]
} else {
parameters = []
}
return Request(method: .get, path: "/api/v1/trends/statuses", queryParameters: parameters)
}
public static func getTrendingLinks(limit: Int? = nil) -> Request<[Card]> {
let parameters: [Parameter]
if let limit = limit {
parameters = ["limit" => limit]
} else {
parameters = []
}
return Request(method: .get, path: "/api/v1/trends/links", queryParameters: parameters)
}
public static func getFeaturedProfiles(local: Bool, order: DirectoryOrder, offset: Int? = nil, limit: Int? = nil) -> Request<[Account]> {
var parameters = [
"order" => order.rawValue,
@ -367,19 +438,32 @@ public class Client {
return Request<[Account]>(method: .get, path: "/api/v1/directory", queryParameters: parameters)
}
public static func getSuggestions(limit: Int?) -> Request<[Suggestion]> {
return Request(method: .get, path: "/api/v2/suggestions", queryParameters: [
"limit" => limit,
])
}
}
extension Client {
public enum Error: LocalizedError {
case networkError(Swift.Error)
case unexpectedStatus(Int)
case invalidRequest
case invalidResponse
case invalidModel
case mastodonError(String)
public struct Error: LocalizedError {
public let requestMethod: Method
public let requestEndpoint: Endpoint
public let type: ErrorType
#if DEBUG
public static let debug = Error(request: Client.getStatuses(timeline: .home), type: .invalidResponse)
#endif
init<ResultType: Decodable>(request: Request<ResultType>, type: ErrorType) {
self.requestMethod = request.method
self.requestEndpoint = request.endpoint
self.type = type
}
public var localizedDescription: String {
switch self {
switch type {
case .networkError(let error):
return "Network Error: \(error.localizedDescription)"
// todo: support more status codes
@ -391,11 +475,19 @@ extension Client {
return "Invalid Request"
case .invalidResponse:
return "Invalid Response"
case .invalidModel:
case .invalidModel(_):
return "Invalid Model"
case .mastodonError(let error):
return "Server Error: \(error)"
case .mastodonError(let code, let error):
return "Server Error (\(code)): \(error)"
}
}
}
public enum ErrorType: LocalizedError {
case networkError(Swift.Error)
case unexpectedStatus(Int)
case invalidRequest
case invalidResponse
case invalidModel(Swift.Error)
case mastodonError(Int, String)
}
}

View File

@ -20,8 +20,9 @@ public final class Account: AccountProtocol, Decodable {
public let statusesCount: Int
public let note: String
public let url: URL
public let avatar: URL
public let avatarStatic: URL
// required on mastodon, but optional on gotosocial
public let avatar: URL?
public let avatarStatic: URL?
public let header: URL?
public let headerStatic: URL?
public private(set) var emojis: [Emoji]
@ -44,11 +45,16 @@ public final class Account: AccountProtocol, Decodable {
self.statusesCount = try container.decode(Int.self, forKey: .statusesCount)
self.note = try container.decode(String.self, forKey: .note)
self.url = try container.decode(URL.self, forKey: .url)
self.avatar = try container.decode(URL.self, forKey: .avatar)
self.avatarStatic = try container.decode(URL.self, forKey: .avatarStatic)
self.avatar = try? container.decode(URL.self, forKey: .avatar)
self.avatarStatic = try? container.decode(URL.self, forKey: .avatarStatic)
self.header = try? container.decode(URL.self, forKey: .header)
self.headerStatic = try? container.decode(URL.self, forKey: .headerStatic)
self.emojis = try container.decode([Emoji].self, forKey: .emojis)
// even up-to-date pixelfed instances sometimes lack this, for reasons unclear
if let emojis = try container.decodeIfPresent([Emoji].self, forKey: .emojis) {
self.emojis = emojis
} else {
self.emojis = []
}
self.fields = (try? container.decode([Field].self, forKey: .fields)) ?? []
self.bot = try? container.decode(Bool.self, forKey: .bot)
@ -76,23 +82,24 @@ public final class Account: AccountProtocol, Decodable {
return Request<Empty>(method: .delete, path: "/api/v1/suggestions/\(account.id)")
}
public static func getFollowers(_ account: Account, range: RequestRange = .default) -> Request<[Account]> {
var request = Request<[Account]>(method: .get, path: "/api/v1/accounts/\(account.id)/followers")
public static func getFollowers(_ accountID: String, range: RequestRange = .default) -> Request<[Account]> {
var request = Request<[Account]>(method: .get, path: "/api/v1/accounts/\(accountID)/followers")
request.range = range
return request
}
public static func getFollowing(_ account: Account, range: RequestRange = .default) -> Request<[Account]> {
var request = Request<[Account]>(method: .get, path: "/api/v1/accounts/\(account.id)/following")
public static func getFollowing(_ accountID: String, range: RequestRange = .default) -> Request<[Account]> {
var request = Request<[Account]>(method: .get, path: "/api/v1/accounts/\(accountID)/following")
request.range = range
return request
}
public static func getStatuses(_ accountID: String, range: RequestRange = .default, onlyMedia: Bool? = nil, pinned: Bool? = nil, excludeReplies: Bool? = nil) -> Request<[Status]> {
public static func getStatuses(_ accountID: String, range: RequestRange = .default, onlyMedia: Bool? = nil, pinned: Bool? = nil, excludeReplies: Bool? = nil, excludeReblogs: Bool? = nil) -> Request<[Status]> {
var request = Request<[Status]>(method: .get, path: "/api/v1/accounts/\(accountID)/statuses", queryParameters: [
"only_media" => onlyMedia,
"pinned" => pinned,
"exclude_replies" => excludeReplies
"exclude_replies" => excludeReplies,
"exclude_reblogs" => excludeReblogs,
])
request.range = range
return request
@ -106,22 +113,22 @@ public final class Account: AccountProtocol, Decodable {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(accountID)/unfollow")
}
public static func block(_ account: Account) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(account.id)/block")
public static func block(_ accountID: String) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(accountID)/block")
}
public static func unblock(_ account: Account) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(account.id)/unblock")
public static func unblock(_ accountID: String) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(accountID)/unblock")
}
public static func mute(_ account: Account, notifications: Bool? = nil) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(account.id)/mute", body: ParametersBody([
public static func mute(_ accountID: String, notifications: Bool? = nil) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(accountID)/mute", body: ParametersBody([
"notifications" => notifications
]))
}
public static func unmute(_ account: Account) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(account.id)/unmute")
public static func unmute(_ accountID: String) -> Request<Relationship> {
return Request<Relationship>(method: .post, path: "/api/v1/accounts/\(accountID)/unmute")
}
public static func getLists(_ account: Account) -> Request<[List]> {
@ -161,5 +168,12 @@ extension Account {
public struct Field: Codable {
public let name: String
public let value: String
public let verifiedAt: Date?
enum CodingKeys: String, CodingKey {
case name
case value
case verifiedAt = "verified_at"
}
}
}

View File

@ -14,7 +14,6 @@ public class Attachment: Codable {
public let url: URL
public let remoteURL: URL?
public let previewURL: URL?
public let textURL: URL?
public let meta: Metadata?
public let description: String?
public let blurHash: String?
@ -33,7 +32,6 @@ public class Attachment: Codable {
self.url = try container.decode(URL.self, forKey: .url)
self.previewURL = try? container.decode(URL?.self, forKey: .previewURL)
self.remoteURL = try? container.decode(URL?.self, forKey: .remoteURL)
self.textURL = try? container.decode(URL?.self, forKey: .textURL)
self.meta = try? container.decode(Metadata?.self, forKey: .meta)
self.description = try? container.decode(String?.self, forKey: .description)
self.blurHash = try? container.decode(String?.self, forKey: .blurHash)
@ -45,7 +43,6 @@ public class Attachment: Codable {
case url
case remoteURL = "remote_url"
case previewURL = "preview_url"
case textURL = "text_url"
case meta
case description
case blurHash = "blurhash"
@ -59,6 +56,23 @@ extension Attachment {
case gifv
case audio
case unknown
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
switch try container.decode(String.self) {
// gotosocial uses "gif" for gif images
case "image", "gif":
self = .image
case "video":
self = .video
case "gifv":
self = .gifv
case "audio":
self = .audio
default:
self = .unknown
}
}
}
}

View File

@ -7,38 +7,42 @@
//
import Foundation
import WebURL
public class Card: Codable {
public let url: URL
public let url: WebURL
public let title: String
public let description: String
public let image: URL?
public let image: WebURL?
public let kind: Kind
public let authorName: String?
public let authorURL: URL?
public let authorURL: WebURL?
public let providerName: String?
public let providerURL: URL?
public let providerURL: WebURL?
public let html: String?
public let width: Int?
public let height: Int?
public let blurhash: String?
/// Only present when returned from the trending links endpoint
public let history: [History]?
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.url = try container.decode(URL.self, forKey: .url)
self.url = try container.decode(WebURL.self, forKey: .url)
self.title = try container.decode(String.self, forKey: .title)
self.description = try container.decode(String.self, forKey: .description)
self.kind = try container.decode(Kind.self, forKey: .kind)
self.image = try? container.decodeIfPresent(URL.self, forKey: .image)
self.image = try? container.decodeIfPresent(WebURL.self, forKey: .image)
self.authorName = try? container.decodeIfPresent(String.self, forKey: .authorName)
self.authorURL = try? container.decodeIfPresent(URL.self, forKey: .authorURL)
self.authorURL = try? container.decodeIfPresent(WebURL.self, forKey: .authorURL)
self.providerName = try? container.decodeIfPresent(String.self, forKey: .providerName)
self.providerURL = try? container.decodeIfPresent(URL.self, forKey: .providerURL)
self.providerURL = try? container.decodeIfPresent(WebURL.self, forKey: .providerURL)
self.html = try? container.decodeIfPresent(String.self, forKey: .html)
self.width = try? container.decodeIfPresent(Int.self, forKey: .width)
self.height = try? container.decodeIfPresent(Int.self, forKey: .height)
self.blurhash = try? container.decodeIfPresent(String.self, forKey: .blurhash)
self.history = try? container.decodeIfPresent([History].self, forKey: .history)
}
public func encode(to encoder: Encoder) throws {
@ -66,6 +70,7 @@ public class Card: Codable {
case width
case height
case blurhash
case history
}
}
@ -74,5 +79,6 @@ extension Card {
case link
case photo
case video
case rich
}
}

View File

@ -8,7 +8,7 @@
import Foundation
public enum DirectoryOrder: String {
public enum DirectoryOrder: String, CaseIterable {
case active
case new
}

View File

@ -7,30 +7,25 @@
//
import Foundation
import WebURL
public class Emoji: Codable {
public let shortcode: String
public let url: URL
public let staticURL: URL
// these shouldn't need to be WebURLs as they're not external resources,
// but some instances (pleroma?) has emoji urls that Foundation considers malformed so we use WebURL to be more lenient
public let url: WebURL
public let staticURL: WebURL
public let visibleInPicker: Bool
public let category: String?
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.shortcode = try container.decode(String.self, forKey: .shortcode)
if let url = try? container.decode(URL.self, forKey: .url) {
self.url = url
} else {
let str = try container.decode(String.self, forKey: .url)
self.url = URL(string: str.replacingOccurrences(of: " ", with: "%20"))!
}
if let url = try? container.decode(URL.self, forKey: .staticURL) {
self.staticURL = url
} else {
let staticStr = try container.decode(String.self, forKey: .staticURL)
self.staticURL = URL(string: staticStr.replacingOccurrences(of: " ", with: "%20"))!
}
self.url = try container.decode(WebURL.self, forKey: .url)
self.staticURL = try container.decode(WebURL.self, forKey: .staticURL)
self.visibleInPicker = try container.decode(Bool.self, forKey: .visibleInPicker)
self.category = try container.decodeIfPresent(String.self, forKey: .category)
}
private enum CodingKeys: String, CodingKey {
@ -38,6 +33,7 @@ public class Emoji: Codable {
case url
case staticURL = "static_url"
case visibleInPicker = "visible_in_picker"
case category
}
}
@ -46,3 +42,9 @@ extension Emoji: CustomDebugStringConvertible {
return ":\(shortcode):"
}
}
extension Emoji: Equatable {
public static func ==(lhs: Emoji, rhs: Emoji) -> Bool {
return lhs.shortcode == rhs.shortcode && lhs.url == rhs.url
}
}

View File

@ -1,5 +1,5 @@
//
// Filter.swift
// FilterV1.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
@ -8,7 +8,7 @@
import Foundation
public class Filter: Decodable {
public struct FilterV1: Decodable {
public let id: String
public let phrase: String
private let context: [String]
@ -22,17 +22,16 @@ public class Filter: Decodable {
}
}
public static func update(_ filter: Filter, phrase: String? = nil, context: [Context]? = nil, irreversible: Bool? = nil, wholeWord: Bool? = nil, expiresAt: Date? = nil) -> Request<Filter> {
return Request<Filter>(method: .put, path: "/api/v1/filters/\(filter.id)", body: ParametersBody([
"phrase" => (phrase ?? filter.phrase),
"irreversible" => (irreversible ?? filter.irreversible),
"whole_word" => (wholeWord ?? filter.wholeWord),
"expires_at" => (expiresAt ?? filter.expiresAt)
] + "context" => (context?.contextStrings ?? filter.context)))
public static func update(_ filterID: String, phrase: String, context: [Context], irreversible: Bool, wholeWord: Bool, expiresIn: TimeInterval?) -> Request<FilterV1> {
return Request<FilterV1>(method: .put, path: "/api/v1/filters/\(filterID)", body: ParametersBody([
"phrase" => phrase,
"whole_word" => wholeWord,
"expires_in" => expiresIn,
] + "context" => context.contextStrings))
}
public static func delete(_ filter: Filter) -> Request<Empty> {
return Request<Empty>(method: .delete, path: "/api/v1/filters/\(filter.id)")
public static func delete(_ filterID: String) -> Request<Empty> {
return Request<Empty>(method: .delete, path: "/api/v1/filters/\(filterID)")
}
private enum CodingKeys: String, CodingKey {
@ -45,16 +44,17 @@ public class Filter: Decodable {
}
}
extension Filter {
public enum Context: String, Decodable {
extension FilterV1 {
public enum Context: String, Decodable, CaseIterable {
case home
case notifications
case `public`
case thread
case account
}
}
extension Array where Element == Filter.Context {
extension Array where Element == FilterV1.Context {
var contextStrings: [String] {
return map { $0.rawValue }
}

View File

@ -0,0 +1,115 @@
//
// FilterV2.swift
// Pachyderm
//
// Created by Shadowfacts on 12/2/22.
//
import Foundation
public struct FilterV2: Decodable {
public let id: String
public let title: String
public let context: [FilterV1.Context]
public let expiresAt: Date?
public let action: Action
public let keywords: [Keyword]
public static func update(
_ filterID: String,
title: String,
context: [FilterV1.Context],
expiresIn: TimeInterval?,
action: Action,
keywords keywordUpdates: [KeywordUpdate]
) -> Request<FilterV2> {
var keywordsParams = [Parameter]()
for (index, update) in keywordUpdates.enumerated() {
switch update {
case .update(id: let id, keyword: let keyword, wholeWord: let wholeWord):
keywordsParams.append("keywords_attributes[\(index)][id]" => id)
keywordsParams.append("keywords_attributes[\(index)][keyword]" => keyword)
keywordsParams.append("keywords_attributes[\(index)][whole_word]" => wholeWord)
case .add(keyword: let keyword, wholeWord: let wholeWord):
keywordsParams.append("keywords_attributes[\(index)][keyword]" => keyword)
keywordsParams.append("keywords_attributes[\(index)][whole_word]" => wholeWord)
case .destroy(id: let id):
keywordsParams.append("keywords_attributes[\(index)][id]" => id)
keywordsParams.append("keywords_attributes[\(index)][_destroy]" => true)
}
}
return Request(method: .put, path: "/api/v2/filters/\(filterID)", body: ParametersBody([
"title" => title,
"expires_in" => expiresIn,
"filter_action" => action.rawValue,
] + "context" => context.contextStrings + keywordsParams))
}
public static func create(
title: String,
context: [FilterV1.Context],
expiresIn: TimeInterval?,
action: Action,
keywords keywordUpdates: [KeywordUpdate]
) -> Request<FilterV2> {
var keywordsParams = [Parameter]()
for (index, update) in keywordUpdates.enumerated() {
switch update {
case .add(keyword: let keyword, wholeWord: let wholeWord):
keywordsParams.append("keywords_attributes[\(index)][keyword]" => keyword)
keywordsParams.append("keywords_attributes[\(index)][whole_word]" => wholeWord)
default:
fatalError("can only add keywords when creating filter")
}
}
return Request(method: .post, path: "/api/v2/filters", body: ParametersBody([
"title" => title,
"expires_in" => expiresIn,
"filter_action" => action.rawValue,
] + "context" => context.contextStrings + keywordsParams))
}
private enum CodingKeys: String, CodingKey {
case id
case title
case context
case expiresAt = "expires_at"
case action = "filter_action"
case keywords
}
}
extension FilterV2 {
public enum Action: String, Decodable, Hashable, CaseIterable {
case warn
case hide
}
}
extension FilterV2 {
public struct Keyword: Decodable {
public let id: String
public let keyword: String
public let wholeWord: Bool
public init(id: String, keyword: String, wholeWord: Bool) {
self.id = id
self.keyword = keyword
self.wholeWord = wholeWord
}
private enum CodingKeys: String, CodingKey {
case id
case keyword
case wholeWord = "whole_word"
}
}
}
extension FilterV2 {
public enum KeywordUpdate {
case update(id: String, keyword: String, wholeWord: Bool)
case add(keyword: String, wholeWord: Bool)
case destroy(id: String)
}
}

View File

@ -0,0 +1,69 @@
//
// Hashtag.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
import WebURL
import WebURLFoundationExtras
public class Hashtag: Codable {
public let name: String
public let url: WebURL
/// Only present when returned from the trending hashtags endpoint
public let history: [History]?
/// Only present on Mastodon >= 4 and when logged in
public let following: Bool?
public init(name: String, url: URL) {
self.name = name
self.url = WebURL(url)!
self.history = nil
self.following = nil
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decode(String.self, forKey: .name)
// pixelfed (possibly others) don't fully escape special characters in the hashtag url
self.url = try container.decode(WebURL.self, forKey: .url)
self.history = try container.decodeIfPresent([History].self, forKey: .history)
self.following = try container.decodeIfPresent(Bool.self, forKey: .following)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
try container.encode(url, forKey: .url)
try container.encodeIfPresent(history, forKey: .history)
try container.encodeIfPresent(following, forKey: .following)
}
public static func follow(name: String) -> Request<Hashtag> {
return Request(method: .post, path: "/api/v1/tags/\(name)/follow")
}
public static func unfollow(name: String) -> Request<Hashtag> {
return Request(method: .post, path: "/api/v1/tags/\(name)/unfollow")
}
private enum CodingKeys: String, CodingKey {
case name
case url
case history
case following
}
}
extension Hashtag: Equatable, Hashable {
public static func ==(lhs: Hashtag, rhs: Hashtag) -> Bool {
return lhs.name == rhs.name
}
public func hash(into hasher: inout Hasher) {
hasher.combine(url)
}
}

View File

@ -0,0 +1,54 @@
//
// History.swift
// Pachyderm
//
// Created by Shadowfacts on 4/2/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import Foundation
public class History: Codable {
public let day: Date
public let uses: Int
public let accounts: Int
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let day = try? container.decode(Date.self, forKey: .day) {
self.day = day
} else if let unixTimestamp = try? container.decode(Double.self, forKey: .day) {
self.day = Date(timeIntervalSince1970: unixTimestamp)
} else if let str = try? container.decode(String.self, forKey: .day),
let unixTimestamp = Double(str) {
self.day = Date(timeIntervalSince1970: unixTimestamp)
} else {
throw DecodingError.dataCorruptedError(forKey: .day, in: container, debugDescription: "day must be either date or UNIX timestamp")
}
if let uses = try? container.decode(Int.self, forKey: .uses) {
self.uses = uses
} else if let str = try? container.decode(String.self, forKey: .uses),
let uses = Int(str) {
self.uses = uses
} else {
throw DecodingError.dataCorruptedError(forKey: .uses, in: container, debugDescription: "uses must either be int or string containing int")
}
if let accounts = try? container.decode(Int.self, forKey: .accounts) {
self.accounts = accounts
} else if let str = try? container.decode(String.self, forKey: .accounts),
let accounts = Int(str) {
self.accounts = accounts
} else {
throw DecodingError.dataCorruptedError(forKey: .accounts, in: container, debugDescription: "accounts must either be int or string containing int")
}
}
private enum CodingKeys: String, CodingKey {
case day
case uses
case accounts
}
}

View File

@ -0,0 +1,179 @@
//
// Instance.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
public class Instance: Decodable {
public let uri: String
public let title: String
public let description: String
public let shortDescription: String?
public let email: String?
public let version: String
public let urls: [String: URL]
public let thumbnail: URL?
public let languages: [String]?
public let stats: Stats?
public let configuration: Configuration?
public let rules: [Rule]?
// pleroma doesn't currently implement these
public let contactAccount: Account?
// superseded by mastodon's configuration.statuses.max_characters, still used by older instances & pleroma
let maxTootCharacters: Int?
let pollLimits: PollsConfiguration?
public var maxStatusCharacters: Int? {
configuration?.statuses.maxCharacters ?? maxTootCharacters
}
public var pollsConfiguration: PollsConfiguration? {
configuration?.polls ?? pollLimits
}
// we need a custom decoder, because all API-compatible implementations don't return some data in the same format
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.uri = try container.decode(String.self, forKey: .uri)
self.title = try container.decode(String.self, forKey: .title)
self.description = try container.decode(String.self, forKey: .description)
self.shortDescription = try container.decodeIfPresent(String.self, forKey: .shortDescription)
self.email = try container.decodeIfPresent(String.self, forKey: .email)
self.version = try container.decode(String.self, forKey: .version)
if let urls = try? container.decodeIfPresent([String: URL].self, forKey: .urls) {
self.urls = urls
} else {
self.urls = [:]
}
self.languages = try? container.decodeIfPresent([String].self, forKey: .languages)
self.contactAccount = try? container.decodeIfPresent(Account.self, forKey: .contactAccount)
self.stats = try? container.decodeIfPresent(Stats.self, forKey: .stats)
self.thumbnail = try? container.decodeIfPresent(URL.self, forKey: .thumbnail)
self.configuration = try? container.decodeIfPresent(Configuration.self, forKey: .configuration)
self.rules = try? container.decodeIfPresent([Rule].self, forKey: .rules)
if let maxTootCharacters = try? container.decodeIfPresent(Int.self, forKey: .maxTootCharacters) {
self.maxTootCharacters = maxTootCharacters
} else if let str = try? container.decodeIfPresent(String.self, forKey: .maxTootCharacters),
let maxTootCharacters = Int(str, radix: 10) {
self.maxTootCharacters = maxTootCharacters
} else {
self.maxTootCharacters = nil
}
self.pollLimits = try? container.decodeIfPresent(PollsConfiguration.self, forKey: .pollLimits)
}
private enum CodingKeys: String, CodingKey {
case uri
case title
case description
case shortDescription = "short_description"
case email
case version
case urls
case thumbnail
case languages
case stats
case configuration
case contactAccount = "contact_account"
case rules
case maxTootCharacters = "max_toot_chars"
case pollLimits = "poll_limits"
}
}
extension Instance {
public struct Stats: Decodable {
public let domainCount: Int?
public let statusCount: Int?
public let userCount: Int?
private enum CodingKeys: String, CodingKey {
case domainCount = "domain_count"
case statusCount = "status_count"
case userCount = "user_count"
}
}
}
extension Instance {
public struct Configuration: Decodable {
public let statuses: StatusesConfiguration
public let mediaAttachments: MediaAttachmentsConfiguration
/// Use Instance.pollsConfiguration to support older instance that don't have this nested
let polls: PollsConfiguration
private enum CodingKeys: String, CodingKey {
case statuses
case mediaAttachments = "media_attachments"
case polls
}
}
}
extension Instance {
public struct StatusesConfiguration: Decodable {
public let maxCharacters: Int
public let maxMediaAttachments: Int
public let charactersReservedPerURL: Int
private enum CodingKeys: String, CodingKey {
case maxCharacters = "max_characters"
case maxMediaAttachments = "max_media_attachments"
case charactersReservedPerURL = "characters_reserved_per_url"
}
}
}
extension Instance {
public struct MediaAttachmentsConfiguration: Decodable {
public let supportedMIMETypes: [String]
public let imageSizeLimit: Int
public let imageMatrixLimit: Int
public let videoSizeLimit: Int
public let videoFrameRateLimit: Int
public let videoMatrixLimit: Int
private enum CodingKeys: String, CodingKey {
case supportedMIMETypes = "supported_mime_types"
case imageSizeLimit = "image_size_limit"
case imageMatrixLimit = "image_matrix_limit"
case videoSizeLimit = "video_size_limit"
case videoFrameRateLimit = "video_frame_rate_limit"
case videoMatrixLimit = "video_matrix_limit"
}
}
}
extension Instance {
public struct PollsConfiguration: Decodable {
public let maxOptions: Int
public let maxCharactersPerOption: Int
public let minExpiration: TimeInterval
public let maxExpiration: TimeInterval
private enum CodingKeys: String, CodingKey {
case maxOptions = "max_options"
case maxCharactersPerOption = "max_characters_per_option"
case minExpiration = "min_expiration"
case maxExpiration = "max_expiration"
}
}
}
extension Instance {
public struct Rule: Decodable, Identifiable {
public let id: String
public let text: String
}
}

View File

@ -17,11 +17,12 @@ public class List: Decodable, Equatable, Hashable {
}
public static func ==(lhs: List, rhs: List) -> Bool {
return lhs.id == rhs.id
return lhs.id == rhs.id && lhs.title == rhs.title
}
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(title)
}
public static func getAccounts(_ list: List, range: RequestRange = .default) -> Request<[Account]> {

View File

@ -0,0 +1,33 @@
//
// Mention.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
import WebURL
public struct Mention: Codable {
public let url: WebURL
public let username: String
public let acct: String
/// The instance-local ID of the user being mentioned.
public let id: String
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.username = try container.decode(String.self, forKey: .username)
self.acct = try container.decode(String.self, forKey: .acct)
self.id = try container.decode(String.self, forKey: .id)
self.url = try container.decode(WebURL.self, forKey: .url)
}
private enum CodingKeys: String, CodingKey {
case url
case username
case acct
case id
}
}

View File

@ -0,0 +1,19 @@
//
// NodeInfo.swift
// Pachyderm
//
// Created by Shadowfacts on 1/22/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import Foundation
public struct NodeInfo: Decodable {
public let version: String
public let software: Software
public struct Software: Decodable {
public let name: String
public let version: String
}
}

View File

@ -21,16 +21,16 @@ public class Notification: Decodable {
self.id = try container.decode(String.self, forKey: .id)
if let kind = try? container.decode(Kind.self, forKey: .kind) {
self.kind = kind
} else if let s = try? container.decode(String.self, forKey: .kind),
s == "status" {
// represent notifications of other people posting as regular mentions for now
self.kind = .mention
} else {
self.kind = .unknown
}
self.createdAt = try container.decode(Date.self, forKey: .createdAt)
self.account = try container.decode(Account.self, forKey: .account)
if container.contains(.status) {
self.status = try container.decode(Status.self, forKey: .status)
} else {
self.status = nil
}
self.status = try container.decodeIfPresent(Status.self, forKey: .status)
}
public static func dismiss(id notificationID: String) -> Request<Empty> {
@ -56,6 +56,7 @@ extension Notification {
case follow
case followRequest = "follow_request"
case poll
case update
case unknown
}
}

View File

@ -22,7 +22,7 @@ public protocol AccountProtocol {
var statusesCount: Int { get }
var note: String { get }
var url: URL { get }
var avatar: URL { get }
var avatar: URL? { get }
var header: URL? { get }
var moved: Bool? { get }
var bot: Bool? { get }

View File

@ -20,8 +20,9 @@ public protocol StatusProtocol {
var createdAt: Date { get }
var reblogsCount: Int { get }
var favouritesCount: Int { get }
var reblogged: Bool { get }
var favourited: Bool { get }
// pachyderm impl wants Bool, StatusMO wants optional. not sure how to resolve it, but we don't need this currently
// var reblogged: Bool { get }
// var favourited: Bool { get }
var sensitive: Bool { get }
var spoilerText: String { get }
var visibility: Pachyderm.Status.Visibility { get }

View File

@ -7,11 +7,12 @@
//
import Foundation
import WebURL
public final class Status: /*StatusProtocol,*/ Decodable {
public final class Status: StatusProtocol, Decodable {
public let id: String
public let uri: String
public let url: URL?
public let url: WebURL?
public let account: Account
public let inReplyToID: String?
public let inReplyToAccountID: String?
@ -38,6 +39,8 @@ public final class Status: /*StatusProtocol,*/ Decodable {
public let bookmarked: Bool?
public let card: Card?
public let poll: Poll?
// Hometown, Glitch only
public let localOnly: Bool?
public var applicationName: String? { application?.name }
@ -61,12 +64,17 @@ public final class Status: /*StatusProtocol,*/ Decodable {
return request
}
public static func delete(_ status: Status) -> Request<Empty> {
return Request<Empty>(method: .delete, path: "/api/v1/statuses/\(status.id)")
public static func delete(_ statusID: String) -> Request<Empty> {
return Request<Empty>(method: .delete, path: "/api/v1/statuses/\(statusID)")
}
public static func reblog(_ statusID: String) -> Request<Status> {
return Request<Status>(method: .post, path: "/api/v1/statuses/\(statusID)/reblog")
public static func reblog(_ statusID: String, visibility: Visibility? = nil) -> Request<Status> {
var params: [Parameter] = []
if let visibility {
assert([.public, .unlisted, .private].contains(visibility))
params.append("visibility" => visibility.rawValue)
}
return Request<Status>(method: .post, path: "/api/v1/statuses/\(statusID)/reblog", queryParameters: params)
}
public static func unreblog(_ statusID: String) -> Request<Status> {
@ -134,6 +142,7 @@ public final class Status: /*StatusProtocol,*/ Decodable {
case bookmarked
case card
case poll
case localOnly = "local_only"
}
}

View File

@ -0,0 +1,25 @@
//
// Suggestion.swift
// Pachyderm
//
// Created by Shadowfacts on 1/22/23.
//
import Foundation
public struct Suggestion: Decodable {
public let source: Source
public let account: Account
public static func remove(accountID: String) -> Request<Empty> {
return Request(method: .delete, path: "/api/v1/suggestions/\(accountID)")
}
}
extension Suggestion {
public enum Source: String, Decodable {
case staff
case pastInteractions = "past_interactions"
case global
}
}

View File

@ -8,7 +8,7 @@
import Foundation
public enum Timeline {
public enum Timeline: Equatable, Hashable {
case home
case `public`(local: Bool)
case tag(hashtag: String)
@ -17,7 +17,7 @@ public enum Timeline {
}
extension Timeline {
var endpoint: String {
var endpoint: Endpoint {
switch self {
case .home:
return "/api/v1/timelines/home"

View File

@ -0,0 +1,18 @@
//
// WellKnown.swift
// Pachyderm
//
// Created by Shadowfacts on 1/22/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import Foundation
struct WellKnown: Decodable {
let links: [Link]
struct Link: Decodable {
let href: String
let rel: String
}
}

View File

@ -0,0 +1,62 @@
//
// Endpoint.swift
// Pachyderm
//
// Created by Shadowfacts on 3/29/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import Foundation
public struct Endpoint: ExpressibleByStringInterpolation, CustomStringConvertible {
let components: [Component]
public init(stringLiteral value: StringLiteralType) {
self.components = [.literal(value)]
}
public init(stringInterpolation: StringInterpolation) {
self.components = stringInterpolation.components
}
var path: String {
components.map {
switch $0 {
case .literal(let s), .interpolated(let s):
return s
}
}.joined(separator: "")
}
public var description: String {
components.map {
switch $0 {
case .literal(let s):
return s
case .interpolated(_):
return "<redacted>"
}
}.joined(separator: "")
}
public struct StringInterpolation: StringInterpolationProtocol {
var components = [Component]()
public init(literalCapacity: Int, interpolationCount: Int) {
}
public mutating func appendLiteral(_ literal: StringLiteralType) {
components.append(.literal(literal))
}
public mutating func appendInterpolation(_ value: String) {
components.append(.interpolated(value))
}
}
enum Component {
case literal(String)
case interpolated(String)
}
}

View File

@ -8,12 +8,12 @@
import Foundation
enum Method {
public enum Method {
case get, post, put, patch, delete
}
extension Method {
var name: String {
public var name: String {
switch self {
case .get:
return "GET"

View File

@ -42,6 +42,10 @@ extension String {
}
}
static func =>(name: String, value: TimeInterval?) -> Parameter {
return name => (value == nil ? nil : Int(value!))
}
static func =>(name: String, focus: (Float, Float)?) -> Parameter {
guard let focus = focus else { return Parameter(name: name, value: nil) }
return Parameter(name: name, value: "\(focus.0),\(focus.1)")

View File

@ -10,13 +10,13 @@ import Foundation
public struct Request<ResultType: Decodable> {
let method: Method
let path: String
let endpoint: Endpoint
let body: Body
var queryParameters: [Parameter]
init(method: Method, path: String, body: Body = EmptyBody(), queryParameters: [Parameter] = []) {
init(method: Method, path: Endpoint, body: Body = EmptyBody(), queryParameters: [Parameter] = []) {
self.method = method
self.path = path
self.endpoint = path
self.body = body
self.queryParameters = queryParameters
}

View File

@ -11,7 +11,9 @@ import Foundation
public enum RequestRange {
case `default`
case count(Int)
/// Chronologically immediately before the given ID
case before(id: String, count: Int?)
/// Chronologically immediately after the given ID
case after(id: String, count: Int?)
}

View File

@ -13,12 +13,12 @@ public struct CharacterCounter {
static let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
static let mention = try! NSRegularExpression(pattern: "(@[a-z0-9_]+)(?:@[a-z0-9\\-\\.]+[a-z0-9]+)?", options: .caseInsensitive)
public static func count(text: String) -> Int {
public static func count(text: String, for instance: Instance? = nil) -> Int {
let mentionsRemoved = removeMentions(in: text)
var count = mentionsRemoved.count
for match in linkDetector.matches(in: mentionsRemoved, options: [], range: NSRange(location: 0, length: mentionsRemoved.utf16.count)) {
count -= match.range.length
count += 23 // Mastodon link length
count += instance?.configuration?.statuses.charactersReservedPerURL ?? 23 // default Mastodon link length
}
return count
}

View File

@ -1,5 +1,5 @@
//
// StatusState.swift
// CollapseState.swift
// Pachyderm
//
// Created by Shadowfacts on 11/24/19.
@ -8,7 +8,7 @@
import Foundation
public class StatusState: Equatable, Hashable {
public class CollapseState: Equatable {
public var collapsible: Bool?
public var collapsed: Bool?
@ -21,8 +21,8 @@ public class StatusState: Equatable, Hashable {
self.collapsed = collapsed
}
public func copy() -> StatusState {
return StatusState(collapsible: self.collapsible, collapsed: self.collapsed)
public func copy() -> CollapseState {
return CollapseState(collapsible: self.collapsible, collapsed: self.collapsed)
}
public func hash(into hasher: inout Hasher) {
@ -30,11 +30,11 @@ public class StatusState: Equatable, Hashable {
hasher.combine(collapsed)
}
public static var unknown: StatusState {
StatusState(collapsible: nil, collapsed: nil)
public static var unknown: CollapseState {
CollapseState(collapsible: nil, collapsed: nil)
}
public static func == (lhs: StatusState, rhs: StatusState) -> Bool {
public static func == (lhs: CollapseState, rhs: CollapseState) -> Bool {
lhs.collapsible == rhs.collapsible && lhs.collapsed == rhs.collapsed
}
}

View File

@ -12,7 +12,7 @@ public class InstanceSelector {
private static let decoder = JSONDecoder()
public static func getInstances(category: String?, completion: @escaping Client.Callback<[Instance]>) {
public static func getInstances(category: String?, completion: @escaping (Result<[Instance], Client.ErrorType>) -> Void) {
let url: URL
if let category = category {
url = URL(string: "https://api.joinmastodon.org/servers?category=\(category)")!
@ -34,11 +34,14 @@ public class InstanceSelector {
completion(.failure(.unexpectedStatus(response.statusCode)))
return
}
guard let result = try? decoder.decode([Instance].self, from: data) else {
completion(.failure(Client.Error.invalidModel))
let result: [Instance]
do {
result = try decoder.decode([Instance].self, from: data)
} catch {
completion(.failure(.invalidModel(error)))
return
}
completion(.success(result, nil))
completion(.success(result))
}
task.resume()
}

View File

@ -0,0 +1,117 @@
//
// NotificationGroup.swift
// Pachyderm
//
// Created by Shadowfacts on 9/5/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import Foundation
public struct NotificationGroup: Identifiable, Hashable {
public private(set) var notifications: [Notification]
public let id: String
public let kind: Notification.Kind
public let statusState: CollapseState?
init?(notifications: [Notification]) {
guard !notifications.isEmpty else { return nil }
self.notifications = notifications
self.id = notifications.first!.id
self.kind = notifications.first!.kind
if kind == .mention {
self.statusState = .unknown
} else {
self.statusState = nil
}
}
public static func ==(lhs: NotificationGroup, rhs: NotificationGroup) -> Bool {
guard lhs.notifications.count == rhs.notifications.count else {
return false
}
for (a, b) in zip(lhs.notifications, rhs.notifications) where a.id != b.id {
return false
}
return true
}
public func hash(into hasher: inout Hasher) {
for notification in notifications {
hasher.combine(notification.id)
}
}
private mutating func append(_ notification: Notification) {
notifications.append(notification)
}
private mutating func append(group: NotificationGroup) {
notifications.append(contentsOf: group.notifications)
}
public static func createGroups(notifications: [Notification], only allowedTypes: [Notification.Kind]) -> [NotificationGroup] {
var groups = [NotificationGroup]()
for notification in notifications {
if allowedTypes.contains(notification.kind) {
if let lastGroup = groups.last, canMerge(notification: notification, into: lastGroup) {
groups[groups.count - 1].append(notification)
continue
} else if groups.count >= 2 {
let secondToLastGroup = groups[groups.count - 2]
if allowedTypes.contains(groups[groups.count - 1].kind), canMerge(notification: notification, into: secondToLastGroup) {
groups[groups.count - 2].append(notification)
continue
}
}
}
groups.append(NotificationGroup(notifications: [notification])!)
}
return groups
}
private static func canMerge(notification: Notification, into group: NotificationGroup) -> Bool {
return notification.kind == group.kind && notification.status?.id == group.notifications.first!.status?.id
}
public static func mergeGroups(first: [NotificationGroup], second: [NotificationGroup], only allowedTypes: [Notification.Kind]) -> [NotificationGroup] {
guard !first.isEmpty else {
return second
}
guard !second.isEmpty else {
return first
}
var merged = first
var second = second
merged.reserveCapacity(second.count)
while let firstGroupFromSecond = second.first,
allowedTypes.contains(firstGroupFromSecond.kind) {
second.removeFirst()
guard let lastGroup = merged.last,
allowedTypes.contains(lastGroup.kind) else {
merged.append(firstGroupFromSecond)
break
}
if canMerge(notification: firstGroupFromSecond.notifications.first!, into: lastGroup) {
merged[merged.count - 1].append(group: firstGroupFromSecond)
} else if merged.count >= 2 {
let secondToLastGroup = merged[merged.count - 2]
if allowedTypes.contains(secondToLastGroup.kind), canMerge(notification: firstGroupFromSecond.notifications.first!, into: secondToLastGroup) {
merged[merged.count - 2].append(group: firstGroupFromSecond)
} else {
merged.append(firstGroupFromSecond)
}
} else {
merged.append(firstGroupFromSecond)
}
}
merged.append(contentsOf: second)
return merged
}
}

View File

@ -0,0 +1,268 @@
//
// NotificationGroupTests.swift
//
//
// Created by Shadowfacts on 4/26/22.
//
import XCTest
@testable import Pachyderm
class NotificationGroupTests: XCTestCase {
let decoder: JSONDecoder = {
let d = JSONDecoder()
d.dateDecodingStrategy = .iso8601
return d
}()
let statusA = """
{
"id": "1",
"created_at": "2019-11-23T07:28:34Z",
"account": {
"id": "2",
"username": "bar",
"acct": "bar",
"display_name": "bar",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@bar",
"uri": "https://example.com/@bar",
},
"url": "https://example.com/@bar/1",
"uri": "https://example.com/@bar/1",
"content": "",
"emojis": [],
"reblogs_count": 0,
"favourites_count": 0,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"media_attachments": [],
"mentions": [],
"tags": [],
}
}
"""
lazy var likeA1Data = """
{
"id": "1",
"type": "favourite",
"created_at": "2019-11-23T07:29:18Z",
"account": {
"id": "1",
"username": "foo",
"acct": "foo",
"display_name": "foo",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@foo",
"uri": "https://example.com/@foo",
},
"status": \(statusA)
""".data(using: .utf8)!
lazy var likeA1 = try! decoder.decode(Notification.self, from: likeA1Data)
lazy var likeA2Data = """
{
"id": "2",
"type": "favourite",
"created_at": "2019-11-23T07:30:00Z",
"account": {
"id": "2",
"username": "baz",
"acct": "baz",
"display_name": "baz",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@baz",
"uri": "https://example.com/@baz",
},
"status": \(statusA)
""".data(using: .utf8)!
lazy var likeA2 = try! decoder.decode(Notification.self, from: likeA2Data)
let statusB = """
{
"id": "2",
"created_at": "2019-11-23T07:28:34Z",
"account": {
"id": "2",
"username": "bar",
"acct": "bar",
"display_name": "bar",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@bar",
"uri": "https://example.com/@bar",
},
"url": "https://example.com/@bar/1",
"uri": "https://example.com/@bar/1",
"content": "",
"emojis": [],
"reblogs_count": 0,
"favourites_count": 0,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"media_attachments": [],
"mentions": [],
"tags": [],
}
}
"""
lazy var likeBData = """
{
"id": "3",
"type": "favourite",
"created_at": "2019-11-23T07:29:18Z",
"account": {
"id": "1",
"username": "foo",
"acct": "foo",
"display_name": "foo",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@foo",
"uri": "https://example.com/@foo",
},
"status": \(statusB)
""".data(using: .utf8)!
lazy var likeB = try! decoder.decode(Notification.self, from: likeBData)
lazy var likeB2Data = """
{
"id": "4",
"type": "favourite",
"created_at": "2019-11-23T07:29:18Z",
"account": {
"id": "2",
"username": "bar",
"acct": "bar",
"display_name": "bar",
"locked": false,
"created_at": "2019-11-02T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@bar",
"uri": "https://example.com/@bar",
},
"status": \(statusB)
""".data(using: .utf8)!
lazy var likeB2 = try! decoder.decode(Notification.self, from: likeB2Data)
lazy var mentionBData = """
{
"id": "5",
"type": "mention",
"created_at": "2019-11-23T07:29:18Z",
"account": {
"id": "1",
"username": "foo",
"acct": "foo",
"display_name": "foo",
"locked": false,
"created_at": "2019-11-01T01:01:01Z",
"followers_count": 0,
"following_count": 0,
"statuses_count": 0,
"note": "",
"url": "https://example.com/@foo",
"uri": "https://example.com/@foo",
},
"status": \(statusB)
""".data(using: .utf8)!
lazy var mentionB = try! decoder.decode(Notification.self, from: mentionBData)
func testGroupSimple() {
let groups = NotificationGroup.createGroups(notifications: [likeA1, likeA2], only: [.favourite])
XCTAssertEqual(groups, [NotificationGroup(notifications: [likeA1, likeA2])!])
}
func testGroupWithOtherGroupableInBetween() {
let groups = NotificationGroup.createGroups(notifications: [likeA1, likeB, likeA2], only: [.favourite])
XCTAssertEqual(groups, [
NotificationGroup(notifications: [likeA1, likeA2])!,
NotificationGroup(notifications: [likeB])!,
])
}
func testDontGroupWithUngroupableInBetween() {
let groups = NotificationGroup.createGroups(notifications: [likeA1, mentionB, likeA2], only: [.favourite])
XCTAssertEqual(groups, [
NotificationGroup(notifications: [likeA1])!,
NotificationGroup(notifications: [mentionB])!,
NotificationGroup(notifications: [likeA2])!,
])
}
func testMergeSimpleGroups() {
let group1 = NotificationGroup(notifications: [likeA1])!
let group2 = NotificationGroup(notifications: [likeA2])!
let merged = NotificationGroup.mergeGroups(first: [group1], second: [group2], only: [.favourite])
XCTAssertEqual(merged, [
NotificationGroup(notifications: [likeA1, likeA2])!
])
}
func testMergeGroupsWithOtherGroupableInBetween() {
let group1 = NotificationGroup(notifications: [likeA1])!
let group2 = NotificationGroup(notifications: [likeB])!
let group3 = NotificationGroup(notifications: [likeA2])!
let merged = NotificationGroup.mergeGroups(first: [group1, group2], second: [group3], only: [.favourite])
XCTAssertEqual(merged, [
NotificationGroup(notifications: [likeA1, likeA2])!,
NotificationGroup(notifications: [likeB])!,
])
let merged2 = NotificationGroup.mergeGroups(first: [group1], second: [group2, group3], only: [.favourite])
XCTAssertEqual(merged2, [
NotificationGroup(notifications: [likeA1, likeA2])!,
NotificationGroup(notifications: [likeB])!,
])
let group4 = NotificationGroup(notifications: [likeB2])!
let group5 = NotificationGroup(notifications: [mentionB])!
let merged3 = NotificationGroup.mergeGroups(first: [group1, group5, group2], second: [group4, group3], only: [.favourite])
print(merged3.count)
XCTAssertEqual(merged3, [
group1,
group5,
NotificationGroup(notifications: [likeB, likeB2]),
group3
])
}
func testDontMergeWithUngroupableInBetween() {
let group1 = NotificationGroup(notifications: [likeA1])!
let group2 = NotificationGroup(notifications: [mentionB])!
let group3 = NotificationGroup(notifications: [likeA2])!
let merged = NotificationGroup.mergeGroups(first: [group1, group2], second: [group3], only: [.favourite])
XCTAssertEqual(merged, [
NotificationGroup(notifications: [likeA1])!,
NotificationGroup(notifications: [mentionB])!,
NotificationGroup(notifications: [likeA2])!,
])
}
}

View File

@ -0,0 +1,25 @@
//
// URLTests.swift
//
//
// Created by Shadowfacts on 5/17/22.
//
import XCTest
import WebURL
import WebURLFoundationExtras
class URLTests: XCTestCase {
func testDecodeURL() {
XCTAssertNotNil(WebURL(URL(string: "https://xn--baw-joa.social/@unituebingen")!))
XCTAssertNotNil(WebURL("https://xn--baw-joa.social/@unituebingen"))
XCTAssertNotNil(URLComponents(string: "https://xn--baw-joa.social/test/é"))
XCTAssertNotNil(WebURL("https://xn--baw-joa.social/test/é"))
if #available(iOS 16.0, *) {
XCTAssertNotNil(try? URL.ParseStrategy().parse("https://xn--baw-joa.social/test/é"))
XCTAssertNotNil(try? URL.ParseStrategy().parse("http://見.香港/热狗/🌭"))
}
}
}

9
Packages/TTTKit/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

View File

@ -0,0 +1,31 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "TTTKit",
platforms: [
.iOS(.v15),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "TTTKit",
targets: ["TTTKit"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "TTTKit",
dependencies: []),
.testTarget(
name: "TTTKitTests",
dependencies: ["TTTKit"]),
]
)

View File

@ -0,0 +1,3 @@
# TTTKit
A description of this package.

View File

@ -0,0 +1,152 @@
//
// GameModel.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
import GameKit
public class GameModel: NSObject, NSCopying, GKGameModel {
private var controller: GameController
public init(controller: GameController) {
self.controller = controller
}
// MARK: GKGameModel
public var players: [GKGameModelPlayer]? {
[Player.x, Player.o]
}
public var activePlayer: GKGameModelPlayer? {
switch controller.state {
case .playAnywhere(let mark), .playSpecific(let mark, column: _, row: _):
switch mark {
case .x:
return Player.x
case .o:
return Player.o
}
case .end(_):
return nil
}
}
public func setGameModel(_ gameModel: GKGameModel) {
let other = (gameModel as! GameModel).controller
self.controller = GameController(state: other.state, board: other.board)
}
public func gameModelUpdates(for player: GKGameModelPlayer) -> [GKGameModelUpdate]? {
guard let player = player as? Player else {
return nil
}
let mark = player.mark
switch controller.state {
case .playAnywhere:
return updatesForPlayAnywhere(mark: mark)
case .playSpecific(_, column: let col, row: let row):
return updatesForPlaySpecific(mark: mark, board: (col, row))
case .end:
return nil
}
}
public func apply(_ gameModelUpdate: GKGameModelUpdate) {
let update = gameModelUpdate as! Update
switch controller.state {
case .playAnywhere(update.mark), .playSpecific(update.mark, column: update.subBoard.column, row: update.subBoard.row):
break
default:
fatalError()
}
controller.play(on: update.subBoard, column: update.column, row: update.row)
}
public func score(for player: GKGameModelPlayer) -> Int {
guard let player = player as? Player else {
return .min
}
var score = 0
for column in 0..<3 {
for row in 0..<3 {
let subBoard = controller.board.getSubBoard(column: column, row: row)
if let win = subBoard.win {
if win.mark == player.mark {
score += 10
} else {
score -= 5
}
} else {
score += 4 * subBoard.potentialWinCount(for: player.mark)
score -= 2 * subBoard.potentialWinCount(for: player.mark.next)
}
}
}
if case .playAnywhere(let mark) = controller.state {
if mark == player.mark {
score += 5
}
}
score += 8 * controller.board.potentialWinCount(for: player.mark)
score -= 4 * controller.board.potentialWinCount(for: player.mark.next)
return score
}
public func isWin(for player: GKGameModelPlayer) -> Bool {
let mark = (player as! Player).mark
return controller.board.win?.mark == mark
}
private func updatesForPlayAnywhere(mark: Mark) -> [Update] {
var updates = [Update]()
for boardColumn in 0..<3 {
for boardRow in 0..<3 {
let subBoard = controller.board.getSubBoard(column: boardColumn, row: boardRow)
guard !subBoard.ended else { continue }
for column in 0..<3 {
for row in 0..<3 {
guard subBoard[column, row] == nil else { continue }
updates.append(Update(mark: mark, subBoard: (boardColumn, boardRow), column: column, row: row))
}
}
}
}
return updates
}
private func updatesForPlaySpecific(mark: Mark, board: (column: Int, row: Int)) -> [Update] {
let subBoard = controller.board.getSubBoard(column: board.column, row: board.row)
var updates = [Update]()
for column in 0..<3 {
for row in 0..<3 {
guard subBoard[column, row] == nil else { continue }
updates.append(Update(mark: mark, subBoard: board, column: column, row: row))
}
}
return updates
}
// MARK: NSCopying
public func copy(with zone: NSZone? = nil) -> Any {
return GameModel(controller: GameController(state: controller.state, board: controller.board))
}
}
extension Board {
func potentialWinCount(for mark: Mark) -> Int {
return Win.allPoints.filter { points in
let empty = points.filter { self[$0] == nil }.count
let matching = points.filter { self[$0] == mark }.count
return matching == 2 && empty == 1
}.count
}
}

View File

@ -0,0 +1,24 @@
//
// Player.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
import GameKit
class Player: NSObject, GKGameModelPlayer {
static let x = Player(playerId: 0)
static let o = Player(playerId: 1)
let playerId: Int
var mark: Mark {
playerId == 0 ? .x : .o
}
private init(playerId: Int) {
self.playerId = playerId
}
}

View File

@ -0,0 +1,25 @@
//
// Update.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
import GameKit
class Update: NSObject, GKGameModelUpdate {
let mark: Mark
let subBoard: (column: Int, row: Int)
let column: Int
let row: Int
init(mark: Mark, subBoard: (Int, Int), column: Int, row: Int) {
self.mark = mark
self.subBoard = subBoard
self.column = column
self.row = row
}
var value: Int = 0
}

View File

@ -0,0 +1,120 @@
//
// GameController.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public class GameController: ObservableObject {
@Published public private(set) var state: State
@Published public private(set) var board: SuperTicTacToeBoard
public init() {
self.state = .playAnywhere(.x)
self.board = SuperTicTacToeBoard()
}
init(state: State, board: SuperTicTacToeBoard) {
self.state = state
self.board = board
}
public func play(on subBoard: (column: Int, row: Int), column: Int, row: Int) {
guard board.getSubBoard(column: subBoard.column, row: subBoard.row)[column, row] == nil else {
return
}
let activePlayer: Mark
switch state {
case .playAnywhere(let mark):
activePlayer = mark
case .playSpecific(let mark, column: subBoard.column, row: subBoard.row):
activePlayer = mark
default:
return
}
board.play(mark: activePlayer, subBoard: subBoard, column: column, row: row)
if let win = board.win {
state = .end(.won(win))
} else if board.tied {
state = .end(.tie)
} else {
let nextSubBoard = board.getSubBoard(column: column, row: row)
if nextSubBoard.ended {
state = .playAnywhere(activePlayer.next)
} else {
state = .playSpecific(activePlayer.next, column: column, row: row)
}
}
}
private func canPlay(on subBoard: (column: Int, row: Int)) -> Bool {
switch state {
case .playAnywhere(_):
return true
case .playSpecific(_, column: subBoard.column, row: subBoard.row):
return true
default:
return false
}
}
}
public extension GameController {
enum State {
case playAnywhere(Mark)
case playSpecific(Mark, column: Int, row: Int)
case end(Result)
public var displayName: String {
switch self {
case .playAnywhere(_):
return "Play anywhere"
case .playSpecific(_, column: let col, row: let row):
switch (col, row) {
case (0, 0):
return "Play in the top left"
case (1, 0):
return "Play in the top middle"
case (2, 0):
return "Play in the top right"
case (0, 1):
return "Play in the middle left"
case (1, 1):
return "Play in the center"
case (2, 1):
return "Play in the middle right"
case (0, 2):
return "Play in the bottom left"
case (1, 2):
return "Play in the bottom middle"
case (2, 2):
return "Play in the bottom right"
default:
fatalError()
}
case .end(.tie):
return "It's a tie!"
case .end(.won(let win)):
switch win.mark {
case .x:
return "X wins!"
case .o:
return "O wins!"
}
}
}
}
}
public extension GameController {
enum Result {
case won(Win)
case tie
}
}

View File

@ -0,0 +1,53 @@
//
// Board.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public protocol Board {
subscript(_ column: Int, _ row: Int) -> Mark? { get }
}
extension Board {
subscript(_ point: (column: Int, row: Int)) -> Mark? {
get {
self[point.column, point.row]
}
}
public var full: Bool {
for column in 0..<3 {
for row in 0..<3 {
if self[column, row] == nil {
return false
}
}
}
return true
}
public var win: Win? {
for points in Win.allPoints {
if let mark = self[points[0]],
self[points[1]] == mark && self[points[2]] == mark {
return Win(mark: mark, points: points)
}
}
return nil
}
public var won: Bool {
win != nil
}
public var tied: Bool {
full && !won
}
public var ended: Bool {
won || tied
}
}

View File

@ -0,0 +1,21 @@
//
// Mark.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public enum Mark {
case x, o
public var next: Mark {
switch self {
case .x:
return .o
case .o:
return .x
}
}
}

View File

@ -0,0 +1,32 @@
//
// SuperTicTacToeBoard.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public struct SuperTicTacToeBoard: Board {
private var boards: [[TicTacToeBoard]] = [
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
]
public subscript(_ column: Int, _ row: Int) -> Mark? {
get {
getSubBoard(column: column, row: row).win?.mark
}
}
public func getSubBoard(column: Int, row: Int) -> TicTacToeBoard {
return boards[row][column]
}
public mutating func play(mark: Mark, subBoard: (column: Int, row: Int), column: Int, row: Int) {
boards[subBoard.row][subBoard.column].play(mark: mark, column: column, row: row)
}
}

View File

@ -0,0 +1,39 @@
//
// TicTacToeBoard.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public struct TicTacToeBoard: Board {
private var marks: [[Mark?]] = [
[nil, nil, nil],
[nil, nil, nil],
[nil, nil, nil],
]
init() {
}
init(marks: [[Mark?]]) {
precondition(marks.count == 3)
precondition(marks.allSatisfy { $0.count == 3 })
self.marks = marks
}
public subscript(_ column: Int, _ row: Int) -> Mark? {
get {
marks[row][column]
}
}
public func canPlay(column: Int, row: Int) -> Bool {
return self[column, row] == nil
}
public mutating func play(mark: Mark, column: Int, row: Int) {
marks[row][column] = mark
}
}

View File

@ -0,0 +1,24 @@
//
// Win.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import Foundation
public struct Win {
public let mark: Mark
public let points: [(column: Int, row: Int)]
static let allPoints: [[(Int, Int)]] = [
[(0, 0), (1, 1), (2, 2)], // top left diag
[(2, 0), (1, 1), (0, 2)], // top right diag
[(0, 0), (1, 0), (2, 0)], // top row
[(0, 1), (1, 1), (2, 1)], // middle row
[(0, 2), (1, 2), (2, 2)], // bottom row
[(0, 0), (0, 1), (0, 2)], // left col
[(1, 0), (1, 1), (1, 2)], // middle col
[(2, 0), (2, 1), (2, 2)], // right col
]
}

View File

@ -0,0 +1,88 @@
//
// BoardView.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import SwiftUI
@available(iOS 16.0, *)
struct BoardView<Cell: View>: View {
let board: any Board
@Binding var cellSize: CGFloat
let spacing: CGFloat
let cellProvider: (_ column: Int, _ row: Int) -> Cell
init(board: any Board, cellSize: Binding<CGFloat>, spacing: CGFloat, @ViewBuilder cellProvider: @escaping (Int, Int) -> Cell) {
self.board = board
self._cellSize = cellSize
self.spacing = spacing
self.cellProvider = cellProvider
}
var body: some View {
ZStack {
if let win = board.win {
winOverlay(win)
}
Grid(horizontalSpacing: 10, verticalSpacing: 10) {
GridRow {
cellProvider(0, 0)
.background(GeometryReader { proxy in
Color.clear
.preference(key: MarkSizePrefKey.self, value: proxy.size.width)
.onPreferenceChange(MarkSizePrefKey.self) { newValue in
cellSize = newValue
}
})
cellProvider(1, 0)
cellProvider(2, 0)
}
GridRow {
cellProvider(0, 1)
cellProvider(1, 1)
cellProvider(2, 1)
}
GridRow {
cellProvider(0, 2)
cellProvider(1, 2)
cellProvider(2, 2)
}
}
let sepOffset = (cellSize + spacing) / 2
Separator(axis: .vertical)
.offset(x: -sepOffset)
Separator(axis: .vertical)
.offset(x: sepOffset)
Separator(axis: .horizontal)
.offset(y: -sepOffset)
Separator(axis: .horizontal)
.offset(y: sepOffset)
}
.padding(.all, spacing / 2)
.aspectRatio(1, contentMode: .fit)
}
private func winOverlay(_ win: Win) -> some View {
let pointsWithIndices = win.points.map { ($0, $0.row * 3 + $0.column) }
let cellSize = cellSize + spacing
return ForEach(pointsWithIndices, id: \.1) { (point, _) in
Rectangle()
.foregroundColor(Color(UIColor.green))
.opacity(0.5)
.frame(width: cellSize, height: cellSize)
.offset(x: CGFloat(point.column - 1) * cellSize, y: CGFloat(point.row - 1) * cellSize)
}
}
}
private struct MarkSizePrefKey: PreferenceKey {
static var defaultValue: CGFloat = 0
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}
}

View File

@ -0,0 +1,81 @@
//
// GameView.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import SwiftUI
@available(iOS 16.0, *)
public struct GameView: View {
@ObservedObject private var controller: GameController
@State private var cellSize: CGFloat = 0
@State private var scaleAnchor: UnitPoint = .center
@State private var focusedSubBoard: (column: Int, row: Int)? = nil
public init(controller: GameController) {
self.controller = controller
}
public var body: some View {
let scale: CGFloat = focusedSubBoard == nil ? 1 : 2.5
return boardView
.scaleEffect(x: scale, y: scale, anchor: scaleAnchor)
.clipped()
}
private var boardView: some View {
BoardView(board: controller.board, cellSize: $cellSize, spacing: 10) { column, row in
ZStack {
if case .playSpecific(_, column: column, row: row) = controller.state {
Color.teal
.padding(.all, -5)
.opacity(0.4)
}
let board = controller.board.getSubBoard(column: column, row: row)
SubBoardView(board: board, cellTapped: cellTapHandler(column, row))
.environment(\.separatorColor, Color.gray.opacity(0.6))
.contentShape(Rectangle())
.onTapGesture {
switch controller.state {
case .playAnywhere(_), .playSpecific(_, column: column, row: row):
scaleAnchor = UnitPoint(x: CGFloat(column) * 0.5, y: CGFloat(row) * 0.5)
withAnimation(.easeInOut(duration: 0.3)) {
focusedSubBoard = (column, row)
}
default:
break
}
}
.opacity(board.won ? 0.8 : 1)
if let mark = board.win?.mark {
MarkView(mark: mark)
}
}
}
}
private func cellTapHandler(_ column: Int, _ row: Int) -> ((Int, Int) -> Void)? {
guard focusedSubBoard?.column == column && focusedSubBoard?.row == row else {
return nil
}
let subBoard = (column, row)
return { column, row in
controller.play(on: subBoard, column: column, row: row)
withAnimation(.easeInOut(duration: 0.3)) {
focusedSubBoard = nil
}
}
}
}
@available(iOS 16.0, *)
struct GameView_Previews: PreviewProvider {
static var previews: some View {
GameView(controller: GameController())
.padding()
}
}

View File

@ -0,0 +1,39 @@
//
// MarkView.swift
// TTTKit
//
// Created by Shadowfacts on 12/21/22.
//
import SwiftUI
@available(iOS 16.0, *)
struct MarkView: View {
let mark: Mark?
var body: some View {
maybeImage.aspectRatio(1, contentMode: .fit)
}
@ViewBuilder
private var maybeImage: some View {
if let mark {
Image(systemName: mark == .x ? "xmark" : "circle")
.resizable()
.fontWeight(mark == .x ? .regular : .semibold)
} else {
Color.clear
}
}
}
@available(iOS 16.0, *)
struct MarkView_Previews: PreviewProvider {
static var previews: some View {
HStack {
MarkView(mark: .x)
MarkView(mark: .o)
MarkView(mark: nil)
}
}
}

View File

@ -0,0 +1,39 @@
//
// SwiftUIView.swift
//
//
// Created by Shadowfacts on 12/21/22.
//
import SwiftUI
@available(iOS 16.0, *)
struct Separator: View {
let axis: Axis
@Environment(\.separatorColor) private var separatorColor
var body: some View {
rect
.foregroundColor(separatorColor)
.gridCellUnsizedAxes(axis == .vertical ? .vertical : .horizontal)
}
private var rect: some View {
if axis == .vertical {
return Rectangle().frame(width: 1)
} else {
return Rectangle().frame(height: 1)
}
}
}
private struct SeparatorColorKey: EnvironmentKey {
static var defaultValue = Color.black
}
extension EnvironmentValues {
var separatorColor: Color {
get { self[SeparatorColorKey.self] }
set { self[SeparatorColorKey.self] = newValue }
}
}

View File

@ -0,0 +1,49 @@
//
// SubBoardView.swift
//
//
// Created by Shadowfacts on 12/21/22.
//
import SwiftUI
@available(iOS 16.0, *)
struct SubBoardView: View {
let board: TicTacToeBoard
let cellTapped: ((_ column: Int, _ row: Int) -> Void)?
@State private var cellSize: CGFloat = 0
init(board: TicTacToeBoard, cellTapped: ((Int, Int) -> Void)? = nil) {
self.board = board
self.cellTapped = cellTapped
}
var body: some View {
BoardView(board: board, cellSize: $cellSize, spacing: 10) { column, row in
applyTapHandler(column, row, MarkView(mark: board[column, row])
.contentShape(Rectangle()))
}
}
@ViewBuilder
private func applyTapHandler(_ column: Int, _ row: Int, _ view: some View) -> some View {
if let cellTapped {
view.onTapGesture {
cellTapped(column, row)
}
} else {
view
}
}
}
@available(iOS 16.0, *)
struct SubBoardView_Previews: PreviewProvider {
static var previews: some View {
SubBoardView(board: TicTacToeBoard(marks: [
[ .x, .o, .x],
[nil, .x, .o],
[ .x, nil, nil],
]))
}
}

View File

@ -0,0 +1,7 @@
import XCTest
@testable import TTTKit
final class TTTKitTests: XCTestCase {
func testExample() throws {
}
}

View File

@ -4,12 +4,12 @@ Tusker is a WIP iOS app for Mastodon and Pleroma.
## Installing for Development
Xcode 11 is required, macOS Mojave or later should work (only macOS Catalina is regularly tested).
Requirements:
- Xcode 14
1. Clone the project: `git clone https://git.shadowfacts.net/shadowfacts/Tusker.git`
2. Change directory into the project: `cd Tusker`
3. Clone the submodules: `git submodule init && git submodule update`
4. Open `Tusker.xcworkspace` in Xcode.
5. Change the code signing identity to your own.
6. Change the bundle identifier to something unique.
7. Select a target in the Tusker scheme and build & run.
3. Copy the sample xcconfig: `cp Tusker.xcconfig.example Tusker.xcconfig`
4. Edit `Tusker.xcconfig` and change the development team ID and the bundle ID prefix to your own.
5. Open `Tusker.xcodeproj` in Xcode
6. Select a target in the Tusker scheme and build & run.

2
Tusker.xcconfig.example Normal file
View File

@ -0,0 +1,2 @@
DEVELOPMENT_TEAM = YOUR_TEAM_ID
BUNDLE_ID_PREFIX = com.example

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More