Inline query cleanup; Fix ChatPage scrolling issue
This commit is contained in:
parent
8607f1000b
commit
37ad9441f2
1 changed files with 35 additions and 64 deletions
|
@ -26,7 +26,12 @@ Loader {
|
||||||
id: inlineQueryLoader
|
id: inlineQueryLoader
|
||||||
active: userName.length > 1
|
active: userName.length > 1
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
anchors.fill: parent
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
|
bottom: active ? parent.bottom : parent.top
|
||||||
|
}
|
||||||
property bool hasOverlay: active && userNameIsValid && status === Loader.Ready && item.overlay && item.overlay.status === Loader.Ready
|
property bool hasOverlay: active && userNameIsValid && status === Loader.Ready && item.overlay && item.overlay.status === Loader.Ready
|
||||||
property bool hasButton: active && userNameIsValid && status === Loader.Ready && item.button && item.button.status === Loader.Ready
|
property bool hasButton: active && userNameIsValid && status === Loader.Ready && item.button && item.button.status === Loader.Ready
|
||||||
|
|
||||||
|
@ -43,6 +48,7 @@ Loader {
|
||||||
property bool queued: false
|
property bool queued: false
|
||||||
property TextArea textField
|
property TextArea textField
|
||||||
property bool isLoading
|
property bool isLoading
|
||||||
|
property var inlineBotInformation: null
|
||||||
onIsLoadingChanged: {
|
onIsLoadingChanged: {
|
||||||
requestTimeout.start();
|
requestTimeout.start();
|
||||||
}
|
}
|
||||||
|
@ -70,8 +76,6 @@ Loader {
|
||||||
requestTimer.start();
|
requestTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property var inlineBotInformation: null
|
|
||||||
|
|
||||||
|
|
||||||
function handleQuery(name, query, offset) {
|
function handleQuery(name, query, offset) {
|
||||||
if(!name) {
|
if(!name) {
|
||||||
|
@ -87,6 +91,7 @@ Loader {
|
||||||
}
|
}
|
||||||
inlineQueryLoader.currentOffset = offset || 0
|
inlineQueryLoader.currentOffset = offset || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request() {
|
||||||
if(!inlineBotInformation || !userNameIsValid) {
|
if(!inlineBotInformation || !userNameIsValid) {
|
||||||
queued = true;
|
queued = true;
|
||||||
|
@ -94,18 +99,17 @@ Loader {
|
||||||
queued = false;
|
queued = false;
|
||||||
var location = null;
|
var location = null;
|
||||||
if(inlineBotInformation.type.need_location && fernschreiberUtils.supportsGeoLocation()) {
|
if(inlineBotInformation.type.need_location && fernschreiberUtils.supportsGeoLocation()) {
|
||||||
// TODO add location
|
|
||||||
fernschreiberUtils.startGeoLocationUpdates();
|
fernschreiberUtils.startGeoLocationUpdates();
|
||||||
if(!attachmentPreviewRow.locationData.latitude) {
|
if(!attachmentPreviewRow.locationData.latitude) {
|
||||||
queued = true;
|
queued = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
tdLibWrapper.getInlineQueryResults(inlineBotInformation.id, chatId, location, query, inlineQueryLoader.currentOffset, inlineQueryLoader.responseExtra);
|
tdLibWrapper.getInlineQueryResults(inlineBotInformation.id, chatId, location, query, inlineQueryLoader.currentOffset, inlineQueryLoader.responseExtra);
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: requestTimeout
|
id: requestTimeout
|
||||||
interval: 5000
|
interval: 5000
|
||||||
|
@ -162,7 +166,6 @@ Loader {
|
||||||
property ListModel resultModel: ListModel {
|
property ListModel resultModel: ListModel {
|
||||||
dynamicRoles: true
|
dynamicRoles: true
|
||||||
}
|
}
|
||||||
|
|
||||||
property string inlineQueryPlaceholder: inlineBotInformation ? inlineBotInformation.type.inline_query_placeholder : ""
|
property string inlineQueryPlaceholder: inlineBotInformation ? inlineBotInformation.type.inline_query_placeholder : ""
|
||||||
property bool showInlineQueryPlaceholder: !!inlineQueryPlaceholder && query === ""
|
property bool showInlineQueryPlaceholder: !!inlineQueryPlaceholder && query === ""
|
||||||
property string useDelegateSize: "default"
|
property string useDelegateSize: "default"
|
||||||
|
@ -197,6 +200,7 @@ Loader {
|
||||||
}
|
}
|
||||||
useDelegateSize = sizeKey;
|
useDelegateSize = sizeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMore() {
|
function loadMore() {
|
||||||
if(nextOffset && inlineQueryLoader.userNameIsValid) {
|
if(nextOffset && inlineQueryLoader.userNameIsValid) {
|
||||||
inlineQueryLoader.currentOffset = nextOffset;
|
inlineQueryLoader.currentOffset = nextOffset;
|
||||||
|
@ -247,16 +251,6 @@ Loader {
|
||||||
active: inlineQueryComponent.switchPmText.length > 0
|
active: inlineQueryComponent.switchPmText.length > 0
|
||||||
opacity: status === Loader.Ready ? 1.0 : 0.0
|
opacity: status === Loader.Ready ? 1.0 : 0.0
|
||||||
Behavior on opacity { FadeAnimation {} }
|
Behavior on opacity { FadeAnimation {} }
|
||||||
// onActiveChanged: {
|
|
||||||
// inlineQueryLoader.buttonPadding = active ? height + Theme.paddingSmall : 0
|
|
||||||
// if(active) {
|
|
||||||
// newMessageColumn.topPadding = Theme.itemSizeExtraSmall + Theme.paddingSmall
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// newMessageColumn.topPadding = heme.paddingSmall
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
height: Theme.itemSizeSmall
|
height: Theme.itemSizeSmall
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.bottom
|
top: parent.bottom
|
||||||
|
@ -266,39 +260,34 @@ Loader {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: Theme.horizontalPageMargin
|
rightMargin: Theme.horizontalPageMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceComponent: Component {
|
sourceComponent: Component {
|
||||||
|
MouseArea {
|
||||||
MouseArea {
|
id: customButton
|
||||||
id: customButton
|
onClicked: {
|
||||||
onClicked: {
|
tdLibWrapper.createPrivateChat(inlineQueryLoader.inlineBotInformation.id, "openAndSendStartToBot:"+(inlineQueryComponent.switchPmParameter.length > 0 ? " "+inlineQueryComponent.switchPmParameter:""));
|
||||||
Debug.log("now we should switch to pm somehow ;) ooooor: ")
|
}
|
||||||
tdLibWrapper.createPrivateChat(inlineQueryLoader.inlineBotInformation.id, "openAndSendStartToBot:"+(inlineQueryComponent.switchPmParameter.length > 0 ? " "+inlineQueryComponent.switchPmParameter:""));
|
Rectangle {
|
||||||
}
|
anchors.fill: parent
|
||||||
Rectangle {
|
radius: Theme.paddingSmall
|
||||||
anchors.fill: parent
|
color: parent.pressed ? Theme.highlightBackgroundColor : Theme.rgba(Theme.DarkOnLight ? Qt.lighter(Theme.primaryColor) : Qt.darker(Theme.primaryColor), Theme.opacityFaint)
|
||||||
radius: Theme.paddingSmall
|
Label {
|
||||||
color: parent.pressed ? Theme.highlightBackgroundColor : Theme.rgba(Theme.DarkOnLight ? Qt.lighter(Theme.primaryColor) : Qt.darker(Theme.primaryColor), Theme.opacityFaint)
|
anchors {
|
||||||
Label {
|
fill: parent
|
||||||
anchors {
|
leftMargin: Theme.paddingLarge
|
||||||
fill: parent
|
rightMargin: Theme.paddingLarge
|
||||||
leftMargin: Theme.paddingLarge
|
|
||||||
rightMargin: Theme.paddingLarge
|
|
||||||
}
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
|
|
||||||
fontSizeMode: Text.Fit;
|
|
||||||
minimumPixelSize: Theme.fontSizeTiny;
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
|
|
||||||
color: customButton.pressed ? Theme.highlightColor : Theme.primaryColor
|
|
||||||
text: Emoji.emojify(inlineQueryComponent.switchPmText, font.pixelSize)// + "we are gonna make this a bit longer"
|
|
||||||
}
|
}
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
|
fontSizeMode: Text.Fit;
|
||||||
|
minimumPixelSize: Theme.fontSizeTiny;
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
|
||||||
|
color: customButton.pressed ? Theme.highlightColor : Theme.primaryColor
|
||||||
|
text: Emoji.emojify(inlineQueryComponent.switchPmText, font.pixelSize)// + "we are gonna make this a bit longer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,12 +320,6 @@ Loader {
|
||||||
color: Theme.overlayBackgroundColor
|
color: Theme.overlayBackgroundColor
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
// MouseArea {
|
|
||||||
// anchors.fill: parent
|
|
||||||
// onClicked: {
|
|
||||||
// // handleQuery();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
id: autoLoadMoreTimer
|
id: autoLoadMoreTimer
|
||||||
|
@ -347,7 +330,6 @@ Loader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SilicaGridView {
|
SilicaGridView {
|
||||||
id: resultView
|
id: resultView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -359,14 +341,9 @@ Loader {
|
||||||
model: inlineQueryComponent.resultModel
|
model: inlineQueryComponent.resultModel
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: queryResultDelegate
|
id: queryResultDelegate
|
||||||
// asynchronous: true
|
|
||||||
height: resultView.cellHeight
|
height: resultView.cellHeight
|
||||||
width: resultView.cellWidth
|
width: resultView.cellWidth
|
||||||
// TODO: if all are the same, use global?
|
|
||||||
source: "inlineQueryResults/" + (resultsOverlay.supportedResultTypes.indexOf(model["@type"]) > -1 ? (model["@type"].charAt(0).toUpperCase() + model["@type"].substring(1)) : "InlineQueryResultDefaultBase") +".qml"
|
source: "inlineQueryResults/" + (resultsOverlay.supportedResultTypes.indexOf(model["@type"]) > -1 ? (model["@type"].charAt(0).toUpperCase() + model["@type"].substring(1)) : "InlineQueryResultDefaultBase") +".qml"
|
||||||
// Component.onCompleted: {
|
|
||||||
// Debug.log("delegate", source)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
footer: Component {
|
footer: Component {
|
||||||
Item {
|
Item {
|
||||||
|
@ -379,13 +356,11 @@ Loader {
|
||||||
|
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
if(!inlineQueryLoader.isLoading && inlineQueryComponent.nextOffset && contentHeight - contentY - height < Theme.itemSizeHuge) {
|
if(!inlineQueryLoader.isLoading && inlineQueryComponent.nextOffset && contentHeight - contentY - height < Theme.itemSizeHuge) {
|
||||||
|
|
||||||
inlineQueryComponent.loadMore();
|
inlineQueryComponent.loadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScrollDecorator { flickable: resultView }
|
|
||||||
|
|
||||||
|
ScrollDecorator { flickable: resultView }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,10 +371,6 @@ Loader {
|
||||||
Loader {
|
Loader {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
active: inlineQueryComponent.showInlineQueryPlaceholder
|
active: inlineQueryComponent.showInlineQueryPlaceholder
|
||||||
// onActiveChanged: {
|
|
||||||
// Debug.log("inline: placeholder active changed", active)
|
|
||||||
// }
|
|
||||||
|
|
||||||
sourceComponent: Component {
|
sourceComponent: Component {
|
||||||
Label {
|
Label {
|
||||||
text: Emoji.emojify(inlineQueryComponent.inlineQueryPlaceholder, font.pixelSize);
|
text: Emoji.emojify(inlineQueryComponent.inlineQueryPlaceholder, font.pixelSize);
|
||||||
|
|
Loading…
Reference in a new issue