fixed android login. closes #1199
This commit is contained in:
parent
2b53b76fed
commit
d101a76962
|
@ -18,6 +18,7 @@ import share from './pages/share';
|
||||||
import preferences from './pages/preferences';
|
import preferences from './pages/preferences';
|
||||||
import error from './pages/error';
|
import error from './pages/error';
|
||||||
import { getTranslator } from '../app/locale';
|
import { getTranslator } from '../app/locale';
|
||||||
|
import { delay } from '../app/utils';
|
||||||
|
|
||||||
if (navigator.userAgent === 'Send Android') {
|
if (navigator.userAgent === 'Send Android') {
|
||||||
setApiUrlPrefix('https://send2.dev.lcip.org');
|
setApiUrlPrefix('https://send2.dev.lcip.org');
|
||||||
|
@ -28,6 +29,15 @@ const app = choo();
|
||||||
app.use(controller);
|
app.use(controller);
|
||||||
app.use(intents);
|
app.use(intents);
|
||||||
|
|
||||||
|
window.finishLogin = async function(accountInfo) {
|
||||||
|
while (!(app.state && app.state.user)) {
|
||||||
|
await delay();
|
||||||
|
}
|
||||||
|
await app.state.user.finishLogin(accountInfo);
|
||||||
|
await app.state.user.syncFileList();
|
||||||
|
app.emitter.emit('replaceState', '/');
|
||||||
|
};
|
||||||
|
|
||||||
function body(main) {
|
function body(main) {
|
||||||
return function(state, emit) {
|
return function(state, emit) {
|
||||||
/*
|
/*
|
||||||
|
@ -59,7 +69,7 @@ function body(main) {
|
||||||
(async function start() {
|
(async function start() {
|
||||||
const translate = await getTranslator('en-US');
|
const translate = await getTranslator('en-US');
|
||||||
const { LIMITS, DEFAULTS } = await getConstants();
|
const { LIMITS, DEFAULTS } = await getConstants();
|
||||||
app.use((state, emitter) => {
|
app.use(state => {
|
||||||
state.LIMITS = LIMITS;
|
state.LIMITS = LIMITS;
|
||||||
state.DEFAULTS = DEFAULTS;
|
state.DEFAULTS = DEFAULTS;
|
||||||
state.translate = translate;
|
state.translate = translate;
|
||||||
|
@ -68,18 +78,10 @@ function body(main) {
|
||||||
}; //TODO
|
}; //TODO
|
||||||
state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS);
|
state.archive = new Archive([], DEFAULTS.EXPIRE_SECONDS);
|
||||||
state.storage = storage;
|
state.storage = storage;
|
||||||
state.user = new User(storage, LIMITS);
|
state.user = new User(storage, LIMITS, {
|
||||||
|
issuer: 'https://accounts.firefox.com'
|
||||||
|
});
|
||||||
state.raven = Raven;
|
state.raven = Raven;
|
||||||
|
|
||||||
window.finishLogin = async function(accountInfo) {
|
|
||||||
await state.user.finishLogin(accountInfo);
|
|
||||||
await state.user.syncFileList();
|
|
||||||
emitter.emit('replaceState', '/');
|
|
||||||
};
|
|
||||||
|
|
||||||
// for debugging
|
|
||||||
window.appState = state;
|
|
||||||
window.appEmit = emitter.emit.bind(emitter);
|
|
||||||
});
|
});
|
||||||
app.use(metrics);
|
app.use(metrics);
|
||||||
app.route('/', body(home));
|
app.route('/', body(home));
|
||||||
|
@ -91,3 +93,5 @@ function body(main) {
|
||||||
// add /api/filelist
|
// add /api/filelist
|
||||||
app.mount('body');
|
app.mount('body');
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
window.app = app;
|
||||||
|
|
Loading…
Reference in New Issue