|
1 | 1 | import 'dart:convert'; |
2 | | -import 'dart:collection'; |
3 | 2 |
|
4 | 3 | import 'package:http/http.dart' as http; |
5 | 4 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; |
@@ -47,9 +46,6 @@ class ApiService { |
47 | 46 | /// [http.Client] instance to perform queries (is overriden for tests) |
48 | 47 | http.Client httpClient = http.Client(); |
49 | 48 |
|
50 | | - /// Cache for custom emojis per Mastodon instance |
51 | | - final Map<String, Map<String, String>> _customEmojisCache = HashMap(); |
52 | | - |
53 | 49 | /// Performs a GET request to the specified URL through the API helper |
54 | 50 | Future<http.Response> _apiGet(String url) async { |
55 | 51 | return await helper!.get(url, httpClient: httpClient); |
@@ -361,46 +357,6 @@ class ApiService { |
361 | 357 | ); |
362 | 358 | } |
363 | 359 |
|
364 | | - /// Given a Mastodon instance's base URL, requests the Mastodon API to |
365 | | - /// return custom emojis available on that server. |
366 | | - /// The returned data is a map of shortcode to URL for each custom emoji. |
367 | | - /// Note that this request is not tied to the current user or its instance, |
368 | | - /// as it's a public endpoint. Returns a list of custom emojis, if any. |
369 | | - Future<Map<String, String>> getCustomEmojis( |
370 | | - String mastodonInstanceUrl, |
371 | | - ) async { |
372 | | - final apiUrl = "$mastodonInstanceUrl/api/v1/custom_emojis"; |
373 | | - http.Response resp = await _apiGet(apiUrl); |
374 | | - |
375 | | - if (resp.statusCode == 200) { |
376 | | - List<dynamic> jsonDataRaw = jsonDecode(resp.body); |
377 | | - List<Map<String, dynamic>> jsonData = |
378 | | - jsonDataRaw.map((item) => item as Map<String, dynamic>).toList(); |
379 | | - |
380 | | - return { |
381 | | - for (var item in jsonData) |
382 | | - item['shortcode'] as String: item['url'] as String, |
383 | | - }; |
384 | | - } |
385 | | - |
386 | | - throw ApiException( |
387 | | - "Unexpected status code ${resp.statusCode} on `getCustomEmojis`", |
388 | | - ); |
389 | | - } |
390 | | - |
391 | | - /// Fetches custom emojis for a Mastodon instance, using cache if available |
392 | | - Future<Map<String, String>> getCachedCustomEmojis( |
393 | | - String mastodonInstanceUrl, |
394 | | - ) async { |
395 | | - if (_customEmojisCache.containsKey(mastodonInstanceUrl)) { |
396 | | - return _customEmojisCache[mastodonInstanceUrl]!; |
397 | | - } |
398 | | - |
399 | | - final customEmojis = await getCustomEmojis(mastodonInstanceUrl); |
400 | | - _customEmojisCache[mastodonInstanceUrl] = customEmojis; |
401 | | - return customEmojis; |
402 | | - } |
403 | | - |
404 | 360 | /// Given a [Status]'s ID, requests the Mastodon API to un-boost |
405 | 361 | /// the status. Note that this is idempotent: a non-boosted |
406 | 362 | /// status will remain non-boosted. Returns the (new) [Status] instance |
|
0 commit comments