fixed problems with scroll to load more
This commit is contained in:
parent
624dd9a1b9
commit
be8a0c63e3
10 changed files with 101 additions and 45 deletions
|
@ -28,6 +28,7 @@ class Bungloo:
|
|||
self.preferences.show()
|
||||
|
||||
self.oauth_implementation = Windows.Oauth(self)
|
||||
self.conversation_views = []
|
||||
|
||||
if self.controller.stringForKey("user_access_token") != "":
|
||||
self.authentification_succeded()
|
||||
|
@ -160,10 +161,10 @@ class Controller(QtCore.QObject):
|
|||
@QtCore.pyqtSlot(str, str, str, str)
|
||||
def notificateUserAboutMentionFromNameWithPostIdAndEntity(self, text, name, post_id, entity):
|
||||
try:
|
||||
subprocess.check_output(['kdialog', '--passivepopup', name + ' mentioned you: ' + text])
|
||||
subprocess.check_output(['kdialog', '--passivepopup', (name + ' mentioned you: ' + text).replace("\"", "\\\"")])
|
||||
except OSError:
|
||||
try:
|
||||
subprocess.check_output(['notify-send', '-i', 'dialog-information', name + ' mentioned you on Tent', text])
|
||||
subprocess.check_output(['notify-send', '-i', 'dialog-information', name.replace("\"", "\\\"") + ' mentioned you on Tent', text.replace("\"", "\\\"")])
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -221,6 +222,16 @@ class Controller(QtCore.QObject):
|
|||
self.app.timeline.evaluateJavaScript(func)
|
||||
self.app.timeline.show()
|
||||
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def showConversationViewForPostIdandEntity(self, postId, entity):
|
||||
custom_after_load = "function HostAppGo() { start('conversation-standalone', function() { bungloo.conversation.showStatus("
|
||||
custom_after_load += "'{}', '{}'".format(postId, entity)
|
||||
custom_after_load += "); }) }"
|
||||
|
||||
conversation = Windows.Timeline(self.app, "conversation", "Conversation", custom_after_load)
|
||||
self.app.conversation_views += [conversation]
|
||||
conversation.show()
|
||||
|
||||
@QtCore.pyqtSlot(str)
|
||||
def showProfileForEntity(self, entity):
|
||||
func = "bungloo.sidebar.onEntityProfile(); bungloo.entityProfile.showProfileForEntity('{}');".format(entity)
|
||||
|
|
|
@ -76,10 +76,11 @@ class Preferences:
|
|||
|
||||
class Timeline:
|
||||
|
||||
def __init__(self, app, action="timeline", title="Bungloo"):
|
||||
def __init__(self, app, action="timeline", title="Bungloo", custom_after_load=None):
|
||||
self.app = app
|
||||
self.action = action
|
||||
self.title = title
|
||||
self.custom_after_load = custom_after_load
|
||||
|
||||
self.window = Helper.RestorableWindow(action, self.app)
|
||||
self.window.setWindowTitle(title)
|
||||
|
@ -182,8 +183,7 @@ class Timeline:
|
|||
|
||||
def show(self):
|
||||
self.window.show()
|
||||
#self.window.raise_()
|
||||
#QtGui.qApp.setActiveWindow(self.window)
|
||||
|
||||
def close(self):
|
||||
self.window.close()
|
||||
|
||||
|
@ -192,6 +192,8 @@ class Timeline:
|
|||
|
||||
def load_finished(self, widget):
|
||||
script = "function HostAppGo() { start('" + self.action + "'); }"
|
||||
if self.custom_after_load:
|
||||
script = self.custom_after_load
|
||||
self.webView.page().mainFrame().evaluateJavaScript(script)
|
||||
|
||||
def set_window_title(self, title):
|
||||
|
|
|
@ -7,16 +7,25 @@ html, body {
|
|||
body {
|
||||
font-family: "Lucida Grande", "Open Sans", "Ubuntu", Tahoma, sans-serif;
|
||||
font-size: 11px;
|
||||
background: #dedede url(../img/background.png) center center no-repeat;
|
||||
background: #dedede center center no-repeat;
|
||||
}
|
||||
|
||||
body#with-sidebar {
|
||||
background-image: url(../img/background.png);
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #00317a;
|
||||
outline: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#with-sidebar #sidebar {
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
@ -59,7 +68,7 @@ a {
|
|||
/*display: none;*/
|
||||
}
|
||||
|
||||
#content {
|
||||
#with-sidebar #content {
|
||||
margin-left: 62px;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ define([
|
|||
function(HostApp, Core, Paths, URI) {
|
||||
|
||||
|
||||
function Conversation() {
|
||||
function Conversation(standalone) {
|
||||
|
||||
Core.call(this);
|
||||
|
||||
this.standalone = standalone;
|
||||
|
||||
this.action = "conversation";
|
||||
|
||||
|
@ -20,7 +22,7 @@ function(HostApp, Core, Paths, URI) {
|
|||
this.container.appendChild(this.body)
|
||||
|
||||
document.getElementById("content").appendChild(this.container);
|
||||
this.hide();
|
||||
if(!this.standalone) this.hide();
|
||||
}
|
||||
|
||||
Conversation.prototype = Object.create(Core.prototype);
|
||||
|
@ -43,6 +45,8 @@ function(HostApp, Core, Paths, URI) {
|
|||
Conversation.prototype.showStatus = function(id, entity) {
|
||||
|
||||
this.body.innerHTML = "";
|
||||
this.current_post_id = id;
|
||||
this.current_entity = entity;
|
||||
this.append(id, entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -417,11 +417,10 @@ function(HostApp, Core, Paths, URI) {
|
|||
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
|
||||
var last_status = statuses[statuses.length -1];
|
||||
this.before.id = last_status.id
|
||||
this.before.entity = last_status.entity;
|
||||
this.before.loading = false;
|
||||
|
||||
if (append) statuses = statuses.reverse();
|
||||
|
||||
for(var i = statuses.length-1, c=0; i>=c; --i) {
|
||||
|
||||
var status = statuses[i];
|
||||
|
@ -460,11 +459,11 @@ function(HostApp, Core, Paths, URI) {
|
|||
}
|
||||
|
||||
Profile.prototype.getMoreStatusPosts = function() {
|
||||
if (!this.before.loading && this.before.id) {
|
||||
if (!this.before.loading) {
|
||||
this.before.loading = true;
|
||||
var add_search = {
|
||||
"before_id": this.before.id,
|
||||
"before_id_entity": this.before.entity
|
||||
"before_id": this.body.lastChild.status.id,
|
||||
"before_id_entity": this.body.lastChild.status.entity
|
||||
}
|
||||
this.getStatuses(this.server, add_search, true);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ function(HostApp, Paths, Cache) {
|
|||
|
||||
this.menu.user = this.createItem("User", function() { _this.onEntity(); return false; }, "img/sidebar/user.png", "img/sidebar/user.png");
|
||||
this.menu.timeline = this.createItem("Timeline", function() { _this.onTimeline(); return false; }, "img/sidebar/timeline.png", "img/sidebar/timeline_active.png", true);
|
||||
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions(); return false; }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
|
||||
|
||||
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions(); return false; }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
|
||||
this.menu.conversation = this.createItem("Conversation", function() { _this.onConversation(); return false; }, "img/sidebar/conversation.png", "img/sidebar/conversation_active.png");
|
||||
this.menu.entityProfile = this.createItem("Profile", function() { _this.onEntityProfile(); return false; }, "img/sidebar/profile.png", "img/sidebar/profile_active.png");
|
||||
this.menu.search = this.createItem("Search", function() { _this.onSearch(); return false; }, "img/sidebar/search.png", "img/sidebar/search_active.png")
|
||||
|
@ -35,13 +34,22 @@ function(HostApp, Paths, Cache) {
|
|||
|
||||
this.unreadMentionsSpan = document.createElement("span");
|
||||
this.unreadMentionsSpan.className = "unread_mentions";
|
||||
this.menu.mentions.appendChild(this.unreadMentionsSpan);
|
||||
this.menu.mentions.getElementsByTagName("a")[0].appendChild(this.unreadMentionsSpan);
|
||||
this.setUnreadMentions(0);
|
||||
|
||||
this.menu.conversation.getElementsByTagName("a")[0].ondblclick = function() {
|
||||
var postId = bungloo.conversation.current_post_id;
|
||||
var entity = bungloo.conversation.current_entity;
|
||||
if (postId && entity) {
|
||||
HostApp.showConversationViewForPostIdandEntity(postId, entity);
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("sidebar").appendChild(this.body);
|
||||
|
||||
// initial seting of the <body> class
|
||||
document.body.className = "body-timeline";
|
||||
document.body.id = "with-sidebar";
|
||||
|
||||
this.setEntityAvatar();
|
||||
this.setOnScroll();
|
||||
|
|
|
@ -14,7 +14,7 @@ function(Core, Paths, HostApp, URI) {
|
|||
this.action = "timeline";
|
||||
this.reload_blocked = false;
|
||||
|
||||
this.max_length = 20;
|
||||
this.max_length = 25;
|
||||
this.timeout = 10 * 1000; // every 10 seconds
|
||||
this.since_id = null;
|
||||
this.since_id_entity = null;
|
||||
|
@ -49,11 +49,10 @@ function(Core, Paths, HostApp, URI) {
|
|||
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
|
||||
var last_status = statuses[statuses.length -1];
|
||||
this.before.id = last_status.id
|
||||
this.before.entity = last_status.entity;
|
||||
this.before.loading = false;
|
||||
|
||||
if (append) statuses = statuses.reverse();
|
||||
|
||||
for(var i = statuses.length-1, c=0; i>=c; --i) {
|
||||
|
||||
var status = statuses[i];
|
||||
|
@ -66,18 +65,20 @@ function(Core, Paths, HostApp, URI) {
|
|||
|
||||
var new_node = this.getStatusDOMElement(status);
|
||||
|
||||
if(!append && this.body.childNodes.length > 0) {
|
||||
if (!document.getElementById(new_node.id)) {
|
||||
if(!append && this.body.childNodes.length > 0) {
|
||||
|
||||
if(this.body.childNodes.length > this.max_length) {
|
||||
if(this.body.childNodes.length > this.max_length) {
|
||||
|
||||
this.body.removeChild(this.body.lastChild);
|
||||
this.body.removeChild(this.body.lastChild);
|
||||
}
|
||||
|
||||
this.body.insertBefore(new_node, this.body.firstChild);
|
||||
|
||||
} else {
|
||||
|
||||
this.body.appendChild(new_node);
|
||||
}
|
||||
|
||||
this.body.insertBefore(new_node, this.body.firstChild);
|
||||
|
||||
} else {
|
||||
|
||||
this.body.appendChild(new_node);
|
||||
}
|
||||
|
||||
} else if (status.type == "https://tent.io/types/post/delete/v0.1.0") {
|
||||
|
@ -107,7 +108,7 @@ function(Core, Paths, HostApp, URI) {
|
|||
"https://tent.io/types/post/photo/v0.1.0"
|
||||
];
|
||||
url.addSearch("post_types", post_types.join(","));
|
||||
|
||||
//url.addSearch("sort_by", "published_at");
|
||||
url.addSearch("limit", this.max_length);
|
||||
|
||||
if(this.since_id && !append) {
|
||||
|
@ -147,12 +148,13 @@ function(Core, Paths, HostApp, URI) {
|
|||
}
|
||||
|
||||
Timeline.prototype.getMoreStatusPosts = function() {
|
||||
if (!this.before.loading && this.before.id) {
|
||||
if (!this.before.loading) {
|
||||
this.before.loading = true;
|
||||
var add_search = {
|
||||
"before_id": this.before.id,
|
||||
"before_id_entity": this.before.entity
|
||||
"before_id": this.body.lastChild.status.id,
|
||||
"before_id_entity": this.body.lastChild.status.entity
|
||||
}
|
||||
|
||||
this.getNewData(add_search, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ define([
|
|||
"lib/URI",
|
||||
"helper/HostApp",
|
||||
"helper/Cache",
|
||||
"lib/Timeago"
|
||||
"lib/Timeago",
|
||||
"lib/SingleDoubleClick"
|
||||
],
|
||||
|
||||
function(jQuery, Paths, URI, HostApp, Cache) {
|
||||
|
@ -336,10 +337,12 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
|||
template.ago.appendChild(time);
|
||||
|
||||
template.ago.href = "#"
|
||||
template.ago.onclick = function() {
|
||||
|
||||
$(template.ago).single_double_click(function () {
|
||||
HostApp.showConversation(status.id, status.entity);
|
||||
return false;
|
||||
}
|
||||
}, function () {
|
||||
HostApp.showConversationViewForPostIdandEntity(status.id, status.entity);
|
||||
});
|
||||
|
||||
// {"type":"Point","coordinates":[57.10803113,12.25854746]}
|
||||
if (status.content && status.content.location && (typeof status.content.location.type == "undefined" || status.content.location.type == "Point")) {
|
||||
|
@ -370,7 +373,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
|||
}
|
||||
|
||||
|
||||
Core.prototype.getRepost = function(repost, before_node) {
|
||||
Core.prototype.getRepost = function(repost, before_node, append) {
|
||||
|
||||
var post = document.getElementById("post-" + repost.content.id + "-" + this.action);
|
||||
|
||||
|
@ -450,7 +453,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
|||
var status = JSON.parse(resp.responseText);
|
||||
status.__repost = repost;
|
||||
var li = _this.getStatusDOMElement(status);
|
||||
before_node.parentNode.insertBefore(li, before_node);
|
||||
if(!document.getElementById(li.id)) before_node.parentNode.insertBefore(li, before_node);
|
||||
_this.getRepost(repost, before_node); // call this recursive because we now have the repost
|
||||
}
|
||||
}
|
||||
|
@ -994,7 +997,8 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
|||
Core.prototype.afterChangingTextinMessageHTML = function(message_node) {
|
||||
// adding show search on click hash
|
||||
$(message_node).find("a.hash").click(function(e) {
|
||||
bungloo.search.searchFor(e.target.innerHTML);
|
||||
|
||||
if(bungloo.search) bungloo.search.searchFor(e.target.innerHTML);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
|
|
@ -95,6 +95,14 @@ define(function() {
|
|||
}
|
||||
}
|
||||
|
||||
HostApp.showConversationViewForPostIdandEntity = function(id, entity) {
|
||||
if (OS_TYPE == "mac") {
|
||||
controller.showConversationViewForPostId_andEntity_(id, entity);
|
||||
} else {
|
||||
controller.showConversationViewForPostIdandEntity(id, entity);
|
||||
}
|
||||
}
|
||||
|
||||
HostApp.showProfileForEntity = function(entity) {
|
||||
|
||||
if (OS_TYPE == "mac") {
|
||||
|
|
|
@ -14,7 +14,7 @@ requirejs.config({
|
|||
baseUrl: 'scripts'
|
||||
});
|
||||
|
||||
function start(view) {
|
||||
function start(view, callback) {
|
||||
|
||||
if (view == "oauth") {
|
||||
|
||||
|
@ -24,6 +24,15 @@ function start(view) {
|
|||
|
||||
});
|
||||
|
||||
} else if (view == "conversation-standalone") {
|
||||
|
||||
require(["controller/Conversation"], function(Conversation) {
|
||||
|
||||
bungloo.conversation = new Conversation(true);
|
||||
if(callback) callback();
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
@ -141,7 +150,7 @@ function loadCssPlugin(css_url) {
|
|||
function debug(string) {
|
||||
|
||||
if (typeof string != "string") {
|
||||
string = JSON.stringify(string);
|
||||
string = JSON.stringify(string);
|
||||
}
|
||||
|
||||
console.debug(string);
|
||||
|
|
Reference in a new issue