Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message search #3664

Merged
merged 9 commits into from
May 3, 2021
Merged

Message search #3664

merged 9 commits into from
May 3, 2021

Conversation

richrd
Copy link
Member

@richrd richrd commented Jan 3, 2020

This is mainly similar to #2627 except it's all on vue.

What this does:

  • Adds a search field to the channel and query header bars (on mobile a search icon is shown, clicking it opens the search field as a dropdown)
  • Pressing enter in the field runs the search and navigates the user to the search results page (the url contains the search terms)
  • The search result page allows the search to be changed and run again
  • The results show max 100 messages at once and older messages can be loaded with the "Show older messages" button
  • The backend db search is just a simple LIKE %keyword%. This might require some improvement to get more relevant results

TODO:

  • Channels with upper case letters in the name cannot be searched

Things to improve after this MVP:

  • Highlight the search keyword in each search result message
  • Append new results when loading more messages instead of replacing the old results
  • Ability to jump back in history to a specific message by clicking on a search result

@richrd richrd force-pushed the richrd/message-search branch 2 times, most recently from 93f9c98 to b088786 Compare January 3, 2020 22:00
@richrd richrd changed the title Message search WIP Message search Jan 4, 2020
Copy link
Member

@xPaw xPaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need some extra UI to allow searching all channels on network, or even all networks.

Thinking about it in the scope of this PR because it may require a different archicture before we move further.

client/css/style.css Outdated Show resolved Hide resolved
canProvideMessages() {
return this.isEnabled;
}
}

module.exports = MessageStorage;

function parseRowToMessage(row) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's resolve in getMessages that should re-use this function (minus setting the id).

That being said, we need to have global ids somehow stored in sqlite because when we will want to dynamically load history from sqlite in channel history, we will not be able to assign incremental ids to them as it will be out of order.

src/plugins/messageStorage/sqlite.js Outdated Show resolved Hide resolved
:message="message"
/>
<Message
:key="message.time"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this happen:

[Vue warn]: Duplicate keys detected: '2019-12-27T18:15:45.232Z'. This may cause an update error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, context menus need fixing as they rely on activeChannel and that breaks context menus in search:

vue.js:105 TypeError: Cannot read property 'network' of null
    at VueComponent.openUserContextMenu 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting duplicate key errors just by running a single search. There's no guarantee that the dates are unique and I indeed have two messages with the exact same date in my history. I don't know what to do about that since we don't have unique message IDs :(

aria-relevant="additions"
>
<template v-for="(message, id) in messages">
<DateMarker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be too noisy, I tried searching something and almost half of the results were date markers.

src/plugins/messageStorage/sqlite.js Outdated Show resolved Hide resolved
src/server.js Outdated Show resolved Hide resolved
client/components/MessageSearchForm.vue Outdated Show resolved Hide resolved
client/components/Windows/SearchResults.vue Outdated Show resolved Hide resolved
src/client.js Outdated Show resolved Hide resolved
@xPaw xPaw added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Jan 8, 2020
@richrd richrd force-pushed the richrd/message-search branch 2 times, most recently from a7195ac to c28a880 Compare March 7, 2020 13:07
@@ -501,6 +501,11 @@ Client.prototype.more = function(data) {
};
};

Client.prototype.search = function(query) {
const messageStorage = this.messageStorage.find((s) => s.canProvideMessages());
return messageStorage.search(query);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to handle the case when sqlite is disabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need some kind of handling (and probably hiding the search UI) if sqlite is disabled OR if user has logs disabled.

const params = [`%${query.searchTerm}%`];

if (query.searchNicks) {
select += ' OR json_extract(msg, "$.from.nick") LIKE ?)';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be AND if you want to search that a user has said?

@xPaw
Copy link
Member

xPaw commented Mar 24, 2020

  1. Clicking on a username or channel throws Cannot destructure property 'network' of 'this.$store.state.activeChannel' as it is null.
  2. I think searching for something else that returns same message as currently visible throws this warning: Duplicate keys detected: '2020-03-18T01:16:03.495Z'. This may cause an update error.
  3. Is 'show more messages' supposed to replace current messages instead of prepending to the top?
  4. The search box on default theme stands out and doesn't match any other existing fields color wise.
  5. Pagination is off by one and includes 1 message from previous page.

@richrd richrd force-pushed the richrd/message-search branch 3 times, most recently from d257143 to 9aa5864 Compare April 17, 2020 21:32
@xPaw xPaw linked an issue Apr 23, 2020 that may be closed by this pull request
@dgw dgw mentioned this pull request Apr 23, 2020
@richrd
Copy link
Member Author

richrd commented Apr 24, 2020

1. Clicking on a username or channel throws `Cannot destructure property 'network' of 'this.$store.state.activeChannel' as it is null.`

2. I think searching for something else that returns same message as currently visible throws this warning: `Duplicate keys detected: '2020-03-18T01:16:03.495Z'. This may cause an update error.`

3. Is 'show more messages' supposed to replace current messages instead of prepending to the top?

4. The search box on default theme stands out and doesn't match any other existing fields color wise.

5. Pagination is off by one and includes 1 message from previous page.

Points 1, 2, 3 and 5 should be fixed now. Clicking show more adds messages to the top and keeps scroll position. Point 1 still needs testing but seems to work ok for me.
I'm not yet sure of the best way to style the search box on default theme.

richrd and others added 7 commits April 26, 2020 22:39
@xPaw
Copy link
Member

xPaw commented May 9, 2020

  1. Do we want the 'show more messages' to automatically load when scrolling up? It doesn't at the moment.
  2. For the sake of styling, should we also use the search icon on desktop? That way the search input won't stand out, and when focused we can make it stand out with styles.
  3. Clicking a channel in message produces this:
vue.js:108 TypeError: Cannot read property 'network' of null
    at Object.<anonymous> (store.js:161)
    at VueComponent.onClick (InlineChannel.vue:17)

I think because there is no 'activeChannel'.

@xPaw xPaw added this to the 4.2.0 milestone May 9, 2020
@@ -170,10 +170,12 @@ export function generateChannelContextMenu($root, channel, network) {
}

export function generateUserContextMenu($root, channel, network, user) {
const currentChannelUser = channel.users.find((u) => u.nick === network.nick) || {};
const currentChannelUser = channel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(channel && channel.users.find((u) => u.nick === network.nick)) || {} is slightly cleaner

@fnutt
Copy link
Contributor

fnutt commented May 21, 2020

  1. Do we want the 'show more messages' to automatically load when scrolling up? It doesn't at the moment.
  2. For the sake of styling, should we also use the search icon on desktop? That way the search input won't stand out, and when focused we can make it stand out with styles.

Yes to both 1. and 2. please. It would be more consistent with the rest of the client.

Please also add this to the context menus so it is easy to find (e.g. I assume it's normal behaviour to right click a channel in the network-/channel list to search in it).

@cottongin
Copy link

cottongin commented Jul 23, 2020

Some suggestions/comments:

  1. Can you add a way to search directly from the input form? e.g. /search query
  2. I also like the suggestion to make the desktop client-view utilize the search icon and overflow into a separate window like @ already does for mentions. Though I have no strong feelings about it.
  3. I feel like search results should open into their own window/view like other similar features (/banlist, /ignorelist, etc). As it stands now it is not immediately obvious how to "get back" to the channel you searched from. Edit: This would also enable you to return to the search results easily without searching the channel again.
  4. It seems channel activity messages (joins/parts/quits/topic/modes) are ignored when searching, can an option be added to include these? This would be useful for searching for who set a ban in a channel, for example.
  5. Similar to 4, a context option would be nice (like grep -C 5, for example) to also include additional context surrounding a search query.

Edit: I should have mentioned before all of this that I love this PR and it is working great for me. The above comments are mostly nit-picking!

@xPaw xPaw removed this from the 4.2.0 milestone Jul 27, 2020
@vvug
Copy link

vvug commented Sep 4, 2020

Thanks for this, it's great! Will it land in time for 4.3.0?

@richrd richrd added the help wanted Tickets the community can help us with, by either answering questions or sending us PRs. label Oct 1, 2020
@Mstrodl
Copy link
Contributor

Mstrodl commented Jan 21, 2021

@richrd Is there anything specific needed (help-wise, I mean)? From what I saw from the comments above, it seems to be working well for other people.

@fnutt
Copy link
Contributor

fnutt commented Jan 22, 2021

@richrd Is there anything specific needed (help-wise, I mean)? From what I saw from the comments above, it seems to be working well for other people.

At least a rebase has to be done. "Channels with upper case letters in the name cannot be searched" seems to be on the TODO-list, and @xPaw has stated quite a few things that has to be fixed.

There was also some questions about how to filter the search, e.g. search just messages from user X, older than X etc. If this is added the PR may have to be redone regarding the implementation.

Personally I would love to see a rebase, get the channel upper case letters bug fixed, fix @xPaw's review comments, and then merged to master. If we want to add search filter and other stuff later, someone can redo the implementation if needed.

Another option would be to just rebase the PR. Then we can at least use it by running TL from source and merge this PR locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Tickets the community can help us with, by either answering questions or sending us PRs. Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Message search
7 participants