Skip to content

Commit ab89d5f

Browse files
author
Stefania
committed
improved not supported from chromeOs, removed legacy file
1 parent fbf7400 commit ab89d5f

File tree

5 files changed

+41
-395
lines changed

5 files changed

+41
-395
lines changed

src/chrome-app-daemon.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,18 @@ export default class ChromeOsDaemon extends Daemon {
247247
data: file.data,
248248
};
249249

250-
window.oauth.token().then(token => {
251-
payload.token = token.token;
252-
this.channel.postMessage({
253-
command: 'upload',
254-
data: payload
250+
try {
251+
window.oauth.token().then(token => {
252+
payload.token = token.token;
253+
this.channel.postMessage({
254+
command: 'upload',
255+
data: payload
256+
});
255257
});
256-
});
257-
}
258-
259-
/**
260-
* Download tool - not supported in Chrome app
261-
*/
262-
downloadTool() {
263-
return new Error('Download Tool not supported on Chrome OS');
264-
}
265-
266-
/**
267-
* Interrupt upload - not supported in Chrome app
268-
*/
269-
stopUpload() {
270-
return new Error('Stop Upload not supported on Chrome OS');
258+
}
259+
catch (err) {
260+
this.uploading.next({ status: UPLOAD_ERROR, err: 'you need to be logged in on a Create site to upload by Chrome App' });
261+
alert();
262+
}
271263
}
272264
}

src/daemon.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,30 @@ export default class Daemon {
5656
}
5757
return a.every((item, index) => (b[index].Name === item.Name && b[index].IsOpen === item.IsOpen));
5858
}
59+
60+
/**
61+
* Download tool - not supported in Chrome app
62+
* @param {string} toolName
63+
* @param {string} toolVersion
64+
* @param {string} packageName
65+
* @param {string} replacementStrategy
66+
*/
67+
downloadTool(toolName, toolVersion, packageName, replacementStrategy = 'keep') {
68+
if (typeof this.downloadToolCommand === 'function') {
69+
this.downloadToolCommand(toolName, toolVersion, packageName, replacementStrategy);
70+
}
71+
else {
72+
throw new Error('Download Tool not supported on Chrome OS');
73+
}
74+
}
75+
76+
/**
77+
* Interrupt upload - not supported in Chrome app
78+
*/
79+
stopUpload() {
80+
if (typeof this.stopUploadCommand === 'function') {
81+
this.stopUploadCommand();
82+
}
83+
throw new Error('Stop Upload not supported on Chrome OS');
84+
}
5985
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
import SocketDaemon from './socket-daemon';
3131
import ChromeOsDaemon from './chrome-app-daemon';
3232

33-
const Daemon = true ? ChromeOsDaemon : SocketDaemon;
33+
const Daemon = window.navigator.userAgent.indexOf(' CrOS ') !== -1 ? ChromeOsDaemon : SocketDaemon;
3434

3535
export default Daemon;

0 commit comments

Comments
 (0)