Completed
Push — master ( 2f8415...e6e0b0 )
by Rain
02:22
created

dev/Settings/User/Social.js   A

Size

Lines of Code 67

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
nc 1
dl 0
loc 67
rs 10
noi 0
1
2
import SocialStore from 'Stores/Social';
3
4
import {getApp} from 'Helper/Apps/User';
5
6
import {command} from 'Knoin/Knoin';
7
8
class SocialUserSettings
9
{
10
	constructor() {
11
		this.googleEnable = SocialStore.google.enabled;
12
		this.googleEnableAuth = SocialStore.google.capa.auth;
13
		this.googleEnableAuthFast = SocialStore.google.capa.authFast;
14
		this.googleEnableDrive = SocialStore.google.capa.drive;
15
		this.googleEnablePreview = SocialStore.google.capa.preview;
16
17
		this.googleActions = SocialStore.google.loading;
18
		this.googleLoggined = SocialStore.google.loggined;
19
		this.googleUserName = SocialStore.google.userName;
20
21
		this.facebookEnable = SocialStore.facebook.enabled;
22
23
		this.facebookActions = SocialStore.facebook.loading;
24
		this.facebookLoggined = SocialStore.facebook.loggined;
25
		this.facebookUserName = SocialStore.facebook.userName;
26
27
		this.twitterEnable = SocialStore.twitter.enabled;
28
29
		this.twitterActions = SocialStore.twitter.loading;
30
		this.twitterLoggined = SocialStore.twitter.loggined;
31
		this.twitterUserName = SocialStore.twitter.userName;
32
	}
33
34
	@command((self) => !self.googleLoggined() && !self.googleActions())
35
	connectGoogleCommand() {
36
		if (!this.googleLoggined())
37
		{
38
			getApp().googleConnect();
39
		}
40
	}
41
42
	@command()
43
	disconnectGoogleCommand() {
44
		getApp().googleDisconnect();
45
	}
46
47
	@command((self) => !self.facebookLoggined() && !self.facebookActions())
48
	connectFacebookCommand() {
49
		if (!this.facebookLoggined())
50
		{
51
			getApp().facebookConnect();
52
		}
53
	}
54
55
	@command()
56
	disconnectFacebookCommand() {
57
		getApp().facebookDisconnect();
58
	}
59
60
	@command((self) => !self.twitterLoggined() && !self.twitterActions())
61
	connectTwitterCommand() {
62
		if (!this.twitterLoggined())
63
		{
64
			getApp().twitterConnect();
65
		}
66
	}
67
68
	@command()
69
	disconnectTwitterCommand() {
70
		getApp().twitterDisconnect();
71
	}
72
}
73
74
export {SocialUserSettings, SocialUserSettings as default};
75