+ io; other changes;
This commit is contained in:
1 parent
754c8bf9a4
commit
dc130ad394
13 files changed
+145
-63
No files matched your search
@@ -69,6 +69,7 @@ app.run(function($location, $rootScope, $http, config) {
|
||||
});
|
||||
|
||||
require("./api/api")(app);
|
||||
require("./services/io")(app);
|
||||
require("./ui/menu")(app);
|
||||
require("./ui/timeline")(app);
|
||||
require("./filters/uppercase-first")(app);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Created by tmshv on 15/03/15.
|
||||
*/
|
||||
|
||||
module.exports = function (app) {
|
||||
var socket = io();
|
||||
|
||||
app.service("io", function(){
|
||||
return socket;
|
||||
})
|
||||
};
|
||||
+33
-18
@@ -28,6 +28,22 @@ function postText(post){
|
||||
|
||||
module.exports = function(app) {
|
||||
app.directive("timeline", function (team) {
|
||||
function toInstagram(post){
|
||||
var author_id = personByInstagram(team.team, post.data.author);
|
||||
var name = author_id ? team.short(author_id) : post.data.author;
|
||||
|
||||
return {
|
||||
date: post.date,
|
||||
image: post.data.image.standard_resolution.url,
|
||||
url: post.data.url,
|
||||
username: name,
|
||||
//userpic: post.data.user.profile_picture,
|
||||
text: post.body,
|
||||
//text: postText(post),
|
||||
type: post.type
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
templateUrl: "/views/timeline.html",
|
||||
scope: {
|
||||
@@ -38,7 +54,7 @@ module.exports = function(app) {
|
||||
return index % 2 === 1;
|
||||
}
|
||||
},
|
||||
controller: function($scope, $timeout, usSpinnerService, api){
|
||||
controller: function($scope, $timeout, usSpinnerService, io, api){
|
||||
var portion = 0;
|
||||
var count = 10;
|
||||
$scope.feed = [];
|
||||
@@ -67,23 +83,8 @@ module.exports = function(app) {
|
||||
//}, 5000);
|
||||
|
||||
var feed = list.map(function (post) {
|
||||
if(post.type == "instagram"){
|
||||
var author_id = personByInstagram(team.team, post.data.author);
|
||||
var name = author_id ? team.short(author_id) : post.data.author;
|
||||
|
||||
return {
|
||||
date: post.date,
|
||||
image: post.data.image.standard_resolution.url,
|
||||
url: post.data.url,
|
||||
username: name,
|
||||
//userpic: post.data.user.profile_picture,
|
||||
text: post.body,
|
||||
//text: postText(post),
|
||||
type: post.type
|
||||
};
|
||||
}else{
|
||||
return post;
|
||||
}
|
||||
if(post.type == "instagram") return toInstagram(post);
|
||||
else return post;
|
||||
});
|
||||
|
||||
portion++;
|
||||
@@ -92,6 +93,20 @@ module.exports = function(app) {
|
||||
};
|
||||
|
||||
$scope.loadNext();
|
||||
|
||||
io.on("post", function (params) {
|
||||
var posts = params instanceof Array ? params : [params];
|
||||
console.log("post", posts);
|
||||
|
||||
var feed = posts.map(function (post) {
|
||||
if(post.type == "instagram") return toInstagram(post);
|
||||
else return post;
|
||||
});
|
||||
|
||||
$scope.$apply(function () {
|
||||
$scope.feed = feed.concat($scope.feed);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user