misc fixes related to friends page
This commit is contained in:
parent
8e3272c7d5
commit
ca615eb9d9
|
|
@ -37,7 +37,7 @@ const closeSidePanel = () => {
|
||||||
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click();
|
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click();
|
||||||
};
|
};
|
||||||
|
|
||||||
describe.only('Friends page without data', () => {
|
describe('Friends page without data', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.stubAuthenticate();
|
cy.stubAuthenticate();
|
||||||
// cy.intercept('POST', /\S+\/filter/, {
|
// cy.intercept('POST', /\S+\/filter/, {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export const JKMyFriends = () => {
|
||||||
.then(async response => {
|
.then(async response => {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const friendIds = data.map(friend => friend.id);
|
const friendIds = data.map(friend => friend.id);
|
||||||
|
console.log('friendIds', friendIds);
|
||||||
//fetch friends with associated data
|
//fetch friends with associated data
|
||||||
dispatch(filterFriendsByIds({ userId: currentUser.id, ids: friendIds }));
|
dispatch(filterFriendsByIds({ userId: currentUser.id, ids: friendIds }));
|
||||||
//fetch latencies for friends
|
//fetch latencies for friends
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ function JKPeopleFilter() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = (data) => {
|
const onSubmit = (data) => {
|
||||||
|
console.log("_DEBUG_ data", data)
|
||||||
console.log("_DEBUG_ page.current", page.current)
|
console.log("_DEBUG_ page.current", page.current)
|
||||||
let genres = [];
|
let genres = [];
|
||||||
let joined_within_days = '';
|
let joined_within_days = '';
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ const JKMessageModal = props => {
|
||||||
goToBottom();
|
goToBottom();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('ERROR', err);
|
console.error('Error when fetching messages', err);
|
||||||
} finally {
|
} finally {
|
||||||
setFetching(false);
|
setFetching(false);
|
||||||
}
|
}
|
||||||
|
|
@ -100,32 +100,32 @@ const JKMessageModal = props => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (scrollbar && scrollbar.current) {
|
if (scrollbar && scrollbar.current) {
|
||||||
if (!fetching && !scrollAtTop()) {
|
if (!fetching && !scrollAtTop()) { // if not data fetching and scroll is not at top
|
||||||
if (messages[messages.length - 1]['senderId'] !== currentUser.id) {
|
if (messages[messages.length - 1]['senderId'] !== currentUser.id) { // if last message is not sent by current user
|
||||||
if (!scrolledToBottom.current) {
|
if (!scrolledToBottom.current) { // if not scrolled to bottom
|
||||||
setMessagesArrived(true);
|
setMessagesArrived(true);
|
||||||
} else {
|
} else {
|
||||||
goToBottom();
|
//goToBottom(); // a new message has arrived, scroll to bottom
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goToBottom();
|
//goToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [messages]);
|
}, [messages]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (!messagesArrived) {
|
// if (!messagesArrived) {
|
||||||
setMessagesArrived(false);
|
// setMessagesArrived(false);
|
||||||
goToBottom();
|
// goToBottom();
|
||||||
}
|
// }
|
||||||
}, [messagesArrived]);
|
// }, [messagesArrived]);
|
||||||
|
|
||||||
const handleScrollStop = scrollValues => {
|
const handleScrollStop = scrollValues => {
|
||||||
scrolledToBottom.current = false;
|
scrolledToBottom.current = false;
|
||||||
if (scrollValues.scrollTop === 0) {
|
if (scrollValues.scrollTop === 0) { // if scrolled to top
|
||||||
setOffset(prev => prev + 1);
|
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;
|
scrolledToBottom.current = true;
|
||||||
setMessagesArrived(false);
|
setMessagesArrived(false);
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +152,7 @@ const JKMessageModal = props => {
|
||||||
{ isIterableArray(messages) &&
|
{ isIterableArray(messages) &&
|
||||||
messages.map((message, index) => (
|
messages.map((message, index) => (
|
||||||
<div className="d-flex mb-3 mr-1 text-message-row" key={message.id}>
|
<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
|
<JKProfileAvatar
|
||||||
src={message.receiverId === currentUser.id ? userPhotoUrl : currentUserPhotoUrl }
|
src={message.receiverId === currentUser.id ? userPhotoUrl : currentUserPhotoUrl }
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ module JamRuby
|
||||||
inst = []
|
inst = []
|
||||||
instruments.each do |ii|
|
instruments.each do |ii|
|
||||||
proficiency_levels.each do |pl|
|
proficiency_levels.each do |pl|
|
||||||
inst << { id: ii[:value], proficiency: pl}
|
inst << { instrument_id: ii[:value], proficiency_level: pl}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filter_params.merge!(instruments: inst)
|
filter_params.merge!(instruments: inst)
|
||||||
|
|
@ -85,7 +85,7 @@ module JamRuby
|
||||||
raise exception
|
raise exception
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.users_latency_data(user_obj, remote_ip, latency_good, latency_fair, latency_high, filter_opts, offset, limit)
|
def self.users_latency_data(user_obj, remote_ip, latency_good, latency_fair, latency_high, filter_opts, offset, limit)
|
||||||
uri = URI(latency_url)
|
uri = URI(latency_url)
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,7 @@ module JamRuby
|
||||||
end
|
end
|
||||||
|
|
||||||
def _joined_within(rel)
|
def _joined_within(rel)
|
||||||
#debugger
|
if json[KEY_JOINED_WITHIN].present? && 0 < (val = json[KEY_JOINED_WITHIN].to_i)
|
||||||
if 0 < (val = json[KEY_JOINED_WITHIN].to_i)
|
|
||||||
rel = rel.where("users.created_at >= ?", val.days.ago.at_beginning_of_day)
|
rel = rel.where("users.created_at >= ?", val.days.ago.at_beginning_of_day)
|
||||||
end
|
end
|
||||||
rel
|
rel
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ module JamRuby
|
||||||
end
|
end
|
||||||
|
|
||||||
def _active_within(rel)
|
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)
|
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
|
end
|
||||||
rel
|
rel
|
||||||
|
|
@ -163,6 +163,11 @@ module JamRuby
|
||||||
def do_filter(user_ids)
|
def do_filter(user_ids)
|
||||||
rel = User.musicians.where('users.id <> ?', self.user.id)
|
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)
|
#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
|
#debugger
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue