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() {
if (typeof audioData === "object") {
if (audioData) {
audioType = ( audioData['@type'] === "voiceNote" ) ? "voice" : "audio";
audioFileId = audioData[audioType].id;
if (typeof audioData.album_cover_thumbnail !== "undefined") {

View file

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

View file

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

View file

@ -29,15 +29,12 @@ Row {
width: parent.width
property string myUserId;
property variant inReplyToMessage: "";
property variant inReplyToMessage;
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");
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() {
if (typeof stickerData === "object") {
if (stickerData) {
if (stickerData.is_animated) {
// Use thumbnail until we can decode TGS files
usedFileId = stickerData.thumbnail.photo.id;
@ -58,17 +58,14 @@ Item {
Connections {
target: tdLibWrapper
onFileUpdated: {
if (typeof stickerData === "object") {
if (fileId === usedFileId) {
console.log("File updated, completed? " + fileInformation.local.is_downloading_completed);
if (fileInformation.local.is_downloading_completed) {
if (stickerData.is_animated) {
stickerData.thumbnail.photo = fileInformation;
} else {
stickerData.sticker = fileInformation;
}
singleImage.source = fileInformation.local.path;
if (stickerData) {
if (fileId === usedFileId && fileInformation.local.is_downloading_completed) {
if (stickerData.is_animated) {
stickerData.thumbnail.photo = fileInformation;
} else {
stickerData.sticker = fileInformation;
}
singleImage.source = fileInformation.local.path;
}
}
}

View file

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

View file

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

View file

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