mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 18:08:40 +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 {
|
} 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();
|
Box box = await getMediaStorage();
|
||||||
|
|
|
||||||
|
|
@ -304,9 +304,6 @@ Future sendImage(
|
||||||
metadata.messageIds = {};
|
metadata.messageIds = {};
|
||||||
metadata.messageSendAt = DateTime.now();
|
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..
|
// at this point it is safe inform the user about the process of sending the image..
|
||||||
for (final userId in metadata.userIds) {
|
for (final userId in metadata.userIds) {
|
||||||
int? messageId = await twonlyDatabase.messagesDao.insertMessage(
|
int? messageId = await twonlyDatabase.messagesDao.insertMessage(
|
||||||
|
|
@ -334,32 +331,33 @@ Future sendImage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String stateId = prepareState.sha2Hash.toString();
|
||||||
|
|
||||||
{
|
{
|
||||||
Box storage = await getMediaStorage();
|
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||||
|
allMediaFiles[stateId] = jsonEncode(
|
||||||
String? mediaFilesJson = storage.get("mediaUploads");
|
States(metadata: metadata, prepareState: prepareState).toJson(),
|
||||||
Map<String, dynamic> allMediaFiles = {};
|
);
|
||||||
|
(await getMediaStorage()).put("mediaUploads", jsonEncode(allMediaFiles));
|
||||||
if (mediaFilesJson != null) {
|
|
||||||
allMediaFiles = jsonDecode(mediaFilesJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
allMediaFiles[stateId] = jsonEncode(states.toJson());
|
|
||||||
storage.put("mediaUploads", jsonEncode(allMediaFiles));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadMediaState(stateId, prepareState, metadata);
|
uploadMediaState(stateId, prepareState, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future retransmitMediaFiles() async {
|
Future<Map<String, dynamic>> getStoredMediaUploads() async {
|
||||||
Box storage = await getMediaStorage();
|
Box storage = await getMediaStorage();
|
||||||
String? mediaFilesJson = storage.get("mediaUploads");
|
String? mediaFilesJson = storage.get("mediaUploads");
|
||||||
|
Map<String, dynamic> allMediaFiles = {};
|
||||||
|
|
||||||
if (mediaFilesJson == null) {
|
if (mediaFilesJson != null) {
|
||||||
return;
|
allMediaFiles = jsonDecode(mediaFilesJson);
|
||||||
}
|
}
|
||||||
|
return allMediaFiles;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> allMediaFiles = jsonDecode(mediaFilesJson);
|
Future retransmitMediaFiles() async {
|
||||||
|
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||||
|
if (allMediaFiles.isEmpty) return;
|
||||||
|
|
||||||
bool allSuccess = true;
|
bool allSuccess = true;
|
||||||
|
|
||||||
|
|
@ -400,14 +398,10 @@ Future<bool> uploadMediaState(
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Box storage = await getMediaStorage();
|
Map<String, dynamic> allMediaFiles = await getStoredMediaUploads();
|
||||||
|
if (allMediaFiles.isNotEmpty) {
|
||||||
String? mediaFilesJson = storage.get("mediaUploads");
|
|
||||||
|
|
||||||
if (mediaFilesJson != null) {
|
|
||||||
Map<String, dynamic> allMediaFiles = jsonDecode(mediaFilesJson);
|
|
||||||
allMediaFiles.remove(stateId);
|
allMediaFiles.remove(stateId);
|
||||||
storage.put("mediaUploads", jsonEncode(allMediaFiles));
|
(await getMediaStorage()).put("mediaUploads", jsonEncode(allMediaFiles));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue