👽 Support use realm alias instead of id
This commit is contained in:
parent
49f73f5f04
commit
b63db7fe76
@ -167,7 +167,7 @@ class AttachmentProvider extends GetConnect {
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearCache({int? id}) {
|
void clearCache({String? id}) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
_cachedResponses.remove(id);
|
_cachedResponses.remove(id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,11 +9,11 @@ class PostProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> listRecommendations(int page,
|
Future<Response> listRecommendations(int page,
|
||||||
{int? realm, String? channel}) async {
|
{String? realm, String? channel}) async {
|
||||||
final queries = [
|
final queries = [
|
||||||
'take=${10}',
|
'take=${10}',
|
||||||
'offset=$page',
|
'offset=$page',
|
||||||
if (realm != null) 'realmId=$realm',
|
if (realm != null) 'realm=$realm',
|
||||||
];
|
];
|
||||||
final resp = await get(
|
final resp = await get(
|
||||||
channel == null
|
channel == null
|
||||||
@ -45,14 +45,14 @@ class PostProvider extends GetConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> listPost(int page,
|
Future<Response> listPost(int page,
|
||||||
{int? realm, String? author, tag, category}) async {
|
{String? realm, String? author, tag, category}) async {
|
||||||
final queries = [
|
final queries = [
|
||||||
'take=${10}',
|
'take=${10}',
|
||||||
'offset=$page',
|
'offset=$page',
|
||||||
if (tag != null) 'tag=$tag',
|
if (tag != null) 'tag=$tag',
|
||||||
if (category != null) 'category=$category',
|
if (category != null) 'category=$category',
|
||||||
if (author != null) 'author=$author',
|
if (author != null) 'author=$author',
|
||||||
if (realm != null) 'realmId=$realm',
|
if (realm != null) 'realm=$realm',
|
||||||
];
|
];
|
||||||
final resp = await get('/posts?${queries.join('&')}');
|
final resp = await get('/posts?${queries.join('&')}');
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
|
@ -171,7 +171,7 @@ class _RealmPostListWidgetState extends State<RealmPostListWidget> {
|
|||||||
|
|
||||||
Response resp;
|
Response resp;
|
||||||
try {
|
try {
|
||||||
resp = await provider.listPost(pageKey, realm: widget.realm.id);
|
resp = await provider.listPost(pageKey, realm: widget.realm.alias);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_pagingController.error = e;
|
_pagingController.error = e;
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +38,7 @@ class _AttachmentAttrEditorDialogState
|
|||||||
isMature: _isMature,
|
isMature: _isMature,
|
||||||
);
|
);
|
||||||
|
|
||||||
Get.find<AttachmentProvider>().clearCache(id: widget.item.id);
|
Get.find<AttachmentProvider>().clearCache(id: widget.item.rid);
|
||||||
|
|
||||||
setState(() => _isBusy = false);
|
setState(() => _isBusy = false);
|
||||||
return Attachment.fromJson(resp.body);
|
return Attachment.fromJson(resp.body);
|
||||||
|
@ -70,7 +70,6 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
|
|||||||
'/attachments/${widget.item.rid}',
|
'/attachments/${widget.item.rid}',
|
||||||
);
|
);
|
||||||
|
|
||||||
print(url);
|
|
||||||
if (PlatformInfo.isWeb || PlatformInfo.isDesktop) {
|
if (PlatformInfo.isWeb || PlatformInfo.isDesktop) {
|
||||||
await launchUrlString(url);
|
await launchUrlString(url);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user