Files
discord-decomp/modules/forums/ForumSearchStore.tsx
T
2026-11-01 12:12:55 +02:00

139 lines
3.7 KiB
TypeScript

// Metro module 6079 (f6080).
import ChannelStore from "../../stores/ChannelStore";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c3858_1 = {};
class ForumSearchStore extends Module589.Store {
static displayName = "ForumSearchStore";
initialize() {
this.waitFor(ChannelStore);
}
getSearchQuery(a0) {
return c3858_1[a0]?.query;
}
getSearchLoading(a0) {
let r6 = c3858_1[a0]?.loading;
if (r6 == null) {
r6 = false;
}
return r6;
}
getSearchResults(a0) {
return c3858_1[a0]?.results;
}
getHasSearchResults(a0) {
const r6 = c3858_1[a0];
return r6?.results != null && r6.results.length > 0;
}
}
const forumSearchStore = new ForumSearchStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c3858_1 = {};
},
THREAD_DELETE: function handleThreadDelete({ channel }) {
const parent_id = channel.parent_id;
if (parent_id == null) {
return false;
}
const r5 = c3858_1[parent_id];
if (r5 == null) {
return false;
}
const results = r5.results;
c3858_1[parent_id] = {
...r5,
results: results == null ? void 0 : results.filter((result) => channel.id !== result)
};
},
CHANNEL_DELETE: function handleChannelDelete(a0) {
return delete c3858_1[a0.channel.id];
},
FORUM_SEARCH_QUERY_UPDATED: function handleForumSearchQueryUpdated({ channelId, query }) {
const channel2 = ChannelStore.getChannel(channelId);
if (!(channel2 == null || !channel2.isForumLikeChannel())) {
let r17 = c3858_1[channelId];
if (r17 == null) {
r17 = {
query: null,
loading: false,
results: null
};
}
c3858_1[channelId] = r17;
c3858_1[channelId] = {
...r17,
query
};
return void 0;
}
return false;
},
FORUM_SEARCH_START: function handleForumSearchStart({ channelId }) {
const channel2 = ChannelStore.getChannel(channelId);
if (!(channel2 == null || !channel2.isForumLikeChannel())) {
let r16 = c3858_1[channelId];
if (r16 == null) {
r16 = {
query: null,
loading: false,
results: null
};
}
c3858_1[channelId] = r16;
c3858_1[channelId] = {
...r16,
loading: true
};
return void 0;
}
return false;
},
FORUM_SEARCH_SUCCESS: function handleForumSearchSuccess({ channelId, threadIds }) {
const channel2 = ChannelStore.getChannel(channelId);
if (!(channel2 == null || !channel2.isForumLikeChannel())) {
let r17 = c3858_1[channelId];
if (r17 == null) {
r17 = {
query: null,
loading: false,
results: null
};
}
c3858_1[channelId] = r17;
c3858_1[channelId] = {
...r17,
loading: false,
results: threadIds
};
return void 0;
}
return false;
},
FORUM_SEARCH_FAILURE: function handleForumSearchFailure({ channelId }) {
const channel2 = ChannelStore.getChannel(channelId);
if (!(channel2 == null || !channel2.isForumLikeChannel())) {
let r16 = c3858_1[channelId];
if (r16 == null) {
r16 = {
query: null,
loading: false,
results: null
};
}
c3858_1[channelId] = r16;
c3858_1[channelId] = {
...r16,
loading: false,
results: []
};
return void 0;
}
return false;
},
FORUM_SEARCH_CLEAR: function handleForumSearchClear({ channelId }) {
const channel2 = ChannelStore.getChannel(channelId);
return !!!(channel2 == null || !channel2.isForumLikeChannel()) && delete c3858_1[channelId];
}
});
export default forumSearchStore;