diff --git a/actions/Facebook.js b/actions/Facebook.js
index 306d9b7..dd25efe 100644
--- a/actions/Facebook.js
+++ b/actions/Facebook.js
@@ -49,7 +49,7 @@ export function fetchUserInfo(router, accessToken){
}).then(function(response){
dispatch(list_video())
dispatch({type: types.FE_COMPLETE_AUTHENTICATING})
- router.pushState(null, URL_PREFIX+'/videos')
+ router.pushState(null, URL_PREFIX+'videos')
})
})
}
@@ -277,7 +277,7 @@ export function handle_share(video ,history){
FB.getLoginStatus(function(response){
if(response.status != "connected"){
- history.pushState(null, URL_PREFIX+'/login')
+ history.pushState(null, URL_PREFIX+'login')
}else{
var accessToken = response.authResponse.accessToken
FB.api(
@@ -294,7 +294,7 @@ export function handle_share(video ,history){
/* handle the result */
dispatch({type: types.FE_FB_VIDEO_SHARING_COMPLETE})
dispatch(complete_share())
- history.pushState(null, URL_PREFIX+'/videos')
+ history.pushState(null, URL_PREFIX+'videos')
}else{
dispatch(complete_share())
localStorage.removeItem('pv_fb_token')
@@ -321,9 +321,9 @@ function handleLogin(router) {
dispatch(fetchUserInfo(router, accessToken))
} else if (response.status === 'not_authorized') {
- router.pushState(null, URL_PREFIX+'/login')
+ router.pushState(null, URL_PREFIX+'login')
} else {
- router.pushState(null, URL_PREFIX+'/login')
+ router.pushState(null, URL_PREFIX+'login')
}
}, {scope: ['user_photos', 'email', 'publish_actions']})
}
diff --git a/components/Header.js b/components/Header.js
index 992d2e0..8de67db 100644
--- a/components/Header.js
+++ b/components/Header.js
@@ -21,8 +21,8 @@ class Header extends Component {
- - My Videos
- - Select Album
+ - My Videos
+ - Select Album
diff --git a/components/List.js b/components/List.js
index 1e8598d..cae5752 100644
--- a/components/List.js
+++ b/components/List.js
@@ -11,6 +11,7 @@ class List extends Component {
handleMouseEnter(id){
this.setState({'isMouseInsideID': id})
}
+
handleMouseLeave(){
this.setState({'isMouseInsideID': null})
}
@@ -48,7 +49,7 @@ class List extends Component {
{(this.state.isMouseInsideID === video.id) ? this.getBtn(video.id): null}
-
{ video.name }
+
{video.name}
diff --git a/components/Login.js b/components/Login.js
index 10fb4fb..6e06dee 100644
--- a/components/Login.js
+++ b/components/Login.js
@@ -5,10 +5,20 @@ import cookie from 'react-cookie'
class Login extends Component{
- componentDidMount(){
- let facebook_helper = new FacebookHelper();
+ constructor(props){
+ super(props)
+ this.state = {'show_login_button': false}
}
+ componentDidMount(){
+ let self = this
+ let facebook_helper = new FacebookHelper()
+ facebook_helper.getLoginStatus(function(response){
+ self.setState({'show_login_button': true})
+ localStorage.removeItem('picovico')
+ })
+
+ }
componentWillUnmount(){
localStorage['picovico'] = JSON.stringify(this.props.login)
}
@@ -51,6 +61,21 @@ class Login extends Component{
}
}
+ show_login_button(actions){
+ var show_btn;
+ if (this.state.show_login_button){
+ show_btn =
+ return show_btn
+ }else{
+ show_btn =
+ Loading ..
+
+ return show_btn
+ }
+ }
+
render() {
const { login, actions, history } = this.props
return (
@@ -69,9 +94,7 @@ class Login extends Component{
-
+ {this.show_login_button(actions)}
diff --git a/components/album_list.js b/components/album_list.js
index f40407c..bf95e51 100644
--- a/components/album_list.js
+++ b/components/album_list.js
@@ -10,6 +10,7 @@ class AlbumList extends Component {
handleMouseEnter(id){
this.setState({'isMouseInsideID': id})
}
+
handleMouseLeave(){
this.setState({'isMouseInsideID': null})
}
@@ -49,7 +50,7 @@ class AlbumList extends Component {
{(this.state.isMouseInsideID === album.id) ? this.getBtn(album.photos.data.length, album.id): null}
-
{ album.name }
+
{album.name}
{album.photos.data.length} photo(s)
diff --git a/constants/project.js b/constants/project.js
index c7bdbe7..bdd8340 100644
--- a/constants/project.js
+++ b/constants/project.js
@@ -12,4 +12,5 @@ export const STYLE = "vanilla"
export const MUSIC = "https://s3-us-west-2.amazonaws.com/pv-audio-library/free-music/preview/Christmas/Kevin-MacLeod-Christmas-Rap.mp3"
-export const URL_PREFIX = "/popcorn"
\ No newline at end of file
+export const URL_PREFIX = "/popcorn/"
+// export const URL_PREFIX = "/"
diff --git a/containers/VideoCreateView.js b/containers/VideoCreateView.js
index 2957bd4..97e7ca5 100644
--- a/containers/VideoCreateView.js
+++ b/containers/VideoCreateView.js
@@ -19,13 +19,14 @@ class VideoCreate extends Component {
componentWillMount(){
const {albums, history} = this.props
- let facebook_helper = new FacebookHelper(history)
+ let facebook_helper = new FacebookHelper()
facebook_helper.getLoginStatus(function(response){
if(response.status != "connected"){
- history.pushState(null, URL_PREFIX+'/login')
+ history.pushState(null, URL_PREFIX+'login')
}
})
}
+
componentWillUnmount(){
localStorage['picovico'] = JSON.stringify(this.props.albums)
}
diff --git a/containers/VideoListView.js b/containers/VideoListView.js
index 45a7924..f6718f0 100644
--- a/containers/VideoListView.js
+++ b/containers/VideoListView.js
@@ -17,13 +17,13 @@ class VideoList extends Component {
this.state = {'play_video': null}
}
- componentWillMount(){
+ componentDidMount(){
const {videos, history} = this.props
-
- let facebook_helper = new FacebookHelper(history)
+
+ let facebook_helper = new FacebookHelper()
facebook_helper.getLoginStatus(function(response){
if(response.status != "connected"){
- history.pushState(null, URL_PREFIX+'/login')
+ history.pushState(null, URL_PREFIX+'login')
}
})
}
diff --git a/static/bundle.js b/static/bundle.js
index 993d9ea..1c18acb 100644
--- a/static/bundle.js
+++ b/static/bundle.js
@@ -21204,16 +21204,24 @@
var Login = function (_Component) {
_inherits(Login, _Component);
- function Login() {
+ function Login(props) {
_classCallCheck(this, Login);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(Login).apply(this, arguments));
+ var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Login).call(this, props));
+
+ _this.state = { 'show_login_button': false };
+ return _this;
}
_createClass(Login, [{
key: 'componentDidMount',
value: function componentDidMount() {
+ var self = this;
var facebook_helper = new _facebook2.default();
+ facebook_helper.getLoginStatus(function (response) {
+ self.setState({ 'show_login_button': true });
+ localStorage.removeItem('picovico');
+ });
}
}, {
key: 'componentWillUnmount',
@@ -21289,6 +21297,33 @@
return authenticating;
}
}
+ }, {
+ key: 'show_login_button',
+ value: function show_login_button(actions) {
+ var show_btn;
+ if (this.state.show_login_button) {
+ show_btn = _react2.default.createElement(
+ 'div',
+ { className: "col-sm-12 text-center" },
+ _react2.default.createElement(
+ 'a',
+ null,
+ _react2.default.createElement('img', { className: "img-responsive center-block", src: "static/img/facebook.png", style: { marginTop: '50px' }, onClick: function onClick() {
+ return actions.handleLogin(history);
+ } })
+ )
+ );
+ return show_btn;
+ } else {
+ show_btn = _react2.default.createElement(
+ 'div',
+ { className: "col-sm-12 text-center" },
+ _react2.default.createElement('span', { className: "glyphicon glyphicon-refresh glyphicon-refresh-animate", style: { marginTop: '50px' } }),
+ ' Loading ..'
+ );
+ return show_btn;
+ }
+ }
}, {
key: 'render',
value: function render() {
@@ -21329,17 +21364,7 @@
_react2.default.createElement(
'div',
{ className: "row" },
- _react2.default.createElement(
- 'div',
- { className: "col-sm-12 text-center" },
- _react2.default.createElement(
- 'a',
- null,
- _react2.default.createElement('img', { className: "img-responsive center-block", src: "static/img/facebook.png", style: { marginTop: '50px' }, onClick: function onClick() {
- return actions.handleLogin(history);
- } })
- )
- )
+ this.show_login_button(actions)
)
)
)
@@ -21385,6 +21410,7 @@
key: 'initFbScript',
value: function initFbScript() {
if (!this.scriptPromise) {
+
this.scriptPromise = new Promise(function (resolve, reject) {
window.fbAsyncInit = function () {
FB.init({
@@ -21397,17 +21423,15 @@
resolve();
};
- if (typeof FB == 'undefined') {
- (function (d, s, id) {
- var js = void 0,
- fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s);
- js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- })(document, 'script', 'facebook-jssdk');
- }
+ (function (d, s, id) {
+ var js = undefined,
+ fjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(id)) return;
+ js = d.createElement(s);
+ js.id = id;
+ js.src = "//connect.facebook.net/en_US/sdk.js";
+ fjs.parentNode.insertBefore(js, fjs);
+ })(document, 'script', 'facebook-jssdk');
});
}
return this.scriptPromise;
@@ -21415,9 +21439,14 @@
}, {
key: 'getLoginStatus',
value: function getLoginStatus(callback) {
- return this.initFbScript().then(function () {
+
+ if (typeof FB == 'undefined') {
+ return this.initFbScript().then(function () {
+ return FB.getLoginStatus(callback);
+ });
+ } else {
return FB.getLoginStatus(callback);
- });
+ }
}
}]);
@@ -21794,7 +21823,7 @@
}).then(function (response) {
dispatch(list_video());
dispatch({ type: types.FE_COMPLETE_AUTHENTICATING });
- router.pushState(null, _project.URL_PREFIX + '/videos');
+ router.pushState(null, _project.URL_PREFIX + 'videos');
});
});
};
@@ -22021,7 +22050,7 @@
FB.getLoginStatus(function (response) {
if (response.status != "connected") {
- history.pushState(null, _project.URL_PREFIX + '/login');
+ history.pushState(null, _project.URL_PREFIX + 'login');
} else {
var accessToken = response.authResponse.accessToken;
FB.api("/me/videos", "POST", {
@@ -22034,7 +22063,7 @@
/* handle the result */
dispatch({ type: types.FE_FB_VIDEO_SHARING_COMPLETE });
dispatch(complete_share());
- history.pushState(null, _project.URL_PREFIX + '/videos');
+ history.pushState(null, _project.URL_PREFIX + 'videos');
} else {
dispatch(complete_share());
localStorage.removeItem('pv_fb_token');
@@ -22060,9 +22089,9 @@
// localStorage['pv_fb_token'] = JSON.stringify(accessToken)
dispatch(fetchUserInfo(router, accessToken));
} else if (response.status === 'not_authorized') {
- router.pushState(null, _project.URL_PREFIX + '/login');
+ router.pushState(null, _project.URL_PREFIX + 'login');
} else {
- router.pushState(null, _project.URL_PREFIX + '/login');
+ router.pushState(null, _project.URL_PREFIX + 'login');
}
}, { scope: ['user_photos', 'email', 'publish_actions'] });
};
@@ -22103,7 +22132,8 @@
var STYLE = exports.STYLE = "vanilla";
var MUSIC = exports.MUSIC = "https://s3-us-west-2.amazonaws.com/pv-audio-library/free-music/preview/Christmas/Kevin-MacLeod-Christmas-Rap.mp3";
- var URL_PREFIX = exports.URL_PREFIX = "/popcorn";
+ var URL_PREFIX = exports.URL_PREFIX = "/popcorn/";
+ // export const URL_PREFIX = "/"
/***/ },
/* 188 */
@@ -28162,7 +28192,7 @@
{ className: this.state.activeClassKey == "videos" ? "active" : "" },
_react2.default.createElement(
_reactRouter.Link,
- { to: _project.URL_PREFIX + "/videos", onClick: this.handleClick.bind(this, "videos") },
+ { to: _project.URL_PREFIX + "videos", onClick: this.handleClick.bind(this, "videos") },
'My Videos'
)
),
@@ -28171,7 +28201,7 @@
{ className: this.state.activeClassKey == "albums" ? "active" : "" },
_react2.default.createElement(
_reactRouter.Link,
- { to: _project.URL_PREFIX + "/create", onClick: this.handleClick.bind(this, "albums") },
+ { to: _project.URL_PREFIX + "create", onClick: this.handleClick.bind(this, "albums") },
'Select Album'
)
)
@@ -28317,17 +28347,17 @@
}
_createClass(VideoList, [{
- key: 'componentWillMount',
- value: function componentWillMount() {
+ key: 'componentDidMount',
+ value: function componentDidMount() {
var _props = this.props;
var videos = _props.videos;
var history = _props.history;
- var facebook_helper = new _facebook2.default(history);
+ var facebook_helper = new _facebook2.default();
facebook_helper.getLoginStatus(function (response) {
if (response.status != "connected") {
- history.pushState(null, _project.URL_PREFIX + '/login');
+ history.pushState(null, _project.URL_PREFIX + 'login');
}
});
}
@@ -28827,10 +28857,10 @@
var albums = _props.albums;
var history = _props.history;
- var facebook_helper = new _facebook2.default(history);
+ var facebook_helper = new _facebook2.default();
facebook_helper.getLoginStatus(function (response) {
if (response.status != "connected") {
- history.pushState(null, _project.URL_PREFIX + '/login');
+ history.pushState(null, _project.URL_PREFIX + 'login');
}
});
}
diff --git a/static/img/login.jpg b/static/img/login.jpg
deleted file mode 100644
index df2e133..0000000
Binary files a/static/img/login.jpg and /dev/null differ
diff --git a/utils/facebook.js b/utils/facebook.js
index 368a2cf..c8476f0 100644
--- a/utils/facebook.js
+++ b/utils/facebook.js
@@ -4,6 +4,7 @@ class FacebookHelper {
initFbScript() {
if(!this.scriptPromise) {
+
this.scriptPromise = new Promise((resolve, reject) => {
window.fbAsyncInit = () => {
FB.init({
@@ -16,7 +17,6 @@ class FacebookHelper {
resolve();
};
- if (typeof(FB) == 'undefined') {
((d, s, id) => {
let js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
@@ -25,14 +25,19 @@ class FacebookHelper {
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'facebook-jssdk');
- }
})
}
return this.scriptPromise;
}
getLoginStatus(callback) {
- return this.initFbScript().then(() => FB.getLoginStatus(callback));
+
+ if (typeof(FB) == 'undefined') {
+ return this.initFbScript().then(() => FB.getLoginStatus(callback));
+ }else{
+ return FB.getLoginStatus(callback)
+ }
+
}
}