Skip to content

Commit de3f661

Browse files
authored
Merge pull request #161 from codeitcodes/dev
Dev
2 parents 10f0079 + 3d1a46c commit de3f661

File tree

5 files changed

+78
-17
lines changed

5 files changed

+78
-17
lines changed

filebrowser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ async function renderSidebarHTML() {
193193
resp = await git.getItems(treeLoc);
194194

195195

196-
if (resp.message == 'Not Found') {
196+
if (resp.message && resp.message == 'Not Found') {
197197

198198
// if couldn't find repository, show not found screen
199199

@@ -323,7 +323,7 @@ async function renderSidebarHTML() {
323323

324324
}
325325

326-
if (resp.message == 'Bad credentials') {
326+
if (resp.message && resp.message == 'Bad credentials') {
327327

328328
// if failed to get items,
329329
// show login screen

git/gitauth.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,16 @@ window.onload = async () => {
6363

6464

6565
loginButton.addEventListener('click', () => {
66-
67-
window.open('https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org', 'Login with Github', 'height=575,width=575');
66+
67+
if (isMobile) {
68+
69+
window.location.href = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
70+
71+
} else {
72+
73+
window.open('https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org', 'Login with Github', 'height=575,width=575');
74+
75+
}
6876

6977
})
7078

@@ -101,9 +109,39 @@ window.onload = async () => {
101109
}
102110

103111
})
112+
113+
114+
loadLS();
115+
116+
117+
// if git code exists in link
118+
if (linkData.gitCode) {
119+
120+
// hide intro screen
121+
sidebar.classList.remove('intro');
104122

123+
// if on safari, refresh header color
124+
if (isSafari) {
105125

106-
loadLS();
126+
document.querySelector('meta[name="theme-color"]').content = '#313744';
127+
128+
onNextFrame(() => {
129+
130+
document.querySelector('meta[name="theme-color"]').content = '#1a1c24';
131+
132+
});
133+
134+
}
135+
136+
// start loading
137+
startLoading();
138+
139+
const gitCode = linkData.gitCode;
140+
141+
// get git token from Github
142+
getGithubToken(gitCode);
143+
144+
}
107145

108146
}
109147

git/login.html

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,37 @@
33

44
const code = window.location.toString().replace(/.+code=/, '');
55

6-
try {
7-
8-
// check for cross-origin frame
9-
console.log(window.opener.location.href);
6+
let isMobile = false;
7+
8+
if (navigator.userAgentData
9+
&& navigator.userAgentData.mobile) isMobile = true;
10+
11+
if (navigator.userAgent
12+
&& navigator.userAgent.includes('Mobile')) isMobile = true;
13+
14+
15+
if (!isMobile) {
1016

11-
// post login token to opening window
12-
window.opener.postMessage(code, window.location);
13-
window.close();
17+
try {
18+
19+
// check for cross-origin frame
20+
console.log(window.opener.location.href);
21+
22+
// post login token to opening window
23+
window.opener.postMessage(code, window.location);
24+
window.close();
25+
26+
} catch(e) {
27+
28+
// if cannot access opening window (window is cross-origin)
29+
// redirect to dev version and try posting login token from there
30+
window.location.href = window.location.protocol + '//' + 'dev.' + window.location.host + window.location.pathname + window.location.search;
31+
32+
}
1433

15-
} catch(e) {
34+
} else {
1635

17-
// if cannot access opening window (window is cross-origin)
18-
// redirect to dev version and try posting login token from there
19-
window.location.href = window.location.protocol + '//' + 'dev.' + window.location.host + window.location.pathname + window.location.search;
36+
window.location.href = '/full?gitCode=' + code;
2037

2138
}
2239

links.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ function decodeLink(url) {
111111

112112
}
113113

114+
if (link.get('gitCode')) {
115+
116+
linkData.gitCode = link.get('gitCode');
117+
118+
}
119+
114120

115121

116122
// legacy link type

worker/client-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
// update worker name when updating worker
7-
const WORKER_NAME = 'codeit-worker-v525';
7+
const WORKER_NAME = 'codeit-worker-v526';
88

99

1010
// internal paths

0 commit comments

Comments
 (0)