mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
add publish throttle
Closes #2152 Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -37,6 +37,8 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
|
||||
late final RxBool readOnly = false.obs;
|
||||
late final RxBool enablePublish = false.obs;
|
||||
|
||||
bool isPublishing = false;
|
||||
|
||||
bool hasPub = false;
|
||||
void initPubState();
|
||||
|
||||
@@ -208,10 +210,16 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
|
||||
|
||||
void onSubmitted(String value) {
|
||||
if (enablePublish.value) {
|
||||
onPublish();
|
||||
onPublishThrottle();
|
||||
}
|
||||
}
|
||||
|
||||
void onPublishThrottle() {
|
||||
if (isPublishing) return;
|
||||
isPublishing = true;
|
||||
onPublish().whenComplete(() => isPublishing = false);
|
||||
}
|
||||
|
||||
Future<void> onPublish();
|
||||
|
||||
Future<void> onCustomPublish({List? pictures});
|
||||
|
||||
@@ -550,6 +550,6 @@ abstract class CommonRichTextPubPageState<T extends CommonRichTextPubPage>
|
||||
return;
|
||||
}
|
||||
}
|
||||
onCustomPublish(pictures: pictures);
|
||||
return onCustomPublish(pictures: pictures);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ class _CreateDynPanelState extends CommonRichTextPubPageState<CreateDynPanel> {
|
||||
alignment: Alignment.centerRight,
|
||||
child: Obx(
|
||||
() => FilledButton.tonal(
|
||||
onPressed: enablePublish.value ? onPublish : null,
|
||||
onPressed: enablePublish.value ? onPublishThrottle : null,
|
||||
style: FilledButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -267,7 +267,7 @@ class _RepostPanelState extends CommonRichTextPubPageState<RepostPanel> {
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
onPressed: onPublish,
|
||||
onPressed: onPublishThrottle,
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
@@ -320,7 +320,7 @@ class _RepostPanelState extends CommonRichTextPubPageState<RepostPanel> {
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: FilledButton.tonal(
|
||||
onPressed: onPublish,
|
||||
onPressed: onPublishThrottle,
|
||||
style: FilledButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -135,7 +135,7 @@ class _ReplyPageState extends CommonRichTextPubPageState<LiveSendDmPanel> {
|
||||
emojiBtn,
|
||||
Obx(
|
||||
() => FilledButton.tonal(
|
||||
onPressed: enablePublish.value ? onPublish : null,
|
||||
onPressed: enablePublish.value ? onPublishThrottle : null,
|
||||
style: FilledButton.styleFrom(
|
||||
visualDensity: .compact,
|
||||
padding: const .symmetric(horizontal: 20, vertical: 10),
|
||||
|
||||
@@ -210,7 +210,7 @@ class _ReplyPageState extends CommonRichTextPubPageState<ReplyPage> {
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() => FilledButton.tonal(
|
||||
onPressed: enablePublish.value ? onPublish : null,
|
||||
onPressed: enablePublish.value ? onPublishThrottle : null,
|
||||
style: FilledButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -419,7 +419,7 @@ class _SendDanmakuPanelState extends CommonTextPubPageState<SendDanmakuPanel> {
|
||||
iconColor: enablePublish.value
|
||||
? themeData.colorScheme.primary
|
||||
: themeData.colorScheme.outline,
|
||||
onPressed: enablePublish.value ? onPublish : null,
|
||||
onPressed: enablePublish.value ? onPublishThrottle : null,
|
||||
icon: const Icon(Icons.send),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user