Don't do stuff which is not needed ;)

This commit is contained in:
Sebastian J. Wolf 2020-08-29 16:58:48 +02:00
parent 391dd597e2
commit a527009f86
8 changed files with 32 additions and 42 deletions

View file

@ -52,7 +52,7 @@ Item {
} }
function updateAudioThumbnail() { function updateAudioThumbnail() {
if (typeof audioData === "object") { if (audioData) {
audioType = ( audioData['@type'] === "voiceNote" ) ? "voice" : "audio"; audioType = ( audioData['@type'] === "voiceNote" ) ? "voice" : "audio";
audioFileId = audioData[audioType].id; audioFileId = audioData[audioType].id;
if (typeof audioData.album_cover_thumbnail !== "undefined") { if (typeof audioData.album_cover_thumbnail !== "undefined") {

View file

@ -33,7 +33,7 @@ Item {
} }
function updateDocument() { function updateDocument() {
if (typeof documentData === "object") { if (documentData) {
if (documentData.document.local.is_downloading_completed) { if (documentData.document.local.is_downloading_completed) {
downloadDocumentButton.visible = false; downloadDocumentButton.visible = false;
openDocumentButton.visible = true; openDocumentButton.visible = true;
@ -47,8 +47,8 @@ Item {
Connections { Connections {
target: tdLibWrapper target: tdLibWrapper
onFileUpdated: { onFileUpdated: {
if (typeof documentData !== "undefined" && fileId === documentData.document.id) { if (documentData) {
if (fileInformation.local.is_downloading_completed) { if (fileId === documentData.document.id && fileInformation.local.is_downloading_completed) {
downloadBusyIndicator.running = false; downloadBusyIndicator.running = false;
documentData.document = fileInformation; documentData.document = fileInformation;
downloadDocumentButton.visible = false; downloadDocumentButton.visible = false;

View file

@ -32,7 +32,7 @@ Item {
} }
function updatePicture() { function updatePicture() {
if (typeof photoData === "object") { if (photoData) {
// Check first which size fits best... // Check first which size fits best...
for (var i = 0; i < photoData.sizes.length; i++) { for (var i = 0; i < photoData.sizes.length; i++) {
imagePreviewItem.pictureFileInformation = photoData.sizes[i].photo; imagePreviewItem.pictureFileInformation = photoData.sizes[i].photo;
@ -52,9 +52,8 @@ Item {
Connections { Connections {
target: tdLibWrapper target: tdLibWrapper
onFileUpdated: { onFileUpdated: {
if (typeof imagePreviewItem.pictureFileInformation !== "undefined" && fileId === imagePreviewItem.pictureFileInformation.id) { if (imagePreviewItem.pictureFileInformation) {
console.log("File updated, completed? " + fileInformation.local.is_downloading_completed); if (fileId === imagePreviewItem.pictureFileInformation.id && fileInformation.local.is_downloading_completed) {
if (fileInformation.local.is_downloading_completed) {
imagePreviewItem.pictureFileInformation = fileInformation; imagePreviewItem.pictureFileInformation = fileInformation;
singleImage.source = fileInformation.local.path; singleImage.source = fileInformation.local.path;
} }

View file

@ -29,15 +29,12 @@ Row {
width: parent.width width: parent.width
property string myUserId; property string myUserId;
property variant inReplyToMessage: ""; property variant inReplyToMessage;
onInReplyToMessageChanged: { onInReplyToMessageChanged: {
if (typeof inReplyToRow.inReplyToMessage === "object") { if (inReplyToMessage) {
inReplyToUserText.text = (inReplyToRow.inReplyToMessage.sender_user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_user_id)), inReplyToUserText.font.pixelSize) : qsTr("You"); inReplyToUserText.text = (inReplyToRow.inReplyToMessage.sender_user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_user_id)), inReplyToUserText.font.pixelSize) : qsTr("You");
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true), inReplyToMessageText.font.pixelSize); inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true), inReplyToMessageText.font.pixelSize);
} else {
inReplyToUserText.text = "";
inReplyToMessageText.text = "";
} }
} }

View file

@ -35,7 +35,7 @@ Item {
} }
function updateSticker() { function updateSticker() {
if (typeof stickerData === "object") { if (stickerData) {
if (stickerData.is_animated) { if (stickerData.is_animated) {
// Use thumbnail until we can decode TGS files // Use thumbnail until we can decode TGS files
usedFileId = stickerData.thumbnail.photo.id; usedFileId = stickerData.thumbnail.photo.id;
@ -58,17 +58,14 @@ Item {
Connections { Connections {
target: tdLibWrapper target: tdLibWrapper
onFileUpdated: { onFileUpdated: {
if (typeof stickerData === "object") { if (stickerData) {
if (fileId === usedFileId) { if (fileId === usedFileId && fileInformation.local.is_downloading_completed) {
console.log("File updated, completed? " + fileInformation.local.is_downloading_completed); if (stickerData.is_animated) {
if (fileInformation.local.is_downloading_completed) { stickerData.thumbnail.photo = fileInformation;
if (stickerData.is_animated) { } else {
stickerData.thumbnail.photo = fileInformation; stickerData.sticker = fileInformation;
} else {
stickerData.sticker = fileInformation;
}
singleImage.source = fileInformation.local.path;
} }
singleImage.source = fileInformation.local.path;
} }
} }
} }

View file

@ -73,7 +73,7 @@ Item {
} }
function updateVideoThumbnail() { function updateVideoThumbnail() {
if (typeof videoData === "object") { if (videoData) {
videoType = videoData['@type']; videoType = videoData['@type'];
videoFileId = videoData[videoType].id; videoFileId = videoData[videoType].id;
if (typeof videoData.thumbnail !== "undefined") { if (typeof videoData.thumbnail !== "undefined") {
@ -104,19 +104,17 @@ Item {
Connections { Connections {
target: tdLibWrapper target: tdLibWrapper
onFileUpdated: { onFileUpdated: {
if (typeof videoData === "object") { if (videoData) {
if (fileInformation.local.is_downloading_completed) { if (fileInformation.local.is_downloading_completed && fileId === previewFileId) {
if (fileId === previewFileId) { videoData.thumbnail.photo = fileInformation;
videoData.thumbnail.photo = fileInformation; placeholderImage.source = fileInformation.local.path;
placeholderImage.source = fileInformation.local.path; }
} if (fileInformation.local.is_downloading_completed && fileId === videoFileId) {
if (fileId === videoFileId) { videoDownloadBusyIndicator.running = false;
videoDownloadBusyIndicator.running = false; videoData[videoType] = fileInformation;
videoData[videoType] = fileInformation; videoUrl = fileInformation.local.path;
videoUrl = fileInformation.local.path; if (onScreen) {
if (onScreen) { videoComponentLoader.active = true;
videoComponentLoader.active = true;
}
} }
} }
} }

View file

@ -280,7 +280,7 @@ Page {
MenuItem { MenuItem {
onClicked: { onClicked: {
newMessageInReplyToRow.inReplyToMessage = display; newMessageInReplyToRow.inReplyToMessage = display;
sendMessageColumn.focus = true; newMessageTextField.focus = true;
} }
text: qsTr("Reply to Message") text: qsTr("Reply to Message")
} }
@ -475,7 +475,7 @@ Page {
InReplyToRow { InReplyToRow {
onInReplyToMessageChanged: { onInReplyToMessageChanged: {
console.log("This is a reply!"); console.log("This is a reply!");
if (typeof newMessageInReplyToRow.inReplyToMessage === "object") { if (inReplyToMessage) {
newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString() newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString()
newMessageInReplyToRow.visible = true; newMessageInReplyToRow.visible = true;
} else { } else {
@ -509,7 +509,7 @@ Page {
labelVisible: false labelVisible: false
onFocusChanged: { onFocusChanged: {
if (!focus) { if (!focus) {
newMessageInReplyToRow.inReplyToMessage = ""; newMessageInReplyToRow.inReplyToMessage = null;
} }
} }
} }

View file

@ -100,7 +100,6 @@ CoverBackground {
right: parent.right right: parent.right
rightMargin: Theme.paddingMedium rightMargin: Theme.paddingMedium
asynchronous: true
} }
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit