👽 Support use realm alias instead of id

This commit is contained in:
LittleSheep 2024-08-19 00:14:09 +08:00
parent 49f73f5f04
commit b63db7fe76
5 changed files with 7 additions and 8 deletions

View File

@ -167,7 +167,7 @@ class AttachmentProvider extends GetConnect {
return resp;
}
void clearCache({int? id}) {
void clearCache({String? id}) {
if (id != null) {
_cachedResponses.remove(id);
} else {

View File

@ -9,11 +9,11 @@ class PostProvider extends GetConnect {
}
Future<Response> listRecommendations(int page,
{int? realm, String? channel}) async {
{String? realm, String? channel}) async {
final queries = [
'take=${10}',
'offset=$page',
if (realm != null) 'realmId=$realm',
if (realm != null) 'realm=$realm',
];
final resp = await get(
channel == null
@ -45,14 +45,14 @@ class PostProvider extends GetConnect {
}
Future<Response> listPost(int page,
{int? realm, String? author, tag, category}) async {
{String? realm, String? author, tag, category}) async {
final queries = [
'take=${10}',
'offset=$page',
if (tag != null) 'tag=$tag',
if (category != null) 'category=$category',
if (author != null) 'author=$author',
if (realm != null) 'realmId=$realm',
if (realm != null) 'realm=$realm',
];
final resp = await get('/posts?${queries.join('&')}');
if (resp.statusCode != 200) {

View File

@ -171,7 +171,7 @@ class _RealmPostListWidgetState extends State<RealmPostListWidget> {
Response resp;
try {
resp = await provider.listPost(pageKey, realm: widget.realm.id);
resp = await provider.listPost(pageKey, realm: widget.realm.alias);
} catch (e) {
_pagingController.error = e;
return;

View File

@ -38,7 +38,7 @@ class _AttachmentAttrEditorDialogState
isMature: _isMature,
);
Get.find<AttachmentProvider>().clearCache(id: widget.item.id);
Get.find<AttachmentProvider>().clearCache(id: widget.item.rid);
setState(() => _isBusy = false);
return Attachment.fromJson(resp.body);

View File

@ -70,7 +70,6 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
'/attachments/${widget.item.rid}',
);
print(url);
if (PlatformInfo.isWeb || PlatformInfo.isDesktop) {
await launchUrlString(url);
return;