Enable Sender Side Image Previews
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
d0fecbd545
commit
797279d6d7
|
@ -98,8 +98,10 @@ class CwtchNotifier {
|
||||||
}
|
}
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(data["ConversationID"])) == null) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(data["ConversationID"])) == null) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], int.parse(data["ConversationID"]), data["GroupID"],
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], int.parse(data["ConversationID"]), data["GroupID"],
|
||||||
blocked: false, // we created
|
blocked: false,
|
||||||
accepted: true, // we created
|
// we created
|
||||||
|
accepted: true,
|
||||||
|
// we created
|
||||||
imagePath: data["PicturePath"],
|
imagePath: data["PicturePath"],
|
||||||
nickname: data["GroupName"],
|
nickname: data["GroupName"],
|
||||||
status: status,
|
status: status,
|
||||||
|
@ -244,6 +246,11 @@ class CwtchNotifier {
|
||||||
case "UpdatedProfileAttribute":
|
case "UpdatedProfileAttribute":
|
||||||
if (data["Key"] == "public.profile.name") {
|
if (data["Key"] == "public.profile.name") {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"];
|
profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"];
|
||||||
|
} else if (data["Key"].toString().endsWith(".path")) {
|
||||||
|
// local.conversation.filekey.path
|
||||||
|
List<String> keyparts = data["Key"].toString().split(".");
|
||||||
|
String filekey = keyparts[2] + "." + keyparts[3];
|
||||||
|
profileCN.getProfile(data["ProfileOnion"])?.downloadSetPathDangerous(filekey, data["Data"]);
|
||||||
} else {
|
} else {
|
||||||
EnvironmentConfig.debugLog("unhandled set attribute event: ${data['Key']}");
|
EnvironmentConfig.debugLog("unhandled set attribute event: ${data['Key']}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,18 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void downloadSetPathDangerous(String fileKey, String path) {
|
||||||
|
this._downloads[fileKey] = FileDownloadProgress(1, DateTime.now());
|
||||||
|
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||||
|
this._downloads[fileKey]!.chunksDownloaded = 1;
|
||||||
|
this._downloads[fileKey]!.gotManifest = true;
|
||||||
|
this._downloads[fileKey]!.complete = true;
|
||||||
|
this._downloads[fileKey]!.downloadedTo = path;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
String? downloadFinalPath(String fileKey) {
|
String? downloadFinalPath(String fileKey) {
|
||||||
|
var path = this._downloads[fileKey];
|
||||||
return this._downloads.containsKey(fileKey) ? this._downloads[fileKey]!.downloadedTo : null;
|
return this._downloads.containsKey(fileKey) ? this._downloads[fileKey]!.downloadedTo : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,16 +52,28 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var borderRadiousEh = 15.0;
|
var borderRadiousEh = 15.0;
|
||||||
var showFileSharing = Provider.of<Settings>(context, listen: false).isExperimentEnabled(FileSharingExperiment);
|
var showFileSharing = Provider.of<Settings>(context, listen: false).isExperimentEnabled(FileSharingExperiment);
|
||||||
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of<MessageMetadata>(context).timestamp);
|
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of<MessageMetadata>(context).timestamp);
|
||||||
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
var metadata = Provider.of<MessageMetadata>(context);
|
||||||
|
var downloadComplete = metadata.attributes["filepath"] != null || Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||||
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
||||||
|
|
||||||
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
||||||
if (downloadComplete) {
|
|
||||||
var lpath = path!.toLowerCase();
|
// If we haven't stored the filepath in message attributes then save it
|
||||||
|
if (downloadComplete && path == null && metadata.attributes["filepath"] != null) {
|
||||||
|
path = metadata.attributes["filepath"];
|
||||||
|
} else if (downloadComplete && path != null && metadata.attributes["filepath"] == null) {
|
||||||
|
if (metadata.attributes["filepath"] == null) {
|
||||||
|
Provider.of<FlwtchState>(context).cwtch.SetMessageAttribute(metadata.profileOnion, metadata.conversationIdentifier, 0, metadata.messageID, "filepath", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileKey = widget.fileKey();
|
||||||
|
if (downloadComplete && path != null) {
|
||||||
|
var lpath = path.toLowerCase();
|
||||||
if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) {
|
if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) {
|
||||||
if (myFile == null) {
|
if (myFile == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
myFile = new File(path);
|
myFile = new File(path!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +93,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
} else {
|
} else {
|
||||||
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
|
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
senderIsContact = true;
|
||||||
}
|
}
|
||||||
return LayoutBuilder(builder: (bcontext, constraints) {
|
return LayoutBuilder(builder: (bcontext, constraints) {
|
||||||
var wdgSender = Visibility(
|
var wdgSender = Visibility(
|
||||||
|
@ -98,13 +112,9 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
|
|
||||||
if (!showFileSharing) {
|
if (!showFileSharing) {
|
||||||
wdgDecorations = Text('\u202F');
|
wdgDecorations = Text('\u202F');
|
||||||
} else if (fromMe) {
|
} else if (downloadComplete && path != null) {
|
||||||
wdgDecorations = Visibility(
|
|
||||||
visible: widget.interactive,
|
|
||||||
child: MessageBubbleDecoration(ackd: Provider.of<MessageMetadata>(context).ackd, errored: Provider.of<MessageMetadata>(context).error, fromMe: fromMe, prettyDate: prettyDate));
|
|
||||||
} else if (downloadComplete) {
|
|
||||||
// in this case, whatever marked download.complete would have also set the path
|
// in this case, whatever marked download.complete would have also set the path
|
||||||
if (Provider.of<Settings>(context).shouldPreview(path!)) {
|
if (Provider.of<Settings>(context).shouldPreview(path)) {
|
||||||
isPreview = true;
|
isPreview = true;
|
||||||
wdgDecorations = Center(
|
wdgDecorations = Center(
|
||||||
child: MouseRegion(
|
child: MouseRegion(
|
||||||
|
|
Loading…
Reference in New Issue