mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-20 01:56:33 +00:00
feed fix
This commit is contained in:
parent
db87091446
commit
189f1f8000
@ -216,6 +216,7 @@ class Feed extends Component {
|
||||
};
|
||||
const throttledUpdate = throttle(update, 1000, { leading: true });
|
||||
const callback = (event) => {
|
||||
console.log('got event', event);
|
||||
results.set(event.id, event);
|
||||
if (results.length < 10) {
|
||||
update(Array.from(results.values()));
|
||||
@ -260,15 +261,15 @@ class Feed extends Component {
|
||||
|
||||
getEvents(callback) {
|
||||
let since;
|
||||
if (this.state.settings.timespan) {
|
||||
if (this.state.settings.timespan !== 'all') {
|
||||
since = Math.floor(Date.now() / 1000) - TIMESPANS[this.state.settings.timespan];
|
||||
}
|
||||
if (this.props.nostrUser) {
|
||||
if (this.props.index === 'likes') {
|
||||
return PubSub.subscribe(
|
||||
// TODO map to liked msg id
|
||||
[{ authors: [this.props.nostrUser], kinds: [7], since }],
|
||||
(events) => callback(events),
|
||||
{ authors: [this.props.nostrUser], kinds: [7], since },
|
||||
callback,
|
||||
'user',
|
||||
false,
|
||||
);
|
||||
@ -276,6 +277,7 @@ class Feed extends Component {
|
||||
return PubSub.subscribe(
|
||||
{ authors: [this.props.nostrUser], kinds: [1, 6], since },
|
||||
(event) => {
|
||||
console.log('msg', event);
|
||||
if (this.props.index === 'posts') {
|
||||
if (Events.getEventReplyingTo(event)) {
|
||||
return;
|
||||
@ -288,16 +290,15 @@ class Feed extends Component {
|
||||
);
|
||||
}
|
||||
} else if (this.props.keyword) {
|
||||
console.log('keyword search');
|
||||
return PubSub.subscribe(
|
||||
[{ keywords: [this.props.keyword], kinds: [1], limit: 1000, since }],
|
||||
{ keywords: [this.props.keyword], kinds: [1], limit: 1000, since },
|
||||
(e) => e.content?.includes(this.props.keyword) && callback(e), // TODO this should not be necessary. seems subscribe still asks non-search relays
|
||||
'keywords',
|
||||
false,
|
||||
);
|
||||
} else {
|
||||
return PubSub.subscribe(
|
||||
[{ kinds: [1, 6], limit: 500, since }],
|
||||
{ kinds: [1, 6], limit: 500, since },
|
||||
(e) => {
|
||||
if (
|
||||
this.props.index === 'follows' &&
|
||||
@ -371,7 +372,7 @@ class Feed extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
showqueuedEvents() {
|
||||
showQueuedEvents() {
|
||||
const sortedEvents = this.state.sortedEvents;
|
||||
console.log('sortedEvents.length', sortedEvents.length);
|
||||
sortedEvents.unshift(...this.state.queuedEvents);
|
||||
@ -532,7 +533,7 @@ class Feed extends Component {
|
||||
return (
|
||||
<div
|
||||
className={`msg ${this.state.showNewMsgsFixedTop ? 'fixedTop' : ''}`}
|
||||
onClick={() => this.showqueuedEvents()}
|
||||
onClick={() => this.showQueuedEvents()}
|
||||
>
|
||||
<div className="msg-content notification-msg colored">
|
||||
{t('show_n_new_messages').replace('{n}', this.state.queuedEvents.length)}
|
||||
|
@ -391,6 +391,7 @@ const Events = {
|
||||
return true;
|
||||
},
|
||||
find(filter: Filter, callback: (event: Event) => void) {
|
||||
console.log(222);
|
||||
const query = {};
|
||||
if (filter.authors) {
|
||||
query['pubkey'] = { $in: filter.authors };
|
||||
|
@ -81,6 +81,7 @@ const PubSub = {
|
||||
});
|
||||
}
|
||||
|
||||
//debugger;
|
||||
cb && Events.find(filter, cb);
|
||||
IndexedDB.subscribe(filter); // calls Events.handle which calls subscriptions with matching filters
|
||||
|
||||
@ -104,7 +105,7 @@ const PubSub = {
|
||||
|
||||
handle(event: Event & { id: string }) {
|
||||
// go through subscriptions and callback if filters match
|
||||
for (const sub of PubSub.subscriptions.values()) {
|
||||
for (const sub of this.subscriptions.values()) {
|
||||
if (!sub.filter) {
|
||||
continue;
|
||||
}
|
||||
@ -117,11 +118,11 @@ const PubSub = {
|
||||
subscribeRelayPool(filter: Filter, sinceLastOpened: boolean) {
|
||||
let relays: any = Relays.DEFAULT_RELAYS;
|
||||
// if any of filters[] doesn't have authors, we need to define default relays
|
||||
/*
|
||||
/*
|
||||
if (!filter.authors) {
|
||||
relays = Relays.DEFAULT_RELAYS;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
if (dev.indexed03 && filter.kinds.every((k) => k === 0 || k === 3)) {
|
||||
relays = ['wss://us.rbr.bio', 'wss://eu.rbr.bio'];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user