Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src-angular/app/core/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,19 @@ export class SearchService {
return timer(2000).pipe(mergeMap(() => caught))
}
}),
tap(response => {
tap(async (response) => {
this.searchLoading = false

// TODO: Do this operation at the start of the app and when downloading new songs instead of at every search ?
const songs = await window.electron.invoke.readDirectory()

// TODO: Add a toggle in the option to show/hide downloaded songs
// ! Currently this only works if the user have "artist", "name" and "charter" in the chartFolderName setting
// ! Maybe add a way to make it work everytime ? Or make this option require the user to have those 3 in the setting
response.data = response.data.filter(c => {
return !songs.some(s => s.includes(c.artist!) && s.includes(c.name!) && s.includes(c.charter!))
})

if (!nextPage) {
// Don't reload results if they are the same
if (this.groupedSongs
Expand Down
5 changes: 3 additions & 2 deletions src-electron/IpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { download } from './ipc/DownloadHandler.ipc.js'
import { scanIssues } from './ipc/issue-scan/IssueScanHandler.ipc.js'
import { getSettings, setSettings } from './ipc/SettingsHandler.ipc.js'
import { downloadUpdate, getCurrentVersion, getUpdateAvailable, quitAndInstall, retryUpdate } from './ipc/UpdateHandler.ipc.js'
import { getPlatform, getThemeColors, isMaximized, maximize, minimize, openUrl, quit, restore, showFile, showFolder, showOpenDialog, toggleDevTools } from './ipc/UtilHandlers.ipc.js'
import { getPlatform, getThemeColors, isMaximized, maximize, minimize, openUrl, quit, restore, showFile, showFolder, showOpenDialog, toggleDevTools, readDirectory } from './ipc/UtilHandlers.ipc.js'

export function getIpcInvokeHandlers(): IpcInvokeHandlers {
return {
Expand All @@ -14,6 +14,7 @@ export function getIpcInvokeHandlers(): IpcInvokeHandlers {
isMaximized,
showOpenDialog,
getThemeColors,
readDirectory
}
}

Expand All @@ -32,6 +33,6 @@ export function getIpcToMainEmitHandlers(): IpcToMainEmitHandlers {
quit,
showFile,
showFolder,
scanIssues,
scanIssues
}
}
5 changes: 5 additions & 0 deletions src-electron/ipc/UtilHandlers.ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fsExtra from 'fs-extra'

import { ThemeColors } from '../../src-shared/interfaces/theme.interface.js'
import { mainWindow } from '../main.js'
import { settings } from './SettingsHandler.ipc.js'

/**
* Opens `url` in the default browser.
Expand Down Expand Up @@ -58,3 +59,7 @@ export async function getThemeColors(path: string) {
return null
}
}

export async function readDirectory() {
return await fsExtra.readdir(settings.libraryPath || '')
}
1 change: 1 addition & 0 deletions src-electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const electronApi: ContextBridgeApi = {
isMaximized: getInvoker('isMaximized'),
showOpenDialog: getInvoker('showOpenDialog'),
getThemeColors: getInvoker('getThemeColors'),
readDirectory: getInvoker('readDirectory'),
},
emit: {
download: getEmitter('download'),
Expand Down
4 changes: 4 additions & 0 deletions src-shared/interfaces/ipc.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export interface IpcInvokeEvents {
input: string
output: ThemeColors | null
}
readDirectory: {
input: void
output: string[]
}
}

export type IpcInvokeHandlers = {
Expand Down