Skip to content

feat: add Clear History option in Settings #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 25, 2025
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pub fn run() {
add_last_watched,
backup_favs,
restore_favs,
abort_download
abort_download,
clear_history
])
.setup(|app| {
app.manage(Mutex::new(AppState {
Expand Down Expand Up @@ -511,3 +512,8 @@ fn backup_favs(id: i64, path: String) -> Result<(), String> {
fn restore_favs(id: i64, path: String) -> Result<(), String> {
utils::restore_favs(id, path).map_err(map_err_frontend)
}

#[tauri::command(async)]
fn clear_history() -> Result<(), String> {
sql::clear_history().map_err(map_err_frontend)
}
13 changes: 13 additions & 0 deletions src-tauri/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,3 +1207,16 @@ pub fn add_last_watched(id: i64) -> Result<()> {
)?;
Ok(())
}

pub fn clear_history() -> Result<()> {
let sql = get_conn()?;
sql.execute(
r#"
UPDATE channels
SET last_watched = NULL
WHERE last_watched IS NOT NULL
"#,
params![],
)?;
Ok(())
}
10 changes: 10 additions & 0 deletions src/app/settings/settings.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ button:hover .nuke {
transform: scale(125%);
}

button .history {
width: 1.5rem;
height: 1.5rem;
transition: transform 0.3s ease;
}

button:hover .history {
transform: scale(125%);
}

.folder {
height: 1rem;
width: 1rem;
Expand Down
11 changes: 11 additions & 0 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ <h2 class="mt-4 mb-4 text-center">Sources</h2>
/>
</svg>
</button>
<button
[disabled]="memory.Loading"
(click)="clearHistory()"
class="btn btn-secondary d-inline-flex align-items-center"
>
Clear history
<svg class="history ms-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor"
d="M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.89,15.89L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3" />
</svg>
</button>
<button
ngbTooltip="Use this if an upgrade didn't fix a bug you're experiencing"
class="btn btn-danger d-inline-flex align-items-center"
Expand Down
10 changes: 10 additions & 0 deletions src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ export class SettingsComponent {
this.memory.ModalRef.componentInstance.name = "ConfirmDeleteModal";
}

async clearHistory() {
await this.memory.tryIPC(
"History cleared successfully",
"Failed to clear history",
async () => {
await invoke("clear_history");
}
);
}

ngOnDestroy(): void {
this.subscriptions.forEach((x) => x.unsubscribe());
}
Expand Down
Loading