mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 10:58:40 +00:00
hotfix: display time changed to milliseconds...
This commit is contained in:
parent
71823c9fae
commit
f879ae00f1
7 changed files with 58 additions and 21 deletions
|
|
@ -51,9 +51,9 @@ final lockRetransStore = Mutex();
|
||||||
/// errors or network changes.
|
/// errors or network changes.
|
||||||
class ApiService {
|
class ApiService {
|
||||||
ApiService();
|
ApiService();
|
||||||
// final String apiHost = kReleaseMode ? 'api.twonly.eu' : '10.99.0.140:3030';
|
final String apiHost = kReleaseMode ? 'api.twonly.eu' : '10.99.0.140:3030';
|
||||||
final String apiHost = kReleaseMode ? 'api.twonly.eu' : 'dev.twonly.eu';
|
// final String apiHost = kReleaseMode ? 'api.twonly.eu' : 'dev.twonly.eu';
|
||||||
final String apiSecure = kReleaseMode ? 's' : 's';
|
final String apiSecure = kReleaseMode ? 's' : '';
|
||||||
|
|
||||||
bool appIsOutdated = false;
|
bool appIsOutdated = false;
|
||||||
bool isAuthenticated = false;
|
bool isAuthenticated = false;
|
||||||
|
|
|
||||||
|
|
@ -66,15 +66,23 @@ Future<void> handleMedia(
|
||||||
mediaType = MediaType.audio;
|
mediaType = MediaType.audio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int? displayLimitInMilliseconds;
|
||||||
|
if (media.hasDisplayLimitInMilliseconds()) {
|
||||||
|
if (media.displayLimitInMilliseconds.toInt() < 1000) {
|
||||||
|
displayLimitInMilliseconds =
|
||||||
|
media.displayLimitInMilliseconds.toInt() * 1000;
|
||||||
|
} else {
|
||||||
|
displayLimitInMilliseconds = media.displayLimitInMilliseconds.toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final mediaFile = await twonlyDB.mediaFilesDao.insertMedia(
|
final mediaFile = await twonlyDB.mediaFilesDao.insertMedia(
|
||||||
MediaFilesCompanion(
|
MediaFilesCompanion(
|
||||||
downloadState: const Value(DownloadState.pending),
|
downloadState: const Value(DownloadState.pending),
|
||||||
type: Value(mediaType),
|
type: Value(mediaType),
|
||||||
requiresAuthentication: Value(media.requiresAuthentication),
|
requiresAuthentication: Value(media.requiresAuthentication),
|
||||||
displayLimitInMilliseconds: Value(
|
displayLimitInMilliseconds: Value(
|
||||||
media.hasDisplayLimitInMilliseconds()
|
displayLimitInMilliseconds,
|
||||||
? media.displayLimitInMilliseconds.toInt()
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
downloadToken: Value(Uint8List.fromList(media.downloadToken)),
|
downloadToken: Value(Uint8List.fromList(media.downloadToken)),
|
||||||
encryptionKey: Value(Uint8List.fromList(media.encryptionKey)),
|
encryptionKey: Value(Uint8List.fromList(media.encryptionKey)),
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,11 @@ Future<MediaFileService?> initializeMediaUpload(
|
||||||
int? displayLimitInMilliseconds, {
|
int? displayLimitInMilliseconds, {
|
||||||
bool isDraftMedia = false,
|
bool isDraftMedia = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (displayLimitInMilliseconds != null && displayLimitInMilliseconds < 1000) {
|
||||||
|
// in case the time was set in seconds...
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
displayLimitInMilliseconds = displayLimitInMilliseconds * 1000;
|
||||||
|
}
|
||||||
final chacha20 = FlutterChacha20.poly1305Aead();
|
final chacha20 = FlutterChacha20.poly1305Aead();
|
||||||
final encryptionKey = await (await chacha20.newSecretKey()).extract();
|
final encryptionKey = await (await chacha20.newSecretKey()).extract();
|
||||||
final encryptionNonce = chacha20.newNonce();
|
final encryptionNonce = chacha20.newNonce();
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ class MediaFileService {
|
||||||
MediaFilesCompanion(
|
MediaFilesCompanion(
|
||||||
requiresAuthentication: Value(requiresAuthentication),
|
requiresAuthentication: Value(requiresAuthentication),
|
||||||
displayLimitInMilliseconds:
|
displayLimitInMilliseconds:
|
||||||
requiresAuthentication ? const Value(12) : const Value.absent(),
|
requiresAuthentication ? const Value(12000) : const Value.absent(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await updateFromDB();
|
await updateFromDB();
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
||||||
? '0'
|
? '0'
|
||||||
: media.displayLimitInMilliseconds == null
|
: media.displayLimitInMilliseconds == null
|
||||||
? '∞'
|
? '∞'
|
||||||
: media.displayLimitInMilliseconds.toString(),
|
: (media.displayLimitInMilliseconds! ~/ 1000).toString(),
|
||||||
child: ActionButton(
|
child: ActionButton(
|
||||||
(media.type == MediaType.video)
|
(media.type == MediaType.video)
|
||||||
? media.displayLimitInMilliseconds == null
|
? media.displayLimitInMilliseconds == null
|
||||||
|
|
@ -211,11 +211,13 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
||||||
}
|
}
|
||||||
int? maxShowTime;
|
int? maxShowTime;
|
||||||
if (media.displayLimitInMilliseconds == null) {
|
if (media.displayLimitInMilliseconds == null) {
|
||||||
maxShowTime = 1;
|
maxShowTime = 1000;
|
||||||
} else if (media.displayLimitInMilliseconds == 1) {
|
} else if (media.displayLimitInMilliseconds == 1000) {
|
||||||
maxShowTime = 5;
|
maxShowTime = 5000;
|
||||||
} else if (media.displayLimitInMilliseconds == 5) {
|
} else if (media.displayLimitInMilliseconds == 5000) {
|
||||||
maxShowTime = 20;
|
maxShowTime = 12000;
|
||||||
|
} else if (media.displayLimitInMilliseconds == 12000) {
|
||||||
|
maxShowTime = 20000;
|
||||||
}
|
}
|
||||||
await mediaService.setDisplayLimit(maxShowTime);
|
await mediaService.setDisplayLimit(maxShowTime);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:collection';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
|
|
@ -54,7 +55,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
|
|
||||||
bool imageSaved = false;
|
bool imageSaved = false;
|
||||||
bool imageSaving = false;
|
bool imageSaving = false;
|
||||||
bool displayTwonlyPresent = true;
|
bool displayTwonlyPresent = false;
|
||||||
final emojiKey = GlobalKey<EmojiFloatWidgetState>();
|
final emojiKey = GlobalKey<EmojiFloatWidgetState>();
|
||||||
|
|
||||||
StreamSubscription<MediaFile?>? downloadStateListener;
|
StreamSubscription<MediaFile?>? downloadStateListener;
|
||||||
|
|
@ -63,6 +64,8 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
late StreamSubscription<List<Message>> _subscription;
|
late StreamSubscription<List<Message>> _subscription;
|
||||||
TextEditingController textMessageController = TextEditingController();
|
TextEditingController textMessageController = TextEditingController();
|
||||||
|
|
||||||
|
final HashSet<String> _alreadyOpenedMediaIds = HashSet();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
@ -92,6 +95,13 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
|
|
||||||
_subscription = messages.listen((messages) async {
|
_subscription = messages.listen((messages) async {
|
||||||
for (final msg in messages) {
|
for (final msg in messages) {
|
||||||
|
if (_alreadyOpenedMediaIds.contains(msg.mediaId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (msg.mediaId == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.mediaId == currentMedia?.mediaFile.mediaId) {
|
if (msg.mediaId == currentMedia?.mediaFile.mediaId) {
|
||||||
// The update of the current Media in case of a download is done in loadCurrentMediaFile
|
// The update of the current Media in case of a download is done in loadCurrentMediaFile
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -195,13 +205,17 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
bool showTwonly,
|
bool showTwonly,
|
||||||
) async {
|
) async {
|
||||||
if (allMediaFiles.isEmpty) return;
|
if (allMediaFiles.isEmpty) return;
|
||||||
currentMessage = allMediaFiles.removeAt(0);
|
|
||||||
final currentMediaLocal =
|
final currentMediaLocal =
|
||||||
await MediaFileService.fromMediaId(currentMessage!.mediaId!);
|
await MediaFileService.fromMediaId(allMediaFiles.first.mediaId!);
|
||||||
if (currentMediaLocal == null || !mounted) return;
|
if (currentMediaLocal == null || !mounted) return;
|
||||||
|
|
||||||
if (currentMediaLocal.mediaFile.requiresAuthentication) {
|
if (currentMediaLocal.mediaFile.requiresAuthentication) {
|
||||||
if (!showTwonly) return;
|
if (!showTwonly) {
|
||||||
|
setState(() {
|
||||||
|
displayTwonlyPresent = true;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final isAuth = await authenticateUser(
|
final isAuth = await authenticateUser(
|
||||||
context.lang.mediaViewerAuthReason,
|
context.lang.mediaViewerAuthReason,
|
||||||
|
|
@ -209,10 +223,20 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
);
|
);
|
||||||
if (!isAuth) {
|
if (!isAuth) {
|
||||||
await nextMediaOrExit();
|
await nextMediaOrExit();
|
||||||
|
setState(() {
|
||||||
|
displayTwonlyPresent = false;
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_alreadyOpenedMediaIds.add(allMediaFiles.first.mediaId!);
|
||||||
|
currentMessage = allMediaFiles.removeAt(0);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
displayTwonlyPresent = false;
|
||||||
|
});
|
||||||
|
|
||||||
await notifyContactAboutOpeningMessage(
|
await notifyContactAboutOpeningMessage(
|
||||||
currentMessage!.senderId!,
|
currentMessage!.senderId!,
|
||||||
[currentMessage!.messageId],
|
[currentMessage!.messageId],
|
||||||
|
|
@ -490,9 +514,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (currentMedia != null &&
|
if (displayTwonlyPresent)
|
||||||
currentMedia!.mediaFile.requiresAuthentication &&
|
|
||||||
displayTwonlyPresent)
|
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec
|
||||||
|
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.0.65+65
|
version: 0.0.66+66
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.6.0
|
sdk: ^3.6.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue