mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 14:05:04 +08:00
Merge pull request #5337 from matrix-org/t3chguy/fix/15484
Spec compliance, /search doesn't have to return results
This commit is contained in:
commit
5caad82f9f
@ -360,7 +360,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
|
|||||||
let oldestEventFrom = previousSearchResult.oldestEventFrom;
|
let oldestEventFrom = previousSearchResult.oldestEventFrom;
|
||||||
response.highlights = previousSearchResult.highlights;
|
response.highlights = previousSearchResult.highlights;
|
||||||
|
|
||||||
if (localEvents && serverEvents) {
|
if (localEvents && serverEvents && serverEvents.results) {
|
||||||
// This is a first search call, combine the events from the server and
|
// This is a first search call, combine the events from the server and
|
||||||
// the local index. Note where our oldest event came from, we shall
|
// the local index. Note where our oldest event came from, we shall
|
||||||
// fetch the next batch of events from the other source.
|
// fetch the next batch of events from the other source.
|
||||||
@ -379,7 +379,7 @@ function combineEvents(previousSearchResult, localEvents = undefined, serverEven
|
|||||||
oldestEventFrom = "local";
|
oldestEventFrom = "local";
|
||||||
}
|
}
|
||||||
combineEventSources(previousSearchResult, response, localEvents.results, cachedEvents);
|
combineEventSources(previousSearchResult, response, localEvents.results, cachedEvents);
|
||||||
} else if (serverEvents) {
|
} else if (serverEvents && serverEvents.results) {
|
||||||
// This is a pagination call fetching more events from the server,
|
// This is a pagination call fetching more events from the server,
|
||||||
// meaning that our oldest event was in the local index.
|
// meaning that our oldest event was in the local index.
|
||||||
// Change the source of the oldest event if our server event is older
|
// Change the source of the oldest event if our server event is older
|
||||||
@ -454,7 +454,7 @@ function combineResponses(previousSearchResult, localEvents = undefined, serverE
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreEncryptionInfo(searchResultSlice) {
|
function restoreEncryptionInfo(searchResultSlice = []) {
|
||||||
for (let i = 0; i < searchResultSlice.length; i++) {
|
for (let i = 0; i < searchResultSlice.length; i++) {
|
||||||
const timeline = searchResultSlice[i].context.getTimeline();
|
const timeline = searchResultSlice[i].context.getTimeline();
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ async function combinedPagination(searchResult) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const oldResultCount = searchResult.results.length;
|
const oldResultCount = searchResult.results ? searchResult.results.length : 0;
|
||||||
|
|
||||||
// Let the client process the combined result.
|
// Let the client process the combined result.
|
||||||
const result = client._processRoomEventsSearch(searchResult, response);
|
const result = client._processRoomEventsSearch(searchResult, response);
|
||||||
|
@ -1258,7 +1258,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.state.searchResults.next_batch) {
|
if (!this.state.searchResults.next_batch) {
|
||||||
if (this.state.searchResults.results.length == 0) {
|
if (!this.state.searchResults?.results?.length) {
|
||||||
ret.push(<li key="search-top-marker">
|
ret.push(<li key="search-top-marker">
|
||||||
<h2 className="mx_RoomView_topMarker">{ _t("No results") }</h2>
|
<h2 className="mx_RoomView_topMarker">{ _t("No results") }</h2>
|
||||||
</li>,
|
</li>,
|
||||||
@ -1282,7 +1282,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
let lastRoomId;
|
let lastRoomId;
|
||||||
|
|
||||||
for (let i = this.state.searchResults.results.length - 1; i >= 0; i--) {
|
for (let i = (this.state.searchResults?.results?.length || 0) - 1; i >= 0; i--) {
|
||||||
const result = this.state.searchResults.results[i];
|
const result = this.state.searchResults.results[i];
|
||||||
|
|
||||||
const mxEv = result.context.getEvent();
|
const mxEv = result.context.getEvent();
|
||||||
@ -1944,7 +1944,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
if (this.state.searchResults) {
|
if (this.state.searchResults) {
|
||||||
// show searching spinner
|
// show searching spinner
|
||||||
if (this.state.searchResults.results === undefined) {
|
if (this.state.searchResults.count === undefined) {
|
||||||
searchResultsPanel = (
|
searchResultsPanel = (
|
||||||
<div className="mx_RoomView_messagePanel mx_RoomView_messagePanelSearchSpinner" />
|
<div className="mx_RoomView_messagePanel mx_RoomView_messagePanelSearchSpinner" />
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user