Add favorites and recently visited pages
Pages can be starred from their header; favorites show in the sidebar above the spaces, and Home lists the pages visited last. Both are per user and per workspace, and are filtered by the caller's current rights, so pages that moved out of reach or into the trash drop out. Visits are trimmed to the newest 50 per workspace. The icon set gains the glyphs the rest of Phase 1 needs, and DwIcon can draw a filled variant for on/off states. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34660c6b46
commit
b0e36fcfaf
19 files changed
+804
-13
No files matched your search
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
// Per-user favorites and recently visited pages. workspace is copied from the
|
||||
// page so the sidebar can list one workspace's entries without a join.
|
||||
|
||||
migrate(
|
||||
(app) => {
|
||||
const users = app.findCollectionByNameOrId("users");
|
||||
const pages = app.findCollectionByNameOrId("pages");
|
||||
const workspaces = app.findCollectionByNameOrId("workspaces");
|
||||
const refs = () => [
|
||||
{ name: "user", type: "relation", collectionId: users.id, maxSelect: 1, required: true, cascadeDelete: true },
|
||||
{ name: "page", type: "relation", collectionId: pages.id, maxSelect: 1, required: true, cascadeDelete: true },
|
||||
{ name: "workspace", type: "relation", collectionId: workspaces.id, maxSelect: 1, required: true, cascadeDelete: true },
|
||||
];
|
||||
|
||||
app.save(
|
||||
new Collection({
|
||||
type: "base",
|
||||
name: "favorites",
|
||||
fields: [
|
||||
...refs(),
|
||||
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
|
||||
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
|
||||
],
|
||||
indexes: [
|
||||
"CREATE UNIQUE INDEX idx_favorites_unique ON favorites (user, page)",
|
||||
"CREATE INDEX idx_favorites_list ON favorites (user, workspace)",
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
app.save(
|
||||
new Collection({
|
||||
type: "base",
|
||||
name: "page_visits",
|
||||
fields: [
|
||||
...refs(),
|
||||
{ name: "visited", type: "date", required: true },
|
||||
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
|
||||
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
|
||||
],
|
||||
indexes: [
|
||||
"CREATE UNIQUE INDEX idx_page_visits_unique ON page_visits (user, page)",
|
||||
"CREATE INDEX idx_page_visits_list ON page_visits (user, workspace, visited)",
|
||||
],
|
||||
}),
|
||||
);
|
||||
},
|
||||
(app) => {
|
||||
for (const name of ["page_visits", "favorites"]) {
|
||||
try {
|
||||
app.delete(app.findCollectionByNameOrId(name));
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user