Fix sqlite tests?

This commit is contained in:
Max Leiter 2022-05-31 15:06:45 -07:00
parent db5eae414c
commit 8f27e03b40
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
8 changed files with 16 additions and 16 deletions

View file

@ -111,7 +111,7 @@ export default defineComponent({
}); });
onMounted(() => { onMounted(() => {
searchInput.value = String(route.query.q); searchInput.value = String(route.query.q || "");
searchOpened.value = onSearchPage.value; searchOpened.value = onSearchPage.value;
if (searchInputField.value && !searchInput.value && searchOpened.value) { if (searchInputField.value && !searchInput.value && searchOpened.value) {

View file

@ -3,7 +3,7 @@
v-if="activeChannel" v-if="activeChannel"
:network="activeChannel.network" :network="activeChannel.network"
:channel="activeChannel.channel" :channel="activeChannel.channel"
:focused="String(route.query.focused)" :focused="String(route.query.focused || '')"
@channel-changed="channelChanged" @channel-changed="channelChanged"
/> />
</template> </template>
@ -27,7 +27,7 @@ export default defineComponent({
const store = useStore(); const store = useStore();
const activeChannel = computed(() => { const activeChannel = computed(() => {
const chanId = parseInt(String(route.params.id), 10); const chanId = parseInt(String(route.params.id || ""), 10);
const channel = store.getters.findChannel(chanId); const channel = store.getters.findChannel(chanId);
return channel; return channel;
}); });

View file

@ -28,8 +28,8 @@ export default defineComponent({
const networkData = ref<NetworkFormDefaults | null>(null); const networkData = ref<NetworkFormDefaults | null>(null);
const setNetworkData = () => { const setNetworkData = () => {
socket.emit("network:get", String(route.params.uuid)); socket.emit("network:get", String(route.params.uuid || ""));
networkData.value = store.getters.findNetwork(String(route.params.uuid)); networkData.value = store.getters.findNetwork(String(route.params.uuid || ""));
}; };
const handleSubmit = (data: {uuid: string; name: string}) => { const handleSubmit = (data: {uuid: string; name: string}) => {

View file

@ -141,7 +141,7 @@ export default defineComponent({
}); });
const chan = computed(() => { const chan = computed(() => {
const chanId = parseInt(String(route.params.id), 10); const chanId = parseInt(String(route.params.id || ""), 10);
return store.getters.findChannel(chanId); return store.getters.findChannel(chanId);
}); });
@ -198,7 +198,7 @@ export default defineComponent({
socket.emit("search", { socket.emit("search", {
networkUuid: network.value?.uuid, networkUuid: network.value?.uuid,
channelName: channel.value?.name, channelName: channel.value?.name,
searchTerm: String(route.query.q), searchTerm: String(route.query.q || ""),
offset: offset.value, offset: offset.value,
}); });
}; };
@ -217,7 +217,7 @@ export default defineComponent({
socket.emit("search", { socket.emit("search", {
networkUuid: network.value?.uuid, networkUuid: network.value?.uuid,
channelName: channel.value?.name, channelName: channel.value?.name,
searchTerm: String(route.query.q), searchTerm: String(route.query.q || ""),
offset: offset.value + 1, offset: offset.value + 1,
}); });
}; };

View file

@ -127,7 +127,7 @@ Mousetrap.bind(["alt+/"], async function (e) {
return false; return false;
}); });
function jumpToChannel(targetChannel) { function jumpToChannel(targetChannel: ClientChan) {
switchToChannel(targetChannel); switchToChannel(targetChannel);
const element = document.querySelector( const element = document.querySelector(

View file

@ -240,8 +240,8 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
select += " ORDER BY time DESC LIMIT ? OFFSET ? "; select += " ORDER BY time DESC LIMIT ? OFFSET ? ";
params.push(maxResults.toString()); params.push(maxResults.toString());
const offset = parseInt(query.offset, 10) || 0; query.offset = parseInt(query.offset as string, 10) || 0;
params.push(query.offset); params.push(String(query.offset));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.database.all(select, params, (err, rows) => { this.database.all(select, params, (err, rows) => {
@ -252,8 +252,8 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
searchTerm: query.searchTerm, searchTerm: query.searchTerm,
target: query.channelName, target: query.channelName,
networkUuid: query.networkUuid, networkUuid: query.networkUuid,
offset: offset, offset: query.offset as number,
results: parseSearchRowsToMessages(query.offset, rows).reverse(), results: parseSearchRowsToMessages(query.offset as number, rows).reverse(),
}; };
resolve(response); resolve(response);
} }
@ -269,7 +269,7 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
export default SqliteMessageStorage; export default SqliteMessageStorage;
// TODO: type any // TODO: type any
function parseSearchRowsToMessages(id: string, rows: any[]) { function parseSearchRowsToMessages(id: number, rows: any[]) {
const messages: Msg[] = []; const messages: Msg[] = [];
for (const row of rows) { for (const row of rows) {

View file

@ -26,7 +26,7 @@ export type SearchQuery = {
searchTerm: string; searchTerm: string;
networkUuid: string; networkUuid: string;
channelName: string; channelName: string;
offset: string; offset: number | string;
}; };
export type SearchResponse = export type SearchResponse =

View file

@ -3,6 +3,6 @@
"host": "irc.example.com", "host": "irc.example.com",
"port": 7000, "port": 7000,
"duration": 3600, "duration": 3600,
"expires": 1654037554847 "expires": 1654038111401
} }
] ]