Update nedb-promises
Change to use `Datastore.create` instead of `new Datastore` Forgot replace in Auth...
This commit is contained in:
parent
8b2a9964a4
commit
025c1cf19b
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -8271,8 +8271,9 @@
|
|||
}
|
||||
},
|
||||
"nedb-promises": {
|
||||
"version": "git://github.com/bajankristof/nedb-promises.git#bbc45f51d1cdcb6a38fb640b11429490816b320e",
|
||||
"from": "git://github.com/bajankristof/nedb-promises.git#bbc45f5",
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nedb-promises/-/nedb-promises-3.0.5.tgz",
|
||||
"integrity": "sha512-ikrcn1lXTZhuiLG+LZnYfMPxAHECsy8kUqqZ0fQVFlXlpuXQROYSRDG8+AmkAX6N0tZY+tY8P/vEsW4+eFScUA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"nedb": "^1.8.0"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"megalodon": "^0.6.4",
|
||||
"nedb-promises": "git://github.com/bajankristof/nedb-promises.git#bbc45f5",
|
||||
"nedb-promises": "^3.0.5",
|
||||
"postcss-nested": "^4.1.2",
|
||||
"typescript": "^3.4.3",
|
||||
"vue-cli-plugin-electron-builder": "^1.3.1",
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { ipcMain, Event, shell, app } from "electron"
|
||||
import Mastodon, { Response, Account, OAuth } from "megalodon"
|
||||
import { join } from "path"
|
||||
import Datastore from "nedb"
|
||||
import Datastore from "nedb-promises"
|
||||
|
||||
import Client from "./Client"
|
||||
|
||||
interface AccountDoc {
|
||||
_id?: string
|
||||
domain: string
|
||||
acct: string
|
||||
full: string
|
||||
|
@ -100,7 +99,7 @@ export default class Auth {
|
|||
let resp: Response<Account> = await client.get<Account>("/accounts/verify_credentials")
|
||||
let you = resp.data
|
||||
|
||||
let db = new Datastore({
|
||||
let db = Datastore.create({
|
||||
filename: join(app.getPath("userData"), "account.db"),
|
||||
autoload: true
|
||||
})
|
||||
|
@ -114,16 +113,15 @@ export default class Auth {
|
|||
accessToken: tokenData.accessToken,
|
||||
}
|
||||
|
||||
db.insert(docs, function (err, newDocs) {
|
||||
if (err) {
|
||||
event.sender.send(`error`, {
|
||||
id: "ERROR_YOU_TRY_ANOTHER_ACCOUNT",
|
||||
message: "You cannot login already logined account."
|
||||
})
|
||||
} else {
|
||||
Client.setAuthClient('http', newDocs.full, client)
|
||||
event.sender.send(`login-complete`, newDocs)
|
||||
}
|
||||
})
|
||||
try {
|
||||
let newDoc = await db.insert(docs)
|
||||
Client.setAuthClient('http', newDoc.full, client)
|
||||
event.sender.send(`login-complete`, newDoc)
|
||||
} catch (error) {
|
||||
event.sender.send(`error`, {
|
||||
id: "ERROR_YOU_TRY_ANOTHER_ACCOUNT",
|
||||
message: "You cannot login already logined account."
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class Client {
|
|||
|
||||
if (!clients.has(username)) {
|
||||
// usernameからドメインをとトークンをデータベースから取得してクライアントを作る
|
||||
let db = new Datastore({
|
||||
let db = Datastore.create({
|
||||
filename: join(app.getPath("userData"), "account.db"),
|
||||
autoload: true
|
||||
})
|
||||
|
|
|
@ -39,7 +39,7 @@ export default class Timeline {
|
|||
return
|
||||
}
|
||||
|
||||
let db = new Datastore({
|
||||
let db = Datastore.create({
|
||||
filename: join(app.getPath("userData"), "timeline.db"),
|
||||
autoload: true
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user