mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-09 08:18:44 +01:00
refs #100 Set order when save account record
This commit is contained in:
parent
1527f1dcaf
commit
3839e6c3e8
@ -17,7 +17,7 @@ export default class Account {
|
||||
|
||||
listAccounts () {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.find({accessToken: { $ne: '' }}, (err, docs) => {
|
||||
this.db.find({accessToken: { $ne: '' }}).sort({ order: 1 }).exec((err, docs) => {
|
||||
if (err) return reject(err)
|
||||
if (empty(docs)) return reject(new EmptyRecordError('empty'))
|
||||
resolve(docs)
|
||||
@ -25,6 +25,15 @@ export default class Account {
|
||||
})
|
||||
}
|
||||
|
||||
countAuthorizedAccounts () {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.count({accessToken: { $ne: '' }}, (err, count) => {
|
||||
if (err) return reject(err)
|
||||
resolve(count)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getAccount (id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.findOne(
|
||||
|
@ -26,7 +26,7 @@ export default class Authentication {
|
||||
this.clientId = res.client_id
|
||||
this.clientSecret = res.client_secret
|
||||
|
||||
// TODO: Save order number
|
||||
const count = await this.db.countAuthorizedAccounts()
|
||||
const json = {
|
||||
baseURL: this.baseURL,
|
||||
domain: this.domain,
|
||||
@ -34,7 +34,8 @@ export default class Authentication {
|
||||
clientSecret: this.clientSecret,
|
||||
accessToken: '',
|
||||
username: '',
|
||||
accountId: ''
|
||||
accountId: '',
|
||||
order: count + 1
|
||||
}
|
||||
await this.db.insertAccount(json)
|
||||
const url = await Mastodon.getAuthorizationUrl(this.clientId, this.clientSecret, this.baseURL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user