mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +00:00
fix bug
This commit is contained in:
parent
0a0559bd0c
commit
b756682f7c
2 changed files with 20 additions and 27 deletions
|
|
@ -41,9 +41,8 @@ Future tryTransmitMessages() async {
|
|||
),
|
||||
);
|
||||
}
|
||||
failed[key] = retransmit[key];
|
||||
} else {
|
||||
// in case of error do nothing. As the message is not removed the app will try again when relaunched
|
||||
failed[key] = retransmit[key];
|
||||
}
|
||||
}
|
||||
Box box = await getMediaStorage();
|
||||
|
|
|
|||
|
|
@ -304,9 +304,6 @@ Future sendImage(
|
|||
metadata.messageIds = {};
|
||||
metadata.messageSendAt = DateTime.now();
|
||||
|
||||
String stateId = prepareState.sha2Hash.toString();
|
||||
States states = States(metadata: metadata, prepareState: prepareState);
|
||||
|
||||
// at this point it is safe inform the user about the process of sending the image..
|
||||
for (final userId in metadata.userIds) {
|
||||
int? messageId = await twonlyDatabase.messagesDao.insertMessage(
|
||||
|
|
@ -334,32 +331,33 @@ Future sendImage(
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
Box storage = await getMediaStorage();
|
||||
String stateId = prepareState.sha2Hash.toString();
|
||||
|
||||
{
|
||||
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||
allMediaFiles[stateId] = jsonEncode(
|
||||
States(metadata: metadata, prepareState: prepareState).toJson(),
|
||||
);
|
||||
(await getMediaStorage()).put("mediaUploads", jsonEncode(allMediaFiles));
|
||||
}
|
||||
|
||||
uploadMediaState(stateId, prepareState, metadata);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getStoredMediaUploads() async {
|
||||
Box storage = await getMediaStorage();
|
||||
String? mediaFilesJson = storage.get("mediaUploads");
|
||||
Map<String, dynamic> allMediaFiles = {};
|
||||
|
||||
if (mediaFilesJson != null) {
|
||||
allMediaFiles = jsonDecode(mediaFilesJson);
|
||||
}
|
||||
|
||||
allMediaFiles[stateId] = jsonEncode(states.toJson());
|
||||
storage.put("mediaUploads", jsonEncode(allMediaFiles));
|
||||
}
|
||||
|
||||
uploadMediaState(stateId, prepareState, metadata);
|
||||
return allMediaFiles;
|
||||
}
|
||||
|
||||
Future retransmitMediaFiles() async {
|
||||
Box storage = await getMediaStorage();
|
||||
String? mediaFilesJson = storage.get("mediaUploads");
|
||||
|
||||
if (mediaFilesJson == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, dynamic> allMediaFiles = jsonDecode(mediaFilesJson);
|
||||
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||
if (allMediaFiles.isEmpty) return;
|
||||
|
||||
bool allSuccess = true;
|
||||
|
||||
|
|
@ -400,14 +398,10 @@ Future<bool> uploadMediaState(
|
|||
}
|
||||
|
||||
{
|
||||
Box storage = await getMediaStorage();
|
||||
|
||||
String? mediaFilesJson = storage.get("mediaUploads");
|
||||
|
||||
if (mediaFilesJson != null) {
|
||||
Map<String, dynamic> allMediaFiles = jsonDecode(mediaFilesJson);
|
||||
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||
if (allMediaFiles.isNotEmpty) {
|
||||
allMediaFiles.remove(stateId);
|
||||
storage.put("mediaUploads", jsonEncode(allMediaFiles));
|
||||
(await getMediaStorage()).put("mediaUploads", jsonEncode(allMediaFiles));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue