mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Some extra error handling
This commit is contained in:
parent
e380a4d2b1
commit
f1dd218944
@ -137,7 +137,10 @@ export async function pushActiveDirtyResources (resourceGroupId = null) {
|
||||
|
||||
// Resolve conflicts
|
||||
for (const serverResource of conflicts) {
|
||||
const localResource = await store.getResourceByDocId(serverResource.id);
|
||||
const localResource = await store.getResourceByDocId(
|
||||
serverResource.id,
|
||||
serverResource.resourceGroupId
|
||||
);
|
||||
|
||||
// On conflict, choose last edited one
|
||||
const serverIsNewer = serverResource.lastEdited > localResource.lastEdited;
|
||||
@ -268,7 +271,10 @@ export async function pull (resourceGroupId = null, createMissingResources = tru
|
||||
await db.update(doc, true);
|
||||
|
||||
// Update local resource
|
||||
const resource = await store.getResourceByDocId(serverResource.id);
|
||||
const resource = await store.getResourceByDocId(
|
||||
serverResource.id,
|
||||
serverResource.resourceGroupId
|
||||
);
|
||||
await store.updateResource(resource, serverResource, {dirty: false});
|
||||
} catch (e) {
|
||||
logger.warn('Failed to decode updated resource', e, serverResource);
|
||||
@ -402,6 +408,7 @@ async function _queueChange (event, doc) {
|
||||
// TODO: Remove one of these steps since it does encryption twice
|
||||
// in the case where the resource does not exist yet
|
||||
const resource = await getOrCreateResourceForDoc(doc);
|
||||
|
||||
const updatedResource = await store.updateResource(resource, {
|
||||
name: doc.name || 'n/a',
|
||||
lastEdited: timestamp,
|
||||
@ -620,7 +627,11 @@ async function _getOrCreateAllActiveResources (resourceGroupId = null) {
|
||||
for (const doc of await db.all(type)) {
|
||||
const resource = await store.getResourceByDocId(doc._id);
|
||||
if (!resource) {
|
||||
try {
|
||||
activeResourceMap[doc._id] = await _createResourceForDoc(doc);
|
||||
} catch (e) {
|
||||
logger.error(`Failed to create resource for ${doc._id}`, doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,15 @@ export async function findResourcesForResourceGroup (resourceGroupId) {
|
||||
return findResources({resourceGroupId});
|
||||
}
|
||||
|
||||
export async function getResourceByDocId (id) {
|
||||
const rawDocs = await _execDB(TYPE_RESOURCE, 'find', {id});
|
||||
export async function getResourceByDocId (id, resourceGroupId = null) {
|
||||
let query;
|
||||
if (resourceGroupId) {
|
||||
query = {id, resourceGroupId};
|
||||
} else {
|
||||
query = {id};
|
||||
}
|
||||
|
||||
const rawDocs = await _execDB(TYPE_RESOURCE, 'find', query);
|
||||
return rawDocs.length >= 1 ? rawDocs[0] : null;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,10 @@ class LoginModal extends Component {
|
||||
await session.login(email, password);
|
||||
|
||||
// Clear all existing sync data that might be there and enable sync
|
||||
process.nextTick(async () => {
|
||||
await sync.resetLocalData();
|
||||
sync.doInitialSync();
|
||||
await sync.doInitialSync();
|
||||
});
|
||||
|
||||
this.setState({step: 2, loading: false});
|
||||
} catch (e) {
|
||||
@ -60,8 +62,8 @@ class LoginModal extends Component {
|
||||
const {step, title, message} = this.state;
|
||||
if (step === 1) {
|
||||
return (
|
||||
<Modal ref={m => this.modal = m} {...this.props}>
|
||||
<form onSubmit={this._handleLogin.bind(this)}>
|
||||
<Modal ref={m => this.modal = m} {...this.props}>
|
||||
<ModalHeader>{title || "Login to Your Account"}</ModalHeader>
|
||||
<ModalBody className="pad changelog">
|
||||
{message ? (
|
||||
@ -96,12 +98,13 @@ class LoginModal extends Component {
|
||||
<a href="#" onClick={this._handleSignup.bind(this)}>Signup</a>
|
||||
</div>
|
||||
<button type="submit" className="btn">
|
||||
{this.state.loading ? <i className="fa fa-spin fa-refresh margin-right-sm"></i> : null}
|
||||
{this.state.loading ? <i
|
||||
className="fa fa-spin fa-refresh margin-right-sm"></i> : null}
|
||||
Login
|
||||
</button>
|
||||
</ModalFooter>
|
||||
</form>
|
||||
</Modal>
|
||||
</form>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
|
@ -165,22 +165,6 @@ class SyncModal extends Component {
|
||||
</Tab>
|
||||
</TabList>
|
||||
<TabPanel className="pad scrollable">
|
||||
<div className="pad-top">
|
||||
<GravatarImg email={this.state.email}
|
||||
className="inline-block img--circle"
|
||||
size={50}/>
|
||||
<div className="inline-block pad-left">
|
||||
<h2 className="no-pad-bottom no-margin">
|
||||
Hi {this.state.firstName}!
|
||||
</h2>
|
||||
<p>
|
||||
You are currently signed in with
|
||||
{" "}
|
||||
<code>{this.state.email}</code>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user