mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
Disable search if we have no message provider
If we have no message provider: - Search input field not renderd - Search endpoint retuns empty resultset Also removed redundancy by setting a main message provider.
This commit is contained in:
parent
fe0178c0d2
commit
de86c144b5
6 changed files with 21 additions and 13 deletions
|
@ -40,7 +40,10 @@
|
|||
:text="channel.topic"
|
||||
/></span>
|
||||
<MessageSearchForm
|
||||
v-if="['channel', 'query'].includes(channel.type)"
|
||||
v-if="
|
||||
$store.state.settings.searchEnabled &&
|
||||
['channel', 'query'].includes(channel.type)
|
||||
"
|
||||
:network="network"
|
||||
:channel="channel"
|
||||
/>
|
||||
|
|
|
@ -109,6 +109,9 @@ export const config = normalizeConfig({
|
|||
}
|
||||
},
|
||||
},
|
||||
searchEnabled: {
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
export function createState() {
|
||||
|
|
|
@ -56,6 +56,7 @@ store = new Vuex.Store({
|
|||
serverHasSettings: false,
|
||||
messageSearchResults: null,
|
||||
messageSearchInProgress: false,
|
||||
searchEnabled: false,
|
||||
},
|
||||
mutations: {
|
||||
appLoaded(state) {
|
||||
|
|
|
@ -63,6 +63,7 @@ function Client(manager, name, config = {}) {
|
|||
messageStorage: [],
|
||||
highlightRegex: null,
|
||||
highlightExceptionRegex: null,
|
||||
messageProvider: undefined,
|
||||
});
|
||||
|
||||
const client = this;
|
||||
|
@ -72,7 +73,8 @@ function Client(manager, name, config = {}) {
|
|||
|
||||
if (!Helper.config.public && client.config.log) {
|
||||
if (Helper.config.messageStorage.includes("sqlite")) {
|
||||
client.messageStorage.push(new MessageStorage(client));
|
||||
client.messageProvider = new MessageStorage(client);
|
||||
client.messageStorage.push(client.messageProvider);
|
||||
}
|
||||
|
||||
if (Helper.config.messageStorage.includes("text")) {
|
||||
|
@ -106,6 +108,8 @@ function Client(manager, name, config = {}) {
|
|||
client.awayMessage = client.config.clientSettings.awayMessage;
|
||||
}
|
||||
|
||||
client.config.clientSettings.searchEnabled = client.messageProvider !== undefined;
|
||||
|
||||
client.compileCustomHighlights();
|
||||
|
||||
_.forOwn(client.config.sessions, (session) => {
|
||||
|
@ -535,8 +539,11 @@ Client.prototype.clearHistory = function (data) {
|
|||
};
|
||||
|
||||
Client.prototype.search = function (query) {
|
||||
const messageStorage = this.messageStorage.find((s) => s.canProvideMessages());
|
||||
return messageStorage.search(query);
|
||||
if (this.messageProvider === undefined) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return this.messageProvider.search(query);
|
||||
};
|
||||
|
||||
Client.prototype.open = function (socketId, target) {
|
||||
|
|
|
@ -236,17 +236,11 @@ Chan.prototype.writeUserLog = function (client, msg) {
|
|||
};
|
||||
|
||||
Chan.prototype.loadMessages = function (client, network) {
|
||||
if (!this.isLoggable()) {
|
||||
if (!this.isLoggable() || !client.messageProvider) {
|
||||
return;
|
||||
}
|
||||
|
||||
const messageStorage = client.messageStorage.find((s) => s.canProvideMessages());
|
||||
|
||||
if (!messageStorage) {
|
||||
return;
|
||||
}
|
||||
|
||||
messageStorage
|
||||
client.messageProvider
|
||||
.getMessages(network, this)
|
||||
.then((messages) => {
|
||||
if (messages.length === 0) {
|
||||
|
|
|
@ -189,7 +189,7 @@ Network.prototype.createIrcFramework = function (client) {
|
|||
|
||||
// Request only new messages from ZNC if we have sqlite logging enabled
|
||||
// See http://wiki.znc.in/Playback
|
||||
if (client.config.log && client.messageStorage.find((s) => s.canProvideMessages())) {
|
||||
if (client.messageProvider) {
|
||||
this.irc.requestCap("znc.in/playback");
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue