Noded/frontend#86 Store user bookmarks in their preferences
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
2021-02-18 10:18:57 -06:00
parent bebdd504dd
commit 2f3d94adf3
3 changed files with 71 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ class User extends AuthUser {
dark_mode: { type: Boolean, default: false },
auto_prefetch: { type: Boolean, default: false },
default_page: String,
bookmark_page_ids: [String],
},
}}
}
@@ -27,6 +28,20 @@ class User extends AuthUser {
return Page.findOne({OrgUserId: this._id, ParentId: '0'})
}
async get_bookmarked_pages() {
const Page = this.models.get('api:Page')
const pages = await Page.find({ UUID: { $in: this.preferences.bookmark_page_ids || [] }})
const visible = []
for ( const page of pages ) {
if ( await page.is_accessible_by(this) ) {
visible.push(page)
}
}
return visible
}
async get_accessible_pages() {
const Page = this.models.get('api:Page')
const user_page = await this.get_root_page()