kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add confirm dialog when adding comment to posts/comments over 30 days old
Implements Feature #58merge-requests/67/merge
rodzic
f8ac2a05c0
commit
c8159eb830
|
@ -34,6 +34,8 @@
|
|||
settings.([Feature #65](https://gitlab.com/mysocialportal/relatica/-/issues/65))
|
||||
* Ability to turn off Spoiler Alert/CWs at the application
|
||||
level. Defaults to on. ([Feature #42](https://gitlab.com/mysocialportal/relatica/-/issues/42))
|
||||
* Throws a confirm dialog box up if adding a comment to a post/comment over 30 days
|
||||
old. ([Feature #58](https://gitlab.com/mysocialportal/relatica/-/issues/58))
|
||||
|
||||
## Version 0.10.1 (beta)
|
||||
|
||||
|
|
|
@ -147,7 +147,8 @@ class NotificationControl extends StatelessWidget {
|
|||
: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Text(
|
||||
ElapsedDateUtils.epochSecondsToString(notification.timestamp),
|
||||
ElapsedDateUtils.elapsedTimeStringFromEpochSeconds(
|
||||
notification.timestamp),
|
||||
),
|
||||
),
|
||||
trailing: notification.dismissed ||
|
||||
|
|
|
@ -10,6 +10,7 @@ import '../../services/feature_version_checker.dart';
|
|||
import '../../services/fediverse_server_validator.dart';
|
||||
import '../../services/timeline_manager.dart';
|
||||
import '../../utils/active_profile_selector.dart';
|
||||
import '../../utils/dateutils.dart';
|
||||
import '../../utils/interaction_availability_util.dart';
|
||||
import '../../utils/snackbar_builder.dart';
|
||||
|
||||
|
@ -113,6 +114,23 @@ class _InteractionsBarControlState extends State<InteractionsBarControl> {
|
|||
}
|
||||
|
||||
Future<void> addComment() async {
|
||||
if (mounted) {
|
||||
final elapsed = ElapsedDateUtils.elapsedTimeFromEpochSeconds(
|
||||
widget.entry.creationTimestamp);
|
||||
|
||||
if (elapsed > const Duration(days: 30)) {
|
||||
final label = ElapsedDateUtils.elapsedTimeStringFromEpochSeconds(
|
||||
widget.entry.creationTimestamp);
|
||||
final confirm = await showYesNoDialog(
|
||||
context,
|
||||
'Entry is from $label. Are you sure you want to add a comment on it?',
|
||||
);
|
||||
if (confirm != true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
context.push('/comment/new?parent_id=${widget.entry.id}');
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ class StatusHeaderControl extends StatelessWidget {
|
|||
Row(
|
||||
children: [
|
||||
Text(
|
||||
ElapsedDateUtils.epochSecondsToString(entry.backdatedTimestamp),
|
||||
ElapsedDateUtils.elapsedTimeStringFromEpochSeconds(
|
||||
entry.backdatedTimestamp),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
IconButton(
|
||||
|
|
|
@ -85,7 +85,7 @@ class MessagesScreen extends StatelessWidget {
|
|||
style: style,
|
||||
),
|
||||
trailing: Text(
|
||||
ElapsedDateUtils.epochSecondsToString(
|
||||
ElapsedDateUtils.elapsedTimeStringFromEpochSeconds(
|
||||
thread.messages.last.createdAt),
|
||||
style: style,
|
||||
),
|
||||
|
|
|
@ -40,8 +40,12 @@ class OffsetDateTimeUtils {
|
|||
}
|
||||
|
||||
class ElapsedDateUtils {
|
||||
static String epochSecondsToString(int epochSeconds) {
|
||||
final epoch = DateTime.fromMillisecondsSinceEpoch(epochSeconds * 1000);
|
||||
static String elapsedTimeStringFromEpochSeconds(int epochSeconds) {
|
||||
return epochMilliSecondsToString(epochSeconds * 1000);
|
||||
}
|
||||
|
||||
static String epochMilliSecondsToString(int epochMilliSeconds) {
|
||||
final epoch = DateTime.fromMillisecondsSinceEpoch(epochMilliSeconds);
|
||||
final elapsed = DateTime.now().difference(epoch);
|
||||
if (elapsed.inDays > 0) {
|
||||
return '${elapsed.inDays} days ago';
|
||||
|
@ -57,6 +61,16 @@ class ElapsedDateUtils {
|
|||
|
||||
return 'seconds ago';
|
||||
}
|
||||
|
||||
static Duration elapsedTimeFromEpochSeconds(int epochSeconds) {
|
||||
return elapsedTimeFromEpochMilliseconds(epochSeconds * 1000);
|
||||
}
|
||||
|
||||
static Duration elapsedTimeFromEpochMilliseconds(int epochMilliseconds) {
|
||||
final epoch = DateTime.fromMillisecondsSinceEpoch(epochMilliseconds);
|
||||
final elapsed = DateTime.now().difference(epoch);
|
||||
return elapsed;
|
||||
}
|
||||
}
|
||||
|
||||
const _separator = '_';
|
||||
|
|
Ładowanie…
Reference in New Issue