mastodon / mastodon-ios

Official iOS app for Mastodon
https://app.joinmastodon.org/ios
GNU General Public License v3.0
2k stars 249 forks source link

Add hashtag management to mobile app for Akkoma 3.5.0 and newer instances. #794

Open dannekrose opened 1 year ago

dannekrose commented 1 year ago

Pitch

Akkoma 3.5.0 added the ability to follow hashtags and according to the dev the api endpoints are the same as Mastodon. Could the Mobile app add recognition for Akkoma 3.5.0 instances to see, follow, and manage hashtags? The endpoints are the same so I believe this shouldn’t be a large code change. It would just be a recognizing of the instance software and using the same API endpoints when connected to an Akkoma 3.5.0 instance.

Motivation

Hashtag following and management is wonderful and providing this relatively simple change of recognizing Akkoma 3.5.0 as also being able to follow and use hashtags the same as Mastodon makes this client even more versatile and universal in the tumultuous mobile app space.

ineffyble commented 1 year ago

Which mobile app is this related to, iOS or Android?

dannekrose commented 1 year ago

I'm using iOS (iphone 11 Pro). I don't know if this is the case for Android or not, but I would suspect the same.

j-f1 commented 1 year ago

Are you running the latest version of the Mastodon iOS app (1.4.8)? It seems like the new hashtag following UI is available unconditionally, so it should work even if you aren’t logging into a Mastodon-based server. Are you unable to see the UI or are you running into problems with the follow button not behaving correctly?

dannekrose commented 1 year ago

I am running the latest version 1.4.8. I can click on a hashtag and see that I’m following it and unfollow if I want, but I do not have the list of followed hashtags available on my profile screen as documented here.

https://mstdn.social/@feditips/109490860581325719

Note : my profile screen does not show the hashtag in the top row as indicated by the above post even though it is supported by Akkoma 3.5.0. It does give me the option to follow or follow hashtags, but not the ability to see the list from my profile screen.

dannekrose commented 1 year ago

FB27B835-EB22-4E33-ADA9-3E612164B2E4

This is what I see at the top. Note the missing hashtag mark.

j-f1 commented 1 year ago

OK, that makes sense! The code that controls whether or not the hashtag button is visible on the profile is

https://github.com/mastodon/mastodon-ios/blob/da3f63138008f66e6fb183f36684df002287d0fe/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/Instance.swift#L49

…which checks that the server is running v4.0.0 or newer (of any software) as reported by /api/v1/instance. I’m not sure what Akkoma returns for this endpoint but it might have to return a fake value here (unless there’s a better way to feature detect hashtag support?)

dannekrose commented 1 year ago

The changes added to allow Akkoma to follow hashtags are linked from this commit. https://akkoma.dev/AkkomaGang/akkoma/pulls/336

dannekrose commented 1 year ago

OK, that makes sense! The code that controls whether or not the hashtag button is visible on the profile is

https://github.com/mastodon/mastodon-ios/blob/da3f63138008f66e6fb183f36684df002287d0fe/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/Instance.swift#L49

…which checks that the server is running v4.0.0 or newer (of any software) as reported by /api/v1/instance. I’m not sure what Akkoma returns for this endpoint but it might have to return a fake value here (unless there’s a better way to feature detect hashtag support?)

Given that potentially other compatible software may add the feature to follow tags, perhaps a check the sets a variable for “Supports hashtag following” to be a bit more robust might be worth considering. While I know Pixelfed isn’t targeted by the mobile app, Pixelfed also has supported hashtag following for some time.

Just a thought and humble request. I know the focus is on supporting Mastodon first and foremost. I just wanted to at least share about other software and raise awareness. Thank you for looking at this at all.

j-f1 commented 1 year ago

Ok I think the best way to detect this would be to occasionally fetch the metadata for a hashtag and test whether or not the following property is present in the response. That can be used to gate the visibility of the Follow button as well as the icon on the profile tab.

dannekrose commented 1 year ago

Would checking this endpoint work as well?

https://docs.joinmastodon.org/methods/followed_tags/

j-f1 commented 1 year ago

I spent a little time testing this out. My approach sort-of works (works great for controlling the Follow button visibility, but can’t easily be used for the profile tab). Ultimately the problem is that a synchronous check is needed for whether or not the hashtag button should be shown, but network requests are async. One approach would be to eagerly fetch and save the user’s followed hashtags (which I think is reasonable?) and then stash whether the request was successful on a new property of the Instance object. That would require slightly larger code changes though so I’m gonna put this on hold for a bit… maybe someone else will pick it up?