forked from cwtch.im/cwtch-ui
message previews
This commit is contained in:
parent
8a8c5fc3e2
commit
6e9fb6810e
|
@ -135,6 +135,7 @@ class CwtchNotifier {
|
|||
var timestamp = DateTime.tryParse(data['TimestampReceived'])!;
|
||||
var senderHandle = data['RemotePeer'];
|
||||
var senderImage = data['Picture'];
|
||||
var isAuto = data['Auto'] == "true";
|
||||
|
||||
// We might not have received a contact created for this contact yet...
|
||||
// In that case the **next** event we receive will actually update these values...
|
||||
|
@ -145,7 +146,7 @@ class CwtchNotifier {
|
|||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.newMarker++;
|
||||
}
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(identifier, DateTime.now());
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, messageID, timestamp, senderHandle, senderImage, data["Data"]);
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, messageID, timestamp, senderHandle, senderImage, isAuto, data["Data"]);
|
||||
|
||||
// We only ever see messages from authenticated peers.
|
||||
// If the contact is marked as offline then override this - can happen when the contact is removed from the front
|
||||
|
@ -191,10 +192,11 @@ class CwtchNotifier {
|
|||
var senderImage = data['Picture'];
|
||||
var timestampSent = DateTime.tryParse(data['TimestampSent'])!;
|
||||
var currentTotal = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages;
|
||||
var isAuto = data['Auto'] == "true";
|
||||
|
||||
// Only bother to do anything if we know about the group and the provided index is greater than our current total...
|
||||
if (currentTotal != null && idx >= currentTotal) {
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, idx, timestampSent, senderHandle, senderImage, data["Data"]);
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, idx, timestampSent, senderHandle, senderImage, isAuto, data["Data"]);
|
||||
|
||||
//if not currently open
|
||||
if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != identifier) {
|
||||
|
|
|
@ -706,8 +706,8 @@ class ContactInfoState extends ChangeNotifier {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void updateMessageCache(int conversation, int messageID, DateTime timestamp, String senderHandle, String senderImage, String data) {
|
||||
this.messageCache.insert(0, MessageCache(MessageMetadata(profileOnion, conversation, messageID, timestamp, senderHandle, senderImage, "", {}, false, false), data));
|
||||
void updateMessageCache(int conversation, int messageID, DateTime timestamp, String senderHandle, String senderImage, bool isAuto, String data) {
|
||||
this.messageCache.insert(0, MessageCache(MessageMetadata(profileOnion, conversation, messageID, timestamp, senderHandle, senderImage, "", {}, false, false, isAuto), data));
|
||||
this.totalMessages += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
|||
}
|
||||
|
||||
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
||||
var metadata = MessageMetadata(profileOnion, conversationIdentifier, index, DateTime.now(), "", "", "", <String, String>{}, false, true);
|
||||
var metadata = MessageMetadata(profileOnion, conversationIdentifier, index, DateTime.now(), "", "", "", <String, String>{}, false, true, false);
|
||||
try {
|
||||
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
|
||||
// There are 2 conditions in which this error condition can be met:
|
||||
|
@ -107,7 +107,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
|||
var ackd = messageWrapper['Acknowledged'];
|
||||
var error = messageWrapper['Error'] != null;
|
||||
var signature = messageWrapper['Signature'];
|
||||
metadata = MessageMetadata(profileOnion, conversationIdentifier, messageID, timestamp, senderHandle, senderImage, signature, attributes, ackd, error);
|
||||
metadata = MessageMetadata(profileOnion, conversationIdentifier, messageID, timestamp, senderHandle, senderImage, signature, attributes, ackd, error, false);
|
||||
|
||||
return compileOverlay(metadata, messageWrapper['Message']);
|
||||
} catch (e) {
|
||||
|
@ -116,7 +116,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
|||
}
|
||||
});
|
||||
} catch (e) {
|
||||
return Future.value(MalformedMessage(MessageMetadata(profileOnion, conversationIdentifier, -1, DateTime.now(), "", "", "", <String, String>{}, false, true)));
|
||||
return Future.value(MalformedMessage(MessageMetadata(profileOnion, conversationIdentifier, -1, DateTime.now(), "", "", "", <String, String>{}, false, true, false)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ class MessageMetadata extends ChangeNotifier {
|
|||
final dynamic _attributes;
|
||||
bool _ackd;
|
||||
bool _error;
|
||||
final bool isAuto;
|
||||
|
||||
final String? signature;
|
||||
|
||||
|
@ -149,5 +150,5 @@ class MessageMetadata extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
MessageMetadata(this.profileOnion, this.conversationIdentifier, this.messageID, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._attributes, this._ackd, this._error);
|
||||
MessageMetadata(this.profileOnion, this.conversationIdentifier, this.messageID, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._attributes, this._ackd, this._error, this.isAuto);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class FileMessage extends Message {
|
|||
return MessageRow(MalformedBubble());
|
||||
}
|
||||
|
||||
return MessageRow(FileBubble(nameSuggestion, rootHash, nonce, fileSize), key: key);
|
||||
return MessageRow(FileBubble(nameSuggestion, rootHash, nonce, fileSize, isAuto: metadata.isAuto), key: key);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ class FileMessage extends Message {
|
|||
rootHash,
|
||||
nonce,
|
||||
fileSize,
|
||||
isAuto: metadata.isAuto,
|
||||
interactive: false,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -93,11 +93,7 @@ class Settings extends ChangeNotifier {
|
|||
_uiColumnModePortrait = uiColumnModeFromString(settings["UIColumnModePortrait"]);
|
||||
_uiColumnModeLandscape = uiColumnModeFromString(settings["UIColumnModeLandscape"]);
|
||||
|
||||
// image previews/profile pic storage path
|
||||
for (var i = 0; i < 30; i++) {
|
||||
print("|");
|
||||
}
|
||||
print("setting DownloadPath to " + settings["DownloadPath"]);
|
||||
// auto-download folder
|
||||
_downloadPath = settings["DownloadPath"] ?? "";
|
||||
|
||||
// Push the experimental settings to Consumers of Settings
|
||||
|
|
|
@ -23,8 +23,9 @@ class FileBubble extends StatefulWidget {
|
|||
final String nonce;
|
||||
final int fileSize;
|
||||
final bool interactive;
|
||||
final bool isAuto;
|
||||
|
||||
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize, {this.interactive = true});
|
||||
FileBubble(this.nameSuggestion, this.rootHash, this.nonce, this.fileSize, {this.isAuto = false, this.interactive = true});
|
||||
|
||||
@override
|
||||
FileBubbleState createState() => FileBubbleState();
|
||||
|
@ -52,9 +53,10 @@ class FileBubbleState extends State<FileBubble> {
|
|||
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
||||
|
||||
if (downloadInterrupted) {
|
||||
if (flagStarted && !downloadInterrupted) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.fileKey());
|
||||
}
|
||||
|
||||
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
||||
if (downloadComplete) {
|
||||
var lpath = path!.toLowerCase();
|
||||
|
@ -144,12 +146,14 @@ class FileBubbleState extends State<FileBubble> {
|
|||
ElevatedButton(onPressed: _btnResume, child: Text(AppLocalizations.of(context)!.verfiyResumeButton))
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
} else if (!widget.isAuto) {
|
||||
wdgDecorations = Center(
|
||||
widthFactor: 1,
|
||||
child: Wrap(children: [
|
||||
Padding(padding: EdgeInsets.all(5), child: ElevatedButton(child: Text(AppLocalizations.of(context)!.downloadFileButton + '\u202F'), onPressed: _btnAccept)),
|
||||
]));
|
||||
} else {
|
||||
wdgDecorations = Container();
|
||||
}
|
||||
|
||||
return Container(
|
||||
|
|
Loading…
Reference in New Issue