Build threads.net profile links from data since not in JSON

Fixes Issue #89
This commit is contained in:
Hank Grabowski 2024-06-24 20:44:35 -04:00
parent 199262c469
commit 8b8451fbc8
2 changed files with 15 additions and 3 deletions

View file

@ -7,8 +7,12 @@
* Fixes Unlisted posts are showing as and sharing as
private ([Issue #78](https://gitlab.com/mysocialportal/relatica/-/issues/78))
* Fixes trailing CW type ([Issue #90](https://gitlab.com/mysocialportal/relatica/-/issues/90))
* Fix Threads and Bluesky link errors ([Issue #79](https://gitlab.com/mysocialportal/relatica/-/issues/90)
and [Issuen #87](https://gitlab.com/mysocialportal/relatica/-/issues/87))
* Fix Threads open in browser
errors ([Issue #87](https://gitlab.com/mysocialportal/relatica/-/issues/87))
* Fix Bluesky open in browser
errors ([Issue #79](https://gitlab.com/mysocialportal/relatica/-/issues/79))
*Fix Threads profiles don't open in browser
properly ([Issue #89](https://gitlab.com/mysocialportal/relatica/-/issues/89))
* New Features
* Shows the network of the post/comment ([Feature #82](https://gitlab.com/mysocialportal/relatica/-/issues/82))

View file

@ -7,7 +7,7 @@ extension ConnectionMastodonExtensions on Connection {
{String defaultServerName = ''}) {
final name = json['display_name'] ?? '';
final id = json['id']?.toString() ?? '';
final profileUrl = Uri.parse(json['url'] ?? '');
var profileUrl = Uri.parse(json['url'] ?? '');
const network = 'Unknown';
final avatar = Uri.tryParse(json['avatar_static'] ?? '') ?? Uri();
final String handleFromJson = json['acct'];
@ -20,11 +20,19 @@ extension ConnectionMastodonExtensions on Connection {
late final String handle;
if (handleFromJson.contains('@')) {
handle = handleFromJson;
final handleElements = handleFromJson.split('@');
if (handleElements.last == 'threads.net') {
profileUrl =
Uri.parse('https://www.threads.net/@${handleElements.first}');
}
} else {
final server = defaultServerName.isNotEmpty
? defaultServerName
: getIt<AccountsService>().currentProfile.serverName;
handle = '$handleFromJson@$server';
if (server == 'threads.net') {
profileUrl = Uri.parse('https://www.threads.net/@$handleFromJson');
}
}
return Connection(