misc fixes related to friends page

This commit is contained in:
Nuwan 2024-10-18 22:48:11 +05:30
parent 8e3272c7d5
commit ca615eb9d9
7 changed files with 27 additions and 21 deletions

View File

@ -37,7 +37,7 @@ const closeSidePanel = () => {
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click();
};
describe.only('Friends page without data', () => {
describe('Friends page without data', () => {
beforeEach(() => {
cy.stubAuthenticate();
// cy.intercept('POST', /\S+\/filter/, {

View File

@ -38,6 +38,7 @@ export const JKMyFriends = () => {
.then(async response => {
const data = await response.json();
const friendIds = data.map(friend => friend.id);
console.log('friendIds', friendIds);
//fetch friends with associated data
dispatch(filterFriendsByIds({ userId: currentUser.id, ids: friendIds }));
//fetch latencies for friends

View File

@ -151,6 +151,7 @@ function JKPeopleFilter() {
};
const onSubmit = (data) => {
console.log("_DEBUG_ data", data)
console.log("_DEBUG_ page.current", page.current)
let genres = [];
let joined_within_days = '';

View File

@ -51,7 +51,7 @@ const JKMessageModal = props => {
goToBottom();
}
} catch (err) {
console.log('ERROR', err);
console.error('Error when fetching messages', err);
} finally {
setFetching(false);
}
@ -100,32 +100,32 @@ const JKMessageModal = props => {
useEffect(() => {
if (scrollbar && scrollbar.current) {
if (!fetching && !scrollAtTop()) {
if (messages[messages.length - 1]['senderId'] !== currentUser.id) {
if (!scrolledToBottom.current) {
if (!fetching && !scrollAtTop()) { // if not data fetching and scroll is not at top
if (messages[messages.length - 1]['senderId'] !== currentUser.id) { // if last message is not sent by current user
if (!scrolledToBottom.current) { // if not scrolled to bottom
setMessagesArrived(true);
} else {
goToBottom();
//goToBottom(); // a new message has arrived, scroll to bottom
}
} else {
goToBottom();
//goToBottom();
}
}
}
}, [messages]);
useEffect(() => {
if (!messagesArrived) {
setMessagesArrived(false);
goToBottom();
}
}, [messagesArrived]);
// useEffect(() => {
// if (!messagesArrived) {
// setMessagesArrived(false);
// goToBottom();
// }
// }, [messagesArrived]);
const handleScrollStop = scrollValues => {
scrolledToBottom.current = false;
if (scrollValues.scrollTop === 0) {
if (scrollValues.scrollTop === 0) { // if scrolled to top
setOffset(prev => prev + 1);
} else if (scrollValues.scrollTop === scrollValues.scrollHeight - scrollValues.clientHeight) {
} else if (scrollValues.scrollTop === scrollValues.scrollHeight - scrollValues.clientHeight) { // if scrolled to bottom
scrolledToBottom.current = true;
setMessagesArrived(false);
}
@ -152,7 +152,7 @@ const JKMessageModal = props => {
{ isIterableArray(messages) &&
messages.map((message, index) => (
<div className="d-flex mb-3 mr-1 text-message-row" key={message.id}>
<div className="avatar avatar-2xl d-inline-block">
<div className="avatar avatar-2xl d-inline-block mr-2">
<JKProfileAvatar
src={message.receiverId === currentUser.id ? userPhotoUrl : currentUserPhotoUrl }
/>

View File

@ -42,7 +42,7 @@ module JamRuby
inst = []
instruments.each do |ii|
proficiency_levels.each do |pl|
inst << { id: ii[:value], proficiency: pl}
inst << { instrument_id: ii[:value], proficiency_level: pl}
end
end
filter_params.merge!(instruments: inst)
@ -85,7 +85,7 @@ module JamRuby
raise exception
end
end
def self.users_latency_data(user_obj, remote_ip, latency_good, latency_fair, latency_high, filter_opts, offset, limit)
uri = URI(latency_url)
begin

View File

@ -180,8 +180,7 @@ module JamRuby
end
def _joined_within(rel)
#debugger
if 0 < (val = json[KEY_JOINED_WITHIN].to_i)
if json[KEY_JOINED_WITHIN].present? && 0 < (val = json[KEY_JOINED_WITHIN].to_i)
rel = rel.where("users.created_at >= ?", val.days.ago.at_beginning_of_day)
end
rel

View File

@ -128,7 +128,7 @@ module JamRuby
end
def _active_within(rel)
if 0 <= (val = json[KEY_ACTIVE_WITHIN].to_i)
if json[KEY_ACTIVE_WITHIN].present? && 0 <= (val = json[KEY_ACTIVE_WITHIN].to_i)
rel = rel.where("users.id IN (SELECT users.id FROM users GROUP BY id HAVING GREATEST(updated_at, last_jam_updated_at) >= ?)", val.days.ago.at_beginning_of_day)
end
rel
@ -163,6 +163,11 @@ module JamRuby
def do_filter(user_ids)
rel = User.musicians.where('users.id <> ?', self.user.id)
rel = self._genres(rel)
rel = self._instruments(rel)
rel = self._joined_within(rel)
rel = self._active_within(rel)
#user_ids: users returned from neo4j latency data service. #if this variable is not null, that means we are calling this method with neo4j latency data (currently this call only comes from api_search_controller#filter)
#debugger