Skip to content

Commit 765aa3c

Browse files
committed
used new context
1 parent e986cdd commit 765aa3c

22 files changed

+289
-333
lines changed

package.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-facebook",
3-
"version": "5.0.3",
3+
"version": "6.0.3",
44
"description": "Facebook components like a Login button, Like, Share, Comments, Embedded Post/Video, Messenger Chat and others",
55
"author": {
66
"name": "Zlatko Fedor",
@@ -56,40 +56,39 @@
5656
]
5757
},
5858
"dependencies": {
59-
"debug": "^3.1.0",
59+
"debug": "^4.0.1",
6060
"react-spinner-children": "^1.0.8",
6161
"can-use-dom": "^0.1.0",
62-
"prop-types": "^15.6.1",
6362
"babel-runtime": "^6.26.0"
6463
},
6564
"devDependencies": {
6665
"babel-cli": "^6.26.0",
67-
"babel-core": "^6.26.0",
68-
"babel-eslint": "^8.2.2",
66+
"babel-core": "^6.26.3",
67+
"babel-eslint": "^10.0.1",
6968
"babel-plugin-transform-flow-strip-types": "6.22.0",
70-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
69+
"babel-plugin-transform-decorators-legacy": "^1.3.5",
7170
"babel-plugin-transform-class-properties": "^6.24.1",
7271
"babel-plugin-transform-proto-to-assign": "^6.26.0",
73-
"babel-preset-env": "^1.6.1",
72+
"babel-preset-env": "^1.7.0",
7473
"babel-preset-react": "^6.24.1",
7574
"babel-preset-stage-0": "^6.24.1",
7675
"babel-plugin-transform-runtime": "^6.23.0",
77-
"cross-env": "^5.1.4",
78-
"eslint": "^4.19.1",
79-
"eslint-config-airbnb": "^16.1.0",
80-
"eslint-loader": "^2.0.0",
81-
"eslint-plugin-react": "^7.7.0",
82-
"eslint-plugin-jsx-a11y": "^6.0.3",
83-
"eslint-plugin-import": "^2.9.0",
84-
"jest": "^22.4.3",
85-
"jest-cli": "^22.4.3",
86-
"enzyme": "^3.3.0",
87-
"enzyme-adapter-react-16": "^1.1.1",
88-
"react": "^16.2.0",
89-
"react-dom": "^16.2.0",
90-
"react-test-renderer": "^16.2.0"
76+
"cross-env": "^5.2.0",
77+
"eslint": "^5.6.1",
78+
"eslint-config-airbnb": "^17.1.0",
79+
"eslint-loader": "^2.1.1",
80+
"eslint-plugin-react": "^7.11.1",
81+
"eslint-plugin-jsx-a11y": "^6.1.1",
82+
"eslint-plugin-import": "^2.14.0",
83+
"jest": "^23.6.0",
84+
"jest-cli": "^23.6.0",
85+
"enzyme": "^3.6.0",
86+
"enzyme-adapter-react-16": "^1.5.0",
87+
"react": "^16.5.2",
88+
"react-dom": "^16.5.2",
89+
"react-test-renderer": "^16.5.2"
9190
},
9291
"peerDependencies": {
93-
"react": "15.x || 16.x"
92+
"react": "16.x"
9493
}
9594
}

src/Comments.jsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
// @flow
2-
import React from 'react';
3-
import type { Node } from 'react';
4-
import Parser from './Parser';
2+
import React, { type Node } from 'react';
3+
import Parser, { type ParserProps } from './Parser';
54
import getCurrentHref from './utils/getCurrentHref';
6-
import ColorScheme from './constants/ColorScheme';
7-
import CommentsOrderBy from './constants/CommentsOrderBy';
85

9-
type Props = {
10-
className?: string,
6+
type Props = ParserProps & {
117
href?: string,
128
numPosts?: number,
139
orderBy?: string,
1410
width?: number | string,
1511
colorScheme?: string,
1612
children?: Node,
17-
onParse?: Function,
1813
mobile?: boolean,
1914
};
2015

2116
export default function Comments(props: Props) {
2217
const {
23-
className,
2418
colorScheme,
2519
href = getCurrentHref(),
2620
numPosts,
2721
orderBy,
2822
width,
2923
children,
30-
onParse,
3124
mobile,
25+
...rest
3226
} = props;
3327

3428
return (
35-
<Parser className={className} onParse={onParse}>
29+
<Parser {...rest}>
3630
<div
3731
className="fb-comments"
3832
data-colorscheme={colorScheme}
@@ -50,13 +44,12 @@ export default function Comments(props: Props) {
5044
}
5145

5246
Comments.defaultProps = {
47+
...Parser.defaultProps,
5348
href: undefined,
5449
numPosts: undefined,
5550
orderBy: undefined,
5651
width: undefined,
5752
colorScheme: undefined,
5853
children: undefined,
59-
className: undefined,
60-
onParse: undefined,
6154
mobile: undefined,
6255
};

src/CommentsCount.jsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
// @flow
2-
import React from 'react';
3-
import type { Node } from 'react';
4-
import Parser from './Parser';
2+
import React, { type Node } from 'react';
3+
import Parser, { type ParserProps } from './Parser';
54
import getCurrentHref from './utils/getCurrentHref';
65

7-
type Props = {
8-
className?: string,
6+
type Props = ParserProps & {
97
href?: string,
108
children?: Node,
11-
onParse?: Function,
129
};
1310

1411
export default function CommentsCount(props: Props) {
1512
const {
16-
className,
1713
href = getCurrentHref(),
1814
children,
19-
onParse,
15+
...rest
2016
} = props;
2117

2218
return (
23-
<Parser className={className} onParse={onParse}>
19+
<Parser {...rest}>
2420
<span
2521
className="fb-comments-count"
2622
data-href={href}
@@ -32,8 +28,7 @@ export default function CommentsCount(props: Props) {
3228
}
3329

3430
CommentsCount.defaultProps = {
35-
className: undefined,
31+
...Parser.defaultProps,
3632
href: undefined,
3733
children: undefined,
38-
onParse: undefined,
3934
};

src/CustomChat.jsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
// @flow
2-
import React from 'react';
3-
import type { Node } from 'react';
4-
import Parser from './Parser';
2+
import React, { type Node } from 'react';
3+
import Parser, { type ParserProps } from './Parser';
54

6-
type Props = {
7-
className?: string,
5+
type Props = ParserProps & {
86
pageId: string,
97
minimized?: boolean,
10-
onParse?: Function,
118
children?: Node,
129
themeColor?: string,
1310
loggedInGreeting?: string,
@@ -17,19 +14,18 @@ type Props = {
1714

1815
export default function CustomChat(props: Props) {
1916
const {
20-
className,
2117
minimized,
2218
children,
2319
pageId,
24-
onParse,
2520
themeColor,
2621
loggedInGreeting,
2722
loggedOutGreeting,
2823
dataRef,
24+
...rest
2925
} = props;
3026

3127
return (
32-
<Parser className={className} onParse={onParse}>
28+
<Parser {...rest}>
3329
<div
3430
className="fb-customerchat"
3531
page_id={pageId}
@@ -46,10 +42,9 @@ export default function CustomChat(props: Props) {
4642
}
4743

4844
CustomChat.defaultProps = {
45+
...Parser.defaultProps,
4946
minimized: undefined,
5047
children: undefined,
51-
className: undefined,
52-
onParse: undefined,
5348
themeColor: undefined,
5449
loggedInGreeting: undefined,
5550
loggedOutGreeting: undefined,

src/EmbeddedPost.jsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
// @flow
2-
import React from 'react';
3-
import type { Node } from 'react';
4-
import Parser from './Parser';
2+
import React, { type Node } from 'react';
3+
import Parser, { type ParserProps } from './Parser';
54

6-
type Props = {
7-
className?: string,
5+
type Props = ParserProps & {
86
href: string,
97
width?: string | number,
108
showText?: boolean,
119
children?: Node,
12-
onParse?: Function,
1310
};
1411

1512
export default function EmbeddedPost(props: Props) {
1613
const {
17-
className,
1814
href,
1915
width,
2016
showText,
2117
children,
22-
onParse,
18+
...rest
2319
} = props;
2420

2521
return (
26-
<Parser className={className} onParse={onParse}>
22+
<Parser {...rest}>
2723
<div
2824
className="fb-post"
2925
data-href={href}
@@ -37,9 +33,8 @@ export default function EmbeddedPost(props: Props) {
3733
}
3834

3935
EmbeddedPost.defaultProps = {
36+
...Parser.defaultProps,
4037
width: undefined,
4138
showText: undefined,
4239
children: undefined,
43-
className: undefined,
44-
onParse: undefined,
4540
};

src/EmbeddedVideo.jsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// @flow
2-
import React from 'react';
3-
import type { Node } from 'react';
4-
import Parser from './Parser';
2+
import React, { type Node } from 'react';
3+
import Parser, { type ParserProps } from './Parser';
54

6-
type Props = {
5+
type Props = ParserProps & {
76
className?: string,
87
href: string,
98
width?: number | string,
@@ -17,19 +16,18 @@ type Props = {
1716

1817
export default function EmbeddedVideo(props: Props): Node {
1918
const {
20-
className,
2119
href,
2220
width,
2321
showText,
2422
allowFullScreen,
2523
autoPlay,
2624
showCaptions,
2725
children,
28-
onParse,
26+
...rest
2927
} = props;
3028

3129
return (
32-
<Parser className={className} onParse={onParse}>
30+
<Parser {...rest}>
3331
<div
3432
className="fb-video"
3533
data-href={href}
@@ -46,12 +44,11 @@ export default function EmbeddedVideo(props: Props): Node {
4644
}
4745

4846
EmbeddedVideo.defaultProps = {
47+
...Parser.defaultProps,
4948
width: undefined,
5049
showText: undefined,
5150
allowFullScreen: undefined,
5251
autoPlay: undefined,
5352
showCaptions: undefined,
5453
children: undefined,
55-
className: undefined,
56-
onParse: undefined,
5754
};

src/Facebook.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class Facebook {
1717
constructor(options = {}) {
1818
this.options = {
1919
domain: 'connect.facebook.net',
20-
version: 'v2.9',
20+
version: 'v3.1',
2121
cookie: false,
2222
status: false,
2323
xfbml: false,
@@ -60,17 +60,17 @@ export default class Facebook {
6060
resolve(window.FB);
6161
};
6262

63-
const fjs = document.getElementsByTagName('script')[0];
63+
const fjs = window.document.getElementsByTagName('script')[0];
6464
if (!fjs) {
6565
log('Script tag does not exists in the DOM');
6666
return;
6767
}
6868

69-
if (document.getElementById('facebook-jssdk')) {
69+
if (window.document.getElementById('facebook-jssdk')) {
7070
return;
7171
}
7272

73-
const js = document.createElement('script');
73+
const js = window.document.createElement('script');
7474
js.id = 'facebook-jssdk';
7575
js.async = true;
7676
js.src = `https://${options.domain}/${options.language}/sdk.js`;
@@ -181,10 +181,12 @@ export default class Facebook {
181181
const usersPermissions = await this.getPermissions();
182182

183183
const findedPermissions = permissions.filter((p) => {
184-
return !!usersPermissions.find((row) => {
184+
const currentPermission = usersPermissions.find((row) => {
185185
const { permission, status } = row;
186186
return status === 'granted' && permission === p;
187187
});
188+
189+
return !!currentPermission;
188190
});
189191

190192
return findedPermissions.length === permissions.length;
@@ -324,7 +326,7 @@ export default class Facebook {
324326
return callback(err);
325327
}
326328
327-
var fqlQuery = 'SELECT uid FROM page_fan WHERE page_id = ' + pageID + ' and uid = '+ userID;
329+
var fqlQuery = `SELECT uid FROM page_fan WHERE page_id = ${pageID} and uid = ${userID}`;
328330
var query = FB.Data.query(fqlQuery);
329331
330332
query.wait(function(rows) {
@@ -384,7 +386,14 @@ export default class Facebook {
384386
return callback(err);
385387
}
386388
387-
FB.api('fql', { q: 'SELECT uid, name, first_name, last_name, online_presence, status FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name' }, function (response)
389+
FB.api('fql', {
390+
q: `
391+
SELECT uid, name, first_name, last_name, online_presence, status
392+
FROM user
393+
WHERE uid IN
394+
( SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name
395+
`,
396+
}, function (response)
388397
{
389398
var users = fbApi._prepareUsers(response.data);
390399
callback(null, users, response);

0 commit comments

Comments
 (0)