Add user preferences item for auto_prefetch
This commit is contained in:
parent
f273fc5d9b
commit
6c6f932bdb
@ -1,5 +1,6 @@
|
|||||||
const { Controller } = require('libflitter')
|
const { Controller } = require('libflitter')
|
||||||
const FakeRequest = require('../../../FakeRequest')
|
const FakeRequest = require('../../../FakeRequest')
|
||||||
|
const { ObjectId } = require('mongodb')
|
||||||
|
|
||||||
class OfflineController extends Controller {
|
class OfflineController extends Controller {
|
||||||
static get services() {
|
static get services() {
|
||||||
@ -14,6 +15,7 @@ class OfflineController extends Controller {
|
|||||||
const ColumnDef = this.models.get('api:db:ColumnDef')
|
const ColumnDef = this.models.get('api:db:ColumnDef')
|
||||||
const DBEntry = this.models.get('api:db:DBEntry')
|
const DBEntry = this.models.get('api:db:DBEntry')
|
||||||
const FileGroup = this.models.get('api:FileGroup')
|
const FileGroup = this.models.get('api:FileGroup')
|
||||||
|
const File = this.models.get('upload::File')
|
||||||
|
|
||||||
const pages = (await PageModel.visible_by_user(req.user)).filter(x => x.Active)
|
const pages = (await PageModel.visible_by_user(req.user)).filter(x => x.Active)
|
||||||
const page_uuids = pages.map(x => x.UUID)
|
const page_uuids = pages.map(x => x.UUID)
|
||||||
@ -29,7 +31,10 @@ class OfflineController extends Controller {
|
|||||||
|
|
||||||
const databaseEntries = await DBEntry.find({ DatabaseId: { $in: database_uuids }})
|
const databaseEntries = await DBEntry.find({ DatabaseId: { $in: database_uuids }})
|
||||||
|
|
||||||
const fileGroups = await FileGroup.find({ PageId: { $in: page_uuids }})
|
const fileGroups = (await FileGroup.find({ PageId: { $in: page_uuids }}))
|
||||||
|
for ( const grp of fileGroups ) {
|
||||||
|
grp.files = await File.find({_id: {$in: grp.FileIds.map(x => ObjectId(x))}})
|
||||||
|
}
|
||||||
|
|
||||||
return res.api({
|
return res.api({
|
||||||
pages,
|
pages,
|
||||||
|
@ -19,6 +19,8 @@ class SessionController extends Controller {
|
|||||||
} else {
|
} else {
|
||||||
req.user.preferences.default_page = '';
|
req.user.preferences.default_page = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.user.preferences.auto_prefetch = !!save_prefs.auto_prefetch
|
||||||
}
|
}
|
||||||
|
|
||||||
await req.user.save()
|
await req.user.save()
|
||||||
|
@ -15,6 +15,7 @@ class User extends AuthUser {
|
|||||||
// other schema fields here
|
// other schema fields here
|
||||||
preferences: {
|
preferences: {
|
||||||
dark_mode: { type: Boolean, default: false },
|
dark_mode: { type: Boolean, default: false },
|
||||||
|
auto_prefetch: { type: Boolean, default: false },
|
||||||
default_page: String,
|
default_page: String,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user