Add user preferences item for auto_prefetch
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2020-10-28 23:48:31 -05:00
parent f273fc5d9b
commit 6c6f932bdb
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
3 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
const { Controller } = require('libflitter')
const FakeRequest = require('../../../FakeRequest')
const { ObjectId } = require('mongodb')
class OfflineController extends Controller {
static get services() {
@ -14,6 +15,7 @@ class OfflineController extends Controller {
const ColumnDef = this.models.get('api:db:ColumnDef')
const DBEntry = this.models.get('api:db:DBEntry')
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 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 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({
pages,

View File

@ -19,6 +19,8 @@ class SessionController extends Controller {
} else {
req.user.preferences.default_page = '';
}
req.user.preferences.auto_prefetch = !!save_prefs.auto_prefetch
}
await req.user.save()

View File

@ -15,6 +15,7 @@ class User extends AuthUser {
// other schema fields here
preferences: {
dark_mode: { type: Boolean, default: false },
auto_prefetch: { type: Boolean, default: false },
default_page: String,
},
}}