mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-23 22:12:19 +03:00
Online / offline state update
This commit is contained in:
parent
053a8bf11c
commit
05ed70d586
@ -48,6 +48,7 @@ export default class ApplicationPage extends React.Component {
|
||||
data: null,
|
||||
sidebar: null,
|
||||
sidebarLoading: false,
|
||||
online: null,
|
||||
};
|
||||
|
||||
async componentDidMount() {
|
||||
@ -55,6 +56,9 @@ export default class ApplicationPage extends React.Component {
|
||||
window.addEventListener("dragleave", this._handleDragLeave);
|
||||
window.addEventListener("dragover", this._handleDragOver);
|
||||
window.addEventListener("drop", this._handleDrop);
|
||||
|
||||
window.addEventListener("online", this._handleOnlineStatus);
|
||||
window.addEventListener("offline", this._handleOnlineStatus);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -64,11 +68,19 @@ export default class ApplicationPage extends React.Component {
|
||||
window.removeEventListener("drop", this._handleDrop);
|
||||
}
|
||||
|
||||
_handleOnlineStatus = async () => {
|
||||
window.alert(navigator.onLine ? "online" : "offline");
|
||||
this.setState({ online: navigator.onLine });
|
||||
};
|
||||
|
||||
_handleSetFile = async ({ file, slate }) => {
|
||||
//
|
||||
console.log(file);
|
||||
this.setState({ fileLoading: true });
|
||||
|
||||
let data = new FormData();
|
||||
data.append("data", file);
|
||||
data.append("image", file);
|
||||
console.log(data);
|
||||
|
||||
const options = {
|
||||
method: "POST",
|
||||
@ -241,7 +253,8 @@ export default class ApplicationPage extends React.Component {
|
||||
_handleDeleteYourself = async () => {
|
||||
// TODO(jim):
|
||||
// Put this somewhere better for messages.
|
||||
const message = "Do you really want to delete your account? It will be permanently removed";
|
||||
const message =
|
||||
"Do you really want to delete your account? It will be permanently removed";
|
||||
if (!window.confirm(message)) {
|
||||
return false;
|
||||
}
|
||||
@ -441,8 +454,12 @@ export default class ApplicationPage extends React.Component {
|
||||
<WebsitePrototypeWrapper
|
||||
title="Slate: sign in"
|
||||
description="Sign in to your Slate account to manage your assets."
|
||||
url="https://slate.host/application">
|
||||
<SceneSignIn onAuthenticate={this._handleAuthenticate} onNavigateTo={this._handleNavigateTo} />
|
||||
url="https://slate.host/application"
|
||||
>
|
||||
<SceneSignIn
|
||||
onAuthenticate={this._handleAuthenticate}
|
||||
onNavigateTo={this._handleNavigateTo}
|
||||
/>
|
||||
</WebsitePrototypeWrapper>
|
||||
);
|
||||
}
|
||||
@ -515,12 +532,17 @@ export default class ApplicationPage extends React.Component {
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<WebsitePrototypeWrapper title={title} description={description} url={url}>
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description={description}
|
||||
url={url}
|
||||
>
|
||||
<ApplicationLayout
|
||||
navigation={navigationElement}
|
||||
header={headerElement}
|
||||
sidebar={sidebarElement}
|
||||
onDismissSidebar={this._handleDismissSidebar}>
|
||||
onDismissSidebar={this._handleDismissSidebar}
|
||||
>
|
||||
{scene}
|
||||
</ApplicationLayout>
|
||||
</WebsitePrototypeWrapper>
|
||||
|
@ -4,9 +4,10 @@ const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
|
||||
// NOTE(colin): use NEXTJS Production build
|
||||
process.env.NODE_ENV = "production";
|
||||
if (process.env.NODE_ENV == undefined) process.env.NODE_ENV = "production";
|
||||
// NOTE(colin): allow API connection
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
|
||||
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED == undefined)
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
|
||||
|
||||
function bootServer() {
|
||||
// TODO(colin): Spin up server on a child process
|
||||
|
@ -8,11 +8,9 @@
|
||||
"start": "NODE_ENV=production node . --unhandled-rejections=strict",
|
||||
"build-delete": "rm -rf .next && rm -rf dist/mac",
|
||||
"build": "NODE_ENV=production next build",
|
||||
"build-electron": "NODE_ENV=production next build",
|
||||
"build-system": "rollup -c",
|
||||
"electron": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron ./electron/main.js ",
|
||||
"electron-pack": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron-builder --dir",
|
||||
"electron-dist": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron-builder",
|
||||
"electron-dev": "NODE_ENV=development electron ./electron/main.js ",
|
||||
"electron-prod": "NODE_ENV=production next build && electron-builder --dir",
|
||||
"scripts": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts",
|
||||
"www-setup-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts setup-database",
|
||||
"www-seed-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts seed-database",
|
||||
|
Loading…
Reference in New Issue
Block a user