MCPcopy
hub / github.com/gitalk/gitalk / constructor

Method constructor

src/gitalk.jsx:50–148  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

48 errorMsg: '',
49 }
50 constructor (props) {
51 super(props)
52 this.options = Object.assign({}, {
53 id: window.location.href,
54 number: -1,
55 labels: ['Gitalk'],
56 title: window.document.title,
57 body: '', // window.location.href + header.meta[description]
58 language: window.navigator.language || window.navigator.userLanguage,
59 perPage: 10,
60 pagerDirection: 'last', // last or first
61 createIssueManually: false,
62 distractionFreeMode: false,
63 proxy: 'https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token',
64 flipMoveOptions: {
65 staggerDelayBy: 150,
66 appearAnimation: 'accordionVertical',
67 enterAnimation: 'accordionVertical',
68 leaveAnimation: 'accordionVertical',
69 },
70 enableHotKey: true,
71
72 url: window.location.href,
73
74 defaultAuthor: {
75 avatarUrl: '//avatars1.githubusercontent.com/u/29697133?s=50',
76 login: 'null',
77 url: '',
78 },
79
80 updateCountCallback: null
81 }, props.options)
82
83 this.state.pagerDirection = this.options.pagerDirection
84 const storedComment = window.localStorage.getItem(GT_COMMENT)
85 if (storedComment) {
86 this.state.comment = decodeURIComponent(storedComment)
87 window.localStorage.removeItem(GT_COMMENT)
88 }
89
90 const query = queryParse()
91 if (query.code) {
92 const code = query.code
93 delete query.code
94 const replacedUrl = `${window.location.origin}${window.location.pathname}${queryStringify(query)}${window.location.hash}`
95 history.replaceState(null, null, replacedUrl)
96 this.options = Object.assign({}, this.options, {
97 url: replacedUrl,
98 id: replacedUrl
99 }, props.options)
100
101 axiosJSON.post(this.options.proxy, {
102 code,
103 client_id: this.options.clientID,
104 client_secret: this.options.clientSecret
105 }).then(res => {
106 if (res.data && res.data.access_token) {
107 this.accessToken = res.data.access_token

Callers

nothing calls this directly

Calls 4

getInitMethod · 0.95
queryParseFunction · 0.90
queryStringifyFunction · 0.90
formatErrorMsgFunction · 0.90

Tested by

no test coverage detected