Skip to content

Commit

Permalink
Fix issue with loading more comments. atYEnd doesn't seem to work any…
Browse files Browse the repository at this point in the history
…more in this context.
  • Loading branch information
walokra committed Oct 24, 2015
1 parent 14cd002 commit 4606e54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
12 changes: 8 additions & 4 deletions qml/pages/CommentsModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ ListModel {
property int index : 0;
property var allComments : [];
property int total : 0;
property int left : 0;
property bool loaded: false;
property bool showNsfw: settings.showNsfw;

function resetVariables() {
index = 0;
total = 0;
left = 0;
allComments = [];
loaded = false;
}
Expand All @@ -27,24 +29,26 @@ ListModel {
function(){
loadingRectComments.visible = false;
loaded = true;
total = allComments.length;
left = total;
getNextComments();
}, function(status, statusText) {
loadingRectComments.visible = false;
loaded = true;
total = 0;
left = 0;
infoBanner.showHttpError(status, statusText);
}
);
total = allComments.length;
}

function getNextComments() {
var start = index * settings.commentsSlice;
index += 1;
var end = index * settings.commentsSlice;
//start = (start >= allComments.length) ? allComments.length : start;
//end = (end > allComments.length) ? allComments.length : end;
//console.log("start=" + start + "; end=" + end + "; total=" + allComments.length);
listModel.append(allComments.slice(start, end));
left = total - end;
// console.log("getNextComments, start=" + start + "; end=" + end + "; left=" + left + "; total=" + total + "; allComments=" + allComments.length);
}

function getComment(id) {
Expand Down
23 changes: 21 additions & 2 deletions qml/pages/GalleryContentPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,27 @@ Page {
}
}

onMovementEnded: {
if(atYEnd) {
// Doesn't seem to work anymore sfos >= 1.1.9.28
// onMovementEnded: {
// console.log("onMovementEnded, atYEnd=", atYEnd)
// if(atYEnd) {
// commentsModel.getNextComments();
// }
// }
}

Item {
id: showMoreCommentsItem;
width: parent.width;
height: visible ? showMoreCommentsButton.height + 2 * constant.paddingSmall : 0;
visible: commentsModel.left > 0;

Button {
id: showMoreCommentsButton;
anchors.centerIn: parent;
enabled: commentsModel.left > 0;
text: qsTr("more (" + commentsModel.total + " total, " + commentsModel.left + " remaining)");
onClicked: {
commentsModel.getNextComments();
}
}
Expand Down

0 comments on commit 4606e54

Please sign in to comment.