Update nedb-promises

Change to use `Datastore.create` instead of `new Datastore`
Forgot replace in Auth...
This commit is contained in:
kPherox 2019-05-13 01:28:03 +09:00
parent 8b2a9964a4
commit 025c1cf19b
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
5 changed files with 18 additions and 19 deletions

5
package-lock.json generated
View File

@ -8271,8 +8271,9 @@
} }
}, },
"nedb-promises": { "nedb-promises": {
"version": "git://github.com/bajankristof/nedb-promises.git#bbc45f51d1cdcb6a38fb640b11429490816b320e", "version": "3.0.5",
"from": "git://github.com/bajankristof/nedb-promises.git#bbc45f5", "resolved": "https://registry.npmjs.org/nedb-promises/-/nedb-promises-3.0.5.tgz",
"integrity": "sha512-ikrcn1lXTZhuiLG+LZnYfMPxAHECsy8kUqqZ0fQVFlXlpuXQROYSRDG8+AmkAX6N0tZY+tY8P/vEsW4+eFScUA==",
"dev": true, "dev": true,
"requires": { "requires": {
"nedb": "^1.8.0" "nedb": "^1.8.0"

View File

@ -40,7 +40,7 @@
"eslint": "^5.8.0", "eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0", "eslint-plugin-vue": "^5.0.0",
"megalodon": "^0.6.4", "megalodon": "^0.6.4",
"nedb-promises": "git://github.com/bajankristof/nedb-promises.git#bbc45f5", "nedb-promises": "^3.0.5",
"postcss-nested": "^4.1.2", "postcss-nested": "^4.1.2",
"typescript": "^3.4.3", "typescript": "^3.4.3",
"vue-cli-plugin-electron-builder": "^1.3.1", "vue-cli-plugin-electron-builder": "^1.3.1",

View File

@ -1,12 +1,11 @@
import { ipcMain, Event, shell, app } from "electron" import { ipcMain, Event, shell, app } from "electron"
import Mastodon, { Response, Account, OAuth } from "megalodon" import Mastodon, { Response, Account, OAuth } from "megalodon"
import { join } from "path" import { join } from "path"
import Datastore from "nedb" import Datastore from "nedb-promises"
import Client from "./Client" import Client from "./Client"
interface AccountDoc { interface AccountDoc {
_id?: string
domain: string domain: string
acct: string acct: string
full: string full: string
@ -100,7 +99,7 @@ export default class Auth {
let resp: Response<Account> = await client.get<Account>("/accounts/verify_credentials") let resp: Response<Account> = await client.get<Account>("/accounts/verify_credentials")
let you = resp.data let you = resp.data
let db = new Datastore({ let db = Datastore.create({
filename: join(app.getPath("userData"), "account.db"), filename: join(app.getPath("userData"), "account.db"),
autoload: true autoload: true
}) })
@ -114,16 +113,15 @@ export default class Auth {
accessToken: tokenData.accessToken, accessToken: tokenData.accessToken,
} }
db.insert(docs, function (err, newDocs) { try {
if (err) { let newDoc = await db.insert(docs)
Client.setAuthClient('http', newDoc.full, client)
event.sender.send(`login-complete`, newDoc)
} catch (error) {
event.sender.send(`error`, { event.sender.send(`error`, {
id: "ERROR_YOU_TRY_ANOTHER_ACCOUNT", id: "ERROR_YOU_TRY_ANOTHER_ACCOUNT",
message: "You cannot login already logined account." message: "You cannot login already logined account."
}) })
} else { }
Client.setAuthClient('http', newDocs.full, client)
event.sender.send(`login-complete`, newDocs)
}
})
} }
} }

View File

@ -19,7 +19,7 @@ export default class Client {
if (!clients.has(username)) { if (!clients.has(username)) {
// usernameからドメインをとトークンをデータベースから取得してクライアントを作る // usernameからドメインをとトークンをデータベースから取得してクライアントを作る
let db = new Datastore({ let db = Datastore.create({
filename: join(app.getPath("userData"), "account.db"), filename: join(app.getPath("userData"), "account.db"),
autoload: true autoload: true
}) })

View File

@ -39,7 +39,7 @@ export default class Timeline {
return return
} }
let db = new Datastore({ let db = Datastore.create({
filename: join(app.getPath("userData"), "timeline.db"), filename: join(app.getPath("userData"), "timeline.db"),
autoload: true autoload: true
}) })