fixing bug with getting organizations
This commit is contained in:
@@ -38,8 +38,8 @@ export default class AuthHandler {
|
|||||||
|
|
||||||
const user = db.members.getByEmail(email);
|
const user = db.members.getByEmail(email);
|
||||||
let connections = db.MEMBER_IN_NETWORK.getByFrom(db.members.prefix + "-" + user.id)
|
let connections = db.MEMBER_IN_NETWORK.getByFrom(db.members.prefix + "-" + user.id)
|
||||||
let userOrgs = connections.map((v) => {
|
let userOrgs = connections.map((c) => {
|
||||||
return db.networks.get(v.id)
|
return db.networks.get(c.to)
|
||||||
})
|
})
|
||||||
console.log(userOrgs)
|
console.log(userOrgs)
|
||||||
res.send({ email: user.email, name: user.firstName + " " + user.lastName, networks: userOrgs});
|
res.send({ email: user.email, name: user.firstName + " " + user.lastName, networks: userOrgs});
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ export default class Database {
|
|||||||
this.loadData()
|
this.loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCurrentIndex(model) {
|
||||||
|
return model.indices[1] - model.indices[0]
|
||||||
|
}
|
||||||
|
|
||||||
getNextIndex(model) {
|
getNextIndex(model) {
|
||||||
return model.indices[1] - model.indices[0] + 1
|
return model.indices[1] - model.indices[0] + 1
|
||||||
}
|
}
|
||||||
@@ -65,7 +69,6 @@ export default class Database {
|
|||||||
...edge
|
...edge
|
||||||
}
|
}
|
||||||
if(!toAdd.created) toAdd.created = global.currentTime()
|
if(!toAdd.created) toAdd.created = global.currentTime()
|
||||||
console.log(toAdd)
|
|
||||||
let schema = model.schema
|
let schema = model.schema
|
||||||
let result = schema.safeParse(toAdd)
|
let result = schema.safeParse(toAdd)
|
||||||
if(result.success) {
|
if(result.success) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default class Member {
|
|||||||
if(network) {
|
if(network) {
|
||||||
global.db.edge.add({
|
global.db.edge.add({
|
||||||
type: "IN",
|
type: "IN",
|
||||||
from: `${this.prefix}-${global.db.getNextIndex(this)}`,
|
from: `${this.prefix}-${global.db.getCurrentIndex(this)}`,
|
||||||
to: "NETWORK-1"
|
to: "NETWORK-1"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ export default class Network {
|
|||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
|
|
||||||
get(id) {
|
get(stringID) {
|
||||||
|
let id = stringID.split("-")[1]
|
||||||
let index = this.indices[0] + (id - 1)
|
let index = this.indices[0] + (id - 1)
|
||||||
|
console.log("networkget", index, id, global.db.nodes[index-1])
|
||||||
return global.db.nodes[index]
|
return global.db.nodes[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ async function getProfile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfile().then(async () => {
|
async function setCurrentNetwork() {
|
||||||
let path = "";
|
let path = ""
|
||||||
let defaultNetwork = window.profile.networks[0]
|
let defaultNetwork = window.profile.networks[0]
|
||||||
|
|
||||||
if(!selectedNetwork()) {
|
if(!selectedNetwork()) {
|
||||||
@@ -99,6 +99,15 @@ getProfile().then(async () => {
|
|||||||
let json = await appData.json()
|
let json = await appData.json()
|
||||||
window.comalData = json
|
window.comalData = json
|
||||||
|
|
||||||
window.navigateTo(path)
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
getProfile().then(async () => {
|
||||||
|
|
||||||
|
if(window.profile.networks.length > 0) {
|
||||||
|
let path = await setCurrentNetwork()
|
||||||
|
window.navigateTo(path)
|
||||||
|
}
|
||||||
|
|
||||||
Home()
|
Home()
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user