Added conversation view

This commit is contained in:
Jeena Paradies 2012-11-09 21:16:52 +01:00
parent 6c05512285
commit fa2bda0394
13 changed files with 474 additions and 48 deletions

View file

@ -19,6 +19,8 @@
IBOutlet NSWindow *timelineViewWindow;
IBOutlet WebView *mentionsView;
IBOutlet NSWindow *mentionsViewWindow;
IBOutlet WebView *conversationView;
IBOutlet NSWindow *conversationViewWindow;
NSWindow *loginViewWindow;
NSProgressIndicator *loginActivityIndicator;
IBOutlet NSMenuItem *globalHotkeyMenuItem;
@ -32,6 +34,8 @@
@property (retain, nonatomic) IBOutlet NSWindow *timelineViewWindow;
@property (retain, nonatomic) IBOutlet WebView *mentionsView;
@property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow;
@property (retain, nonatomic) IBOutlet WebView *conversationView;
@property (retain, nonatomic) IBOutlet NSWindow *conversationViewWindow;
@property (assign) IBOutlet NSWindow *loginViewWindow;
@property (assign) IBOutlet NSProgressIndicator *loginActivityIndicator;
@property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem;
@ -58,6 +62,8 @@
- (IBAction)login:(id)sender;
- (IBAction)logout:(id)sender;
- (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity;
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);

View file

@ -15,7 +15,8 @@
@synthesize loginViewWindow;
@synthesize loginActivityIndicator;
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate;
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, conversationView, conversationViewWindow;
@synthesize globalHotkeyMenuItem, viewDelegate;
@synthesize logoLayer;
@synthesize oauthView, accessToken;
@ -53,6 +54,10 @@
accessToken = [[AccessToken alloc] init];
//[accessToken setString:nil forKey:@"user_access_token"];
if (![accessToken stringForKey:@"version-0.2.0-new-login"]) {
[self logout:self];
[accessToken setString:@"yes" forKey:@"version-0.2.0-new-login"];
}
if (![accessToken stringForKey:@"user_access_token"]) {
[timelineViewWindow performClose:self];
@ -103,6 +108,14 @@
[mentionsView setPolicyDelegate:viewDelegate];
[mentionsView setUIDelegate:viewDelegate];
[[mentionsView windowScriptObject] setValue:self forKey:@"controller"];
viewDelegate.conversationView = conversationView;
[[conversationView mainFrame] loadHTMLString:index_string baseURL:url];
[conversationView setFrameLoadDelegate:viewDelegate];
[conversationView setPolicyDelegate:viewDelegate];
[conversationView setUIDelegate:viewDelegate];
[[conversationView windowScriptObject] setValue:self forKey:@"controller"];
// FIXME: show timelineView after authentification
}
@ -305,6 +318,12 @@
[mentionsView stringByEvaluatingJavaScriptFromString:@"tentia_instance.getNewData(true)"];
}
- (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity
{
NSString *js = [NSString stringWithFormat:@"tentia_instance.showStatus('%@', '%@');", postId, entity];
[conversationView stringByEvaluatingJavaScriptFromString:js];
[conversationViewWindow makeKeyAndOrderFront:self];
}
/* CARBON */

View file

@ -3,7 +3,7 @@
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">2843</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
@ -15,7 +15,7 @@
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>2843</string>
<string>2844</string>
<string>1810</string>
</object>
</object>
@ -920,7 +920,7 @@
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
<string key="GroupName"/>
<object class="WebPreferences" key="Preferences">
<object class="WebPreferences" key="Preferences" id="1028823828">
<string key="Identifier">12</string>
<object class="NSMutableDictionary" key="Values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -935,6 +935,66 @@
<string key="NSFrameSize">{376, 581}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="126069112"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName">mentions</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
<object class="NSWindowTemplate" id="522849916">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{1292, 328}, {376, 581}}</string>
<int key="NSWTFlags">1685586944</int>
<string key="NSWindowTitle">Conversation</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="443388945">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="WebView" id="461483829">
<reference key="NSNextResponder" ref="443388945"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple HTML pasteboard type</string>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple URL pasteboard type</string>
<string>Apple Web Archive pasteboard type</string>
<string>NSColor pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NSStringPboardType</string>
<string>NeXT RTFD pasteboard type</string>
<string>NeXT Rich Text Format v1.0 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
<string>WebURLsWithTitlesPboardType</string>
<string>public.png</string>
<string>public.url</string>
<string>public.url-name</string>
</object>
</object>
<string key="NSFrameSize">{376, 581}</string>
<reference key="NSSuperview" ref="443388945"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
<string key="GroupName"/>
<reference key="Preferences" ref="1028823828"/>
<bool key="UseBackForwardList">NO</bool>
<bool key="AllowsUndo">YES</bool>
</object>
</object>
<string key="NSFrameSize">{376, 581}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="461483829"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
@ -1561,6 +1621,22 @@
</object>
<int key="connectionID">622</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">conversationView</string>
<reference key="source" ref="408500656"/>
<reference key="destination" ref="461483829"/>
</object>
<int key="connectionID">632</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">conversationViewWindow</string>
<reference key="source" ref="408500656"/>
<reference key="destination" ref="522849916"/>
</object>
<int key="connectionID">633</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">makeKeyAndOrderFront:</string>
@ -1617,6 +1693,14 @@
</object>
<int key="connectionID">619</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="522849916"/>
<reference key="destination" ref="408500656"/>
</object>
<int key="connectionID">631</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -2366,6 +2450,30 @@
<reference key="object" ref="281587867"/>
<reference key="parent" ref="720053764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">628</int>
<reference key="object" ref="522849916"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="443388945"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">Mentions</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">629</int>
<reference key="object" ref="443388945"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="461483829"/>
</object>
<reference key="parent" ref="522849916"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">630</int>
<reference key="object" ref="461483829"/>
<reference key="parent" ref="443388945"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -2477,6 +2585,11 @@
<string>610.IBPluginDependency</string>
<string>613.IBPluginDependency</string>
<string>620.IBPluginDependency</string>
<string>628.IBPluginDependency</string>
<string>628.IBWindowTemplateEditedContentRect</string>
<string>628.NSWindowTemplate.visibleAtLaunch</string>
<string>629.IBPluginDependency</string>
<string>630.IBPluginDependency</string>
<string>72.IBPluginDependency</string>
<string>73.IBPluginDependency</string>
<string>79.IBPluginDependency</string>
@ -2593,6 +2706,11 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{344, 175}, {376, 581}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.WebKitIBPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -2613,7 +2731,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">627</int>
<int key="maxID">633</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -2627,11 +2745,15 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>login:</string>
<string>logout:</string>
<string>openNewMessageWindow:</string>
<string>sendTweet:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@ -2640,6 +2762,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>login:</string>
<string>logout:</string>
<string>openNewMessageWindow:</string>
<string>sendTweet:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -2651,12 +2775,22 @@
<string key="name">logout:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">openNewMessageWindow:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">sendTweet:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>conversationView</string>
<string>conversationViewWindow</string>
<string>globalHotkeyMenuItem</string>
<string>loginActivityIndicator</string>
<string>loginViewWindow</string>
@ -2669,6 +2803,8 @@
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WebView</string>
<string>NSWindow</string>
<string>NSMenuItem</string>
<string>NSProgressIndicator</string>
<string>NSWindow</string>
@ -2684,6 +2820,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>conversationView</string>
<string>conversationViewWindow</string>
<string>globalHotkeyMenuItem</string>
<string>loginActivityIndicator</string>
<string>loginViewWindow</string>
@ -2696,6 +2834,14 @@
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">conversationView</string>
<string key="candidateClassName">WebView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">conversationViewWindow</string>
<string key="candidateClassName">NSWindow</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">globalHotkeyMenuItem</string>
<string key="candidateClassName">NSMenuItem</string>

View file

@ -13,11 +13,13 @@
@interface ViewDelegate : NSObject {
WebView *timelineView;
WebView *mentionsView;
WebView *conversationView;
WebView *oauthView;
}
@property (nonatomic, assign) WebView *timelineView;
@property (nonatomic, assign) WebView *mentionsView;
@property (nonatomic, assign) WebView *conversationView;
@property (nonatomic, assign) WebView *oauthView;
@end

View file

@ -11,7 +11,7 @@
@implementation ViewDelegate
@synthesize timelineView, mentionsView, oauthView;
@synthesize timelineView, mentionsView, conversationView, oauthView;
- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)message;{
@ -19,6 +19,7 @@
NSString *viewName = @"TimelineView";
if (sender == mentionsView) viewName = @"MentionsView";
if (sender == conversationView) viewName = @"ConversationView";
if (sender == oauthView) viewName = @"OauthView";
NSLog(@"js<%@>: %@:%@: %@",
@ -32,6 +33,7 @@
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
NSString *viewName = @"TimelineView";
if (sender == mentionsView) viewName = @"MentionsView";
if (sender == conversationView) viewName = @"ConversationView";
if (sender == oauthView) viewName = @"OauthView";
NSLog(@"jsa<%@>: %@", viewName, message);
@ -47,7 +49,11 @@
if (sender == oauthView) {
[oauthView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('oauth') }"];
} else if(sender == conversationView) {
[conversationView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('conversation') }"];
} else {
NSString *action = @"timeline";

View file

@ -62,6 +62,10 @@ li:after {
height: 0;
}
.highlight {
border-right: 5px solid #f17779;
}
h1 {
font-size: 1em;
font-weight: bold;

View file

@ -0,0 +1,126 @@
define([
"helper/HostApp",
"helper/Core",
"helper/Paths",
"lib/URI"
],
function(HostApp, Core, Paths, URI, Followings) {
function Conversation() {
Core.call(this);
this.action = "conversation";
this.body = document.createElement("ol");
this.body.className = this.action;
document.body.appendChild(this.body);
}
Conversation.prototype = Object.create(Core.prototype);
Conversation.addStatus = function(status) {
this.body.appendChild(this.getStatusDOMElement(status));
}
Conversation.prototype.showStatus = function(id, entity) {
this.body.innerHTML = "";
this.append(id, entity);
}
Conversation.prototype.append = function(id, entity, node, add_after) {
var _this = this;
var callback = function(resp) {
var status = JSON.parse(resp.responseText);
var dom_element = _this.getStatusDOMElement(status);
if (node) {
node.parentNode.insertBefore(dom_element, node);
} else {
dom_element.className = "highlight";
_this.body.appendChild(dom_element);
_this.appendMentioned(id, entity, dom_element);
}
if (status.mentions && status.mentions.length > 0 && status.mentions[0].post) {
_this.append(status.mentions[0].post, status.mentions[0].entity, dom_element);
}
}
function getRemoteStatus(profile) {
var server = profile["https://tent.io/types/info/core/v0.1.0"].servers[0];
Paths.getURL(URI(server + "/posts/" + id).toString(), "GET", callback, null, false);
}
if (entity == HostApp.stringForKey("entity")) {
var url = URI(Paths.mkApiRootPath("/posts/" + id));
Paths.getURL(url.toString(), "GET", callback, null);
} else if(this.followings.followings[entity]) {
getRemoteStatus(this.followings.followings[entity].profile);
} else {
Paths.findProfileURL(entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
getRemoteStatus(JSON.parse(resp.responseText));
}, null, false); // do not send auth-headers
}
});
}
}
Conversation.prototype.appendMentioned = function(id, entity, node) {
var url = URI(Paths.mkApiRootPath("/posts"));
url.addSearch("mentioned_post", id);
url.addSearch("post_types", "https%3A%2F%2Ftent.io%2Ftypes%2Fpost%2Fstatus%2Fv0.1.0");
var _this = this;
var callback = function(resp) {
var statuses = JSON.parse(resp.responseText);
for (var i = 0; i < statuses.length; i++) {
var status = statuses[i];
var dom_element = _this.getStatusDOMElement(status);
_this.body.appendChild(dom_element);
_this.appendMentioned(status.id, status.entity, dom_element);
}
}
Paths.getURL(url.toString(), "GET", callback);
}
// /posts?limit=10&mentioned_post=gnqqyt&post_types=https%3A%2F%2Ftent.io%2Ftypes%2Fpost%2Fstatus%2Fv0.1.0,https%3A%2F%2Ftent.io%2Ftypes%2Fpost%2Frepost%2Fv0.1.0 HTTP/1.1" 200 - 0.0582
return Conversation;
});

View file

@ -18,7 +18,13 @@ function(HostApp, Paths, Hmac) {
],
"scopes": {
"read_posts": "Uses posts to show them in a list",
"write_posts": "Posts on users behalf"
"write_posts": "Posts on users behalf",
"read_profile": "Displays your own profile",
"write_profile": "Updating profile and mentions pointer",
"read_followers": "Display a list of people who follow you",
"write_followers": "Be able to block people who follow you",
"read_followings": "Display following list and their older posts in conversations",
"write_followings": "Follow ne entities"
}
};
@ -74,7 +80,7 @@ function(HostApp, Paths, Hmac) {
+ "&redirect_uri=" + escape(this.app_info["redirect_uris"][0])
+ "&scope=" + Object.keys(this.app_info["scopes"]).join(",")
+ "&state=" + this.state
+ "&tent_post_types=" + escape("https://tent.io/types/posts/status/v0.1.0");
+ "&tent_post_types=all";
HostApp.openURL(this.apiRoot() + auth);
}

View file

@ -3,13 +3,16 @@ define([
"helper/Paths",
"lib/URI",
"helper/HostApp",
"helper/Followings",
"lib/vendor/jquery.plugins"
],
function(jQuery, Paths, URI, HostApp) {
function(jQuery, Paths, URI, HostApp, Followings) {
function Core() {
this.followings = new Followings();
}
Core.prototype.getTemplate = function() {
@ -121,7 +124,6 @@ function(jQuery, Paths, URI, HostApp) {
var template = this.getTemplate();
template.reply_to.onclick = function() {
var mentions = [];
@ -140,25 +142,39 @@ function(jQuery, Paths, URI, HostApp) {
template.username.innerText = status.entity;
template.username.href = status.entity; // FIXME open profile
Paths.findProfileURL(status.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var profile = JSON.parse(resp.responseText);
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
var profile = function(profile) {
if (profile && basic) {
if(basic.name) {
template.username.title = template.username.innerText;
template.username.innerText = basic.name;
}
if(basic.avatar_url) {
template.image.onerror = function() { template.image.src = 'img/default-avatar.png' };
template.image.src = basic.avatar_url;
}
}
}, null, false); // do not send auth-headers
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
if (profile && basic) {
if(basic.name) {
template.username.title = template.username.innerText;
template.username.innerText = basic.name;
}
if(basic.avatar_url) {
template.image.onerror = function() { template.image.src = 'img/default-avatar.png' };
template.image.src = basic.avatar_url;
}
}
});
}
if (this.followings.followings[status.entity]) {
profile(this.followings.followings[status.entity].profile);
} else {
Paths.findProfileURL(status.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var p = JSON.parse(resp.responseText);
profile(p)
}, null, false); // do not send auth-headers
}
});
}
template.in_reply.parentNode.className = "hidden";
@ -174,6 +190,12 @@ function(jQuery, Paths, URI, HostApp) {
time.className = "timeago";
jQuery(time).timeago();
template.ago.appendChild(time);
template.ago.href = "#"
template.ago.onclick = function() {
HostApp.showConversation(status.id, status.entity);
return false;
}
// {"type":"Point","coordinates":[57.10803113,12.25854746]}
if (status.content && status.content.location && status.content.location.type == "Point") {
@ -272,30 +294,44 @@ function(jQuery, Paths, URI, HostApp) {
}
}
var _this = this;
for (var i = 0; i < mentions_in_text.length; i++) {
var mention = mentions_in_text[i];
(function(mention) { // need this closure
Paths.findProfileURL(mention.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var profile = JSON.parse(resp.responseText);
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
if (profile && basic) {
if(basic.name) {
var new_text = node.innerHTML.replace(
mention.text,
"<strong class='name' title='" + mention.entity + "'" + ">"
+ basic.name
+ "</strong>"
);
node.innerHTML = new_text;
}
}
}, null, false); // do not send auth-headers
var profile = function(profile) {
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
if (profile && basic) {
if(basic.name) {
var new_text = node.innerHTML.replace(
mention.text,
"<strong class='name' title='" + mention.entity + "'" + ">"
+ basic.name
+ "</strong>"
);
node.innerHTML = new_text;
}
}
});
}
if (_this.followings.followings[mention.entity]) {
profile(_this.followings.followings[mention.entity].profile)
} else {
Paths.findProfileURL(mention.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var p = JSON.parse(resp.responseText);
profile(p)
}, null, false); // do not send auth-headers
}
});
}
})(mention);
}
}

View file

@ -0,0 +1,50 @@
define([
"helper/Paths",
"lib/URI"
],
function(Paths, URI) {
function Followings() {
this.timeout = 2 * 60 * 1000;
this.followings = {};
this.before_id = null;
var _this = this;
this.intervall = setInterval(function() { _this.getAllFollowings(); }, this.timeout);
this.getAllFollowings();
}
Followings.prototype.getAllFollowings = function() {
var _this = this;
var callback = function(resp) {
var fs = JSON.parse(resp.responseText)
if (fs.length < 1) return;
for (var i = 0; i < fs.length; i++) {
var following = fs[i];
_this.before_id = following.id;
_this.followings[following.entity] = following;
}
_this.getAllFollowings();
}
var url = URI(Paths.mkApiRootPath("/followings"));
if (this.before_id) {
url.addSearch("before_id", this.before_id);
}
Paths.getURL(url, "GET", callback);
}
return Followings;
});

View file

@ -61,6 +61,15 @@ define(function() {
}
}
HostApp.showConversation = function(id, entity) {
if (OS_TYPE == "mac") {
controller.showConversationForPostId_andEntity_(id, entity);
} else {
controller.showConversationForPostIdandEntity(id, entity);
}
}
return HostApp;
});

View file

@ -21,21 +21,28 @@ function(jQuery, HostApp, Hmac) {
}
Paths.getURL = function(url, http_method, callback, data, auth_header) {
jQuery.ajax({
beforeSend: function(xhr) {
if (data) xhr.setRequestHeader("Content-Length", data.length);
if (auth_header) { // if is_set? auth_header
xhr.setRequestHeader("Authorization", auth_header);
} else {
var user_access_token = HostApp.stringForKey("user_access_token");
if (auth_header !== false && user_access_token) {
auth_header = Hmac.makeAuthHeader(
url,
http_method,
HostApp.stringForKey("user_mac_key"),
user_access_token
)
);
xhr.setRequestHeader("Authorization", auth_header);
}
}
@ -54,6 +61,7 @@ function(jQuery, HostApp, Hmac) {
}
Paths.findProfileURL = function(entity, callback) {
jQuery.ajax({
url: entity,
type: "HEAD",

View file

@ -39,6 +39,12 @@ function start(view) {
} else if (view == "conversation") {
require(["controller/Conversation"], function(Conversation) {
tentia_instance = new Conversation();
});
}
}
@ -59,10 +65,12 @@ function loadPlugin(url) {
}
function debug(string) {
if (typeof string != "string") {
string = JSON.stringify(string);
}
alert("DEBUG: " + string);
}
setTimeout(HostAppGo, 1000);
setTimeout(HostAppGo, 2000);