feature: watches on the backend, need frontend implementation for
notifications and unread indicators
This commit is contained in:
parent
7046bb0389
commit
6293374bb7
28 changed files with 1405 additions and 608 deletions
66
models/watch.ts
Normal file
66
models/watch.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { FSDB_COLLECTION } from '@andyburke/fsdb';
|
||||
import { by_lurid } from '@andyburke/fsdb/organizers';
|
||||
import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers';
|
||||
|
||||
/**
|
||||
* @typedef {object} WATCH_TYPE_INFO
|
||||
* @property {boolean} ignored if true, this type should NOT produce any indications or notifications
|
||||
* @property {string} last_id_seen the last event id the user has seen for this event type
|
||||
* @property {string} last_id_notified the last event id the user was notified about for this type
|
||||
*/
|
||||
|
||||
export type WATCH_TYPE_INFO = {
|
||||
ignored: boolean;
|
||||
last_id_seen: string;
|
||||
last_id_notified: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} WATCH_TIMESTAMPS
|
||||
* @property {string} created the created date of the watch
|
||||
* @property {string} updated the last updated date, usually coinciding with the last seen id being changed
|
||||
*/
|
||||
|
||||
/**
|
||||
* WATCH
|
||||
*
|
||||
* @property {string} id - lurid (stable)
|
||||
* @property {string} creator_id - user id of the watch creator
|
||||
* @property {string} topic_id - the topic_id being watched
|
||||
* @property {[WATCH_TYPE_INFO]} types - information for types being watched within this topic
|
||||
* @property {Record<string,any>} [meta] - optional metadata about the watch
|
||||
* @property {WATCH_TIMESTAMPS} timestamps - timestamps for the watch
|
||||
*/
|
||||
|
||||
export type WATCH = {
|
||||
id: string;
|
||||
creator_id: string;
|
||||
topic_id: string;
|
||||
types: [WATCH_TYPE_INFO];
|
||||
meta?: Record<string, any>;
|
||||
timestamps: {
|
||||
created: string;
|
||||
updated: string;
|
||||
};
|
||||
};
|
||||
|
||||
export const WATCHES = new FSDB_COLLECTION<WATCH>({
|
||||
name: 'watches',
|
||||
id_field: 'id',
|
||||
organize: by_lurid,
|
||||
indexers: {
|
||||
creator_id: new FSDB_INDEXER_SYMLINKS<WATCH>({
|
||||
name: 'creator_id',
|
||||
field: 'creator_id',
|
||||
to_many: true,
|
||||
organize: by_lurid
|
||||
}),
|
||||
|
||||
topic_id: new FSDB_INDEXER_SYMLINKS<WATCH>({
|
||||
name: 'topic_id',
|
||||
field: 'topic_id',
|
||||
to_many: true,
|
||||
organize: by_lurid
|
||||
})
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue