mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-06-13 10:42:12 +00:00
ensure correct ordering of media files
This commit is contained in:
parent
3d130cb760
commit
1d3b8dbd8a
4 changed files with 45 additions and 14 deletions
|
|
@ -50,7 +50,8 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
|||
mediaFiles,
|
||||
mediaFiles.mediaId.equalsExp(messages.mediaId),
|
||||
),
|
||||
])..where(
|
||||
])
|
||||
..where(
|
||||
mediaFiles.downloadState
|
||||
.equals(DownloadState.reuploadRequested.name)
|
||||
.not() &
|
||||
|
|
@ -60,7 +61,8 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
|||
messages.mediaId.isNotNull() &
|
||||
messages.senderId.isNotNull() &
|
||||
messages.type.equals(MessageType.media.name),
|
||||
);
|
||||
)
|
||||
..orderBy([OrderingTerm.asc(messages.createdAt)]);
|
||||
return query.map((row) => row.readTable(messages)).watch();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -254,17 +254,32 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> requestMicrophonePermission() async {
|
||||
final statuses = await [
|
||||
Permission.microphone,
|
||||
].request();
|
||||
if (statuses[Permission.microphone]!.isPermanentlyDenied) {
|
||||
await openAppSettings();
|
||||
} else {
|
||||
_hasAudioPermission = await Permission.microphone.isGranted;
|
||||
setState(() {
|
||||
// _hasAudioPermission
|
||||
});
|
||||
Future<void> requestMicrophonePermission({int retryCount = 0}) async {
|
||||
try {
|
||||
final statuses = await [
|
||||
Permission.microphone,
|
||||
].request();
|
||||
if (statuses[Permission.microphone]!.isPermanentlyDenied) {
|
||||
await openAppSettings();
|
||||
} else {
|
||||
_hasAudioPermission = await Permission.microphone.isGranted;
|
||||
setState(() {
|
||||
// _hasAudioPermission
|
||||
});
|
||||
}
|
||||
} on PlatformException catch (e) {
|
||||
if (e.message?.contains('already running') ?? false) {
|
||||
if (retryCount < 5) {
|
||||
Log.warn(
|
||||
'Microphone permission request conflict, retrying in 300ms... (attempt ${retryCount + 1})',
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
return requestMicrophonePermission(retryCount: retryCount + 1);
|
||||
}
|
||||
}
|
||||
Log.error('PlatformException in requestMicrophonePermission: $e');
|
||||
} catch (e) {
|
||||
Log.error('Error in requestMicrophonePermission: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,19 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
allMediaFiles.add(msg);
|
||||
}
|
||||
}
|
||||
if (allMediaFiles.length > 1) {
|
||||
if (widget.initialMessage == null &&
|
||||
currentMedia == null &&
|
||||
!_showDownloadingLoader) {
|
||||
allMediaFiles.sort(
|
||||
(a, b) => a.createdAt.compareTo(b.createdAt),
|
||||
);
|
||||
} else {
|
||||
final upcoming = allMediaFiles.sublist(1)
|
||||
..sort((a, b) => a.createdAt.compareTo(b.createdAt));
|
||||
allMediaFiles = [allMediaFiles.first, ...upcoming];
|
||||
}
|
||||
}
|
||||
if (mounted) setState(() {});
|
||||
if (firstRun) {
|
||||
firstRun = false;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class _ProfileSetupPageState extends State<ProfileSetupPage> {
|
|||
builder: (context, asyncSnapshot) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
|
|
@ -67,7 +68,7 @@ class _ProfileSetupPageState extends State<ProfileSetupPage> {
|
|||
),
|
||||
),
|
||||
child: const AvatarIcon(
|
||||
fontSize: 70,
|
||||
fontSize: 68,
|
||||
myAvatar: true,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue