tangled
alpha
login
or
join now
bad-example.com
/
spacedust-utils
6
fork
atom
demos for spacedust
6
fork
atom
overview
issues
pulls
pipelines
notification filtering ui actually works?
bad-example.com
8 months ago
a6532200
0f8bab03
+17
-7
2 changed files
expand all
collapse all
unified
split
atproto-notifications
src
components
Feed.tsx
db.ts
+2
-2
atproto-notifications/src/components/Feed.tsx
···
89
89
// this could be combined with the broadcast thing above, but for now just chain deps
90
90
const [feed, setFeed] = useState([]);
91
91
useEffect(() => {
92
92
-
(async () => setFeed(await getNotifications()))();
93
93
-
}, [inc]);
92
92
+
(async () => setFeed(await getNotifications(secondary, secondaryFilter)))();
93
93
+
}, [inc, secondary, secondaryFilter]);
94
94
95
95
if (feed.length === 0) {
96
96
return 'no notifications loaded';
+15
-5
atproto-notifications/src/db.ts
···
89
89
});
90
90
}
91
91
92
92
-
export async function getNotifications(limit = 30) {
92
92
+
export async function getNotifications(secondary, secondaryFilter) {
93
93
+
const limit = 30;
93
94
let res = [];
94
94
-
const oc = (await getDB())
95
95
+
const store = (await getDB())
95
96
.transaction([NOTIFICATIONS])
96
96
-
.objectStore(NOTIFICATIONS)
97
97
-
.openCursor(undefined, 'prev');
97
97
+
.objectStore(NOTIFICATIONS);
98
98
+
99
99
+
let oc;
100
100
+
if (!!secondary && secondary !== 'all' && !!secondaryFilter) {
101
101
+
console.log('with', secondary, secondaryFilter)
102
102
+
oc = store
103
103
+
.index(secondary)
104
104
+
.openCursor(IDBKeyRange.only(secondaryFilter), 'prev');
105
105
+
} else {
106
106
+
oc = store.openCursor(null, 'prev');
107
107
+
}
98
108
return new Promise((resolve, reject) => {
99
109
oc.onerror = () => reject(oc.error);
100
110
oc.onsuccess = ev => {
101
111
const cursor = event.target.result;
102
112
if (cursor) {
103
103
-
res.push([cursor.key, cursor.value]);
113
113
+
res.push([cursor.value.id, cursor.value]);
104
114
if (res.length < limit) cursor.continue();
105
115
else resolve(res);
106
116
} else {