[READ-ONLY] Mirror of https://github.com/probablykasper/kadium. App for staying ontop of YouTube channels' uploads kadium.kasper.space
linux macos notifications tauri windows youtube
0

Configure Feed

Select the types of activity you want to include in your feed.

Add channel filter

Kasper (Nov 6, 2021, 2:54 AM +0100) 00ea5712 ed8acafc

+60 -17
+25 -8
src-tauri/src/db.rs
··· 133 133 pub struct Options { 134 134 show_all: bool, 135 135 show_archived: bool, 136 + channel_filter: String, 136 137 } 137 138 138 139 #[command] 139 140 pub async fn get_videos(options: Options, data: DataState<'_>) -> Result<Value, String> { 140 141 let data = data.0.lock().await; 141 - let query_str = if options.show_all { 142 - "SELECT * FROM videos" 143 - } else if options.show_archived { 144 - "SELECT * FROM videos WHERE archived = 1" 145 - } else { 146 - "SELECT * FROM videos WHERE archived = 0" 147 - }; 148 - let query = sqlx::query_as(query_str); 142 + let mut selects = vec!["*"]; 143 + let mut wheres = Vec::new(); 144 + if options.channel_filter != "" { 145 + selects.push("INSTR(channelName, ?) channelFilter"); 146 + wheres.push("channelFilter > 0"); 147 + } 148 + if !options.show_all { 149 + if options.show_archived { 150 + wheres.push("archived = 1"); 151 + } else { 152 + wheres.push("archived = 0"); 153 + } 154 + } 155 + 156 + let mut query_str = "SELECT ".to_owned() + &selects.join(",") + " FROM videos"; 157 + if wheres.len() > 0 { 158 + query_str.push_str(" WHERE "); 159 + query_str.push_str(&wheres.join(" AND ")); 160 + } 161 + 162 + let mut query = sqlx::query_as(&query_str); 163 + if options.channel_filter != "" { 164 + query = query.bind(&options.channel_filter); 165 + } 149 166 let videos: Vec<Video> = match query.fetch_all(&data.db_pool).await { 150 167 Ok(videos) => videos, 151 168 Err(e) => throw!("Error getting videos: {}", e),
+28 -9
src/lib/Nav.svelte
··· 45 45 <a on:mousedown={go} use:active href="/settings"><button>Settings</button></a> 46 46 </nav> 47 47 <div class="options-bar"> 48 - <button class="group" on:keydown={showGroupKeydown}> 48 + <div class="form-item group" on:keydown={showGroupKeydown} tabindex="0"> 49 49 <div class="item" class:selected={show === 0} on:mousedown={() => (show = 0)}>New</div> 50 50 <div class="item" class:selected={show === 1} on:mousedown={() => (show = 1)}>Archived</div> 51 51 <div class="item" class:selected={show === 2} on:mousedown={() => (show = 2)}>All</div> 52 - </button> 52 + </div> 53 + <input 54 + class="form-item" 55 + type="text" 56 + placeholder="Channel" 57 + bind:value={$viewOptions.channel_filter} /> 53 58 </div> 54 59 55 60 <style lang="sass"> ··· 83 88 padding-bottom: 10px 84 89 align-items: center 85 90 display: flex 86 - button.group 91 + .form-item 92 + border-radius: 3px 93 + border: 1px solid hsl(233, 7%, 22%) 94 + background-color: hsla(223, 33%, 64%, 0.12) 95 + outline: none 96 + margin: 0px 97 + margin-right: 12px 98 + font-size: 13px 99 + .group 87 100 display: flex 88 101 color: inherit 89 - border: 1px solid hsl(233, 7%, 22%) 90 - border-radius: 3px 91 - background-color: hsla(223, 33%, 64%, 0.12) 92 102 padding: 0px 93 - margin: 0px 94 103 outline: none 104 + cursor: default 105 + height: 26px 106 + line-height: 26px 107 + box-sizing: border-box 95 108 &:focus 96 109 border-color: hsla(220, 100%, 50%, 1) 97 110 box-shadow: 0px 0px 0px 3px hsla(220, 100%, 50%, 0.5) ··· 100 113 .item 101 114 background-color: transparent 102 115 border: none 103 - font-size: 13px 104 116 margin: 0px 105 - padding: 4px 12px 117 + padding: 0px 12px 106 118 &.selected 107 119 background-color: hsl(225, 14%, 28%) 120 + input 121 + height: 26px 122 + box-sizing: border-box 123 + padding: 0px 6px 124 + &:focus 125 + border-color: hsla(220, 100%, 50%, 1) 126 + box-shadow: 0px 0px 0px 3px hsla(220, 100%, 50%, 0.5) 108 127 </style>
+2
src/lib/data.ts
··· 89 89 export type ViewOptions = { 90 90 show_all: boolean 91 91 show_archived: boolean 92 + channel_filter: string 92 93 } 93 94 export const viewOptions: Writable<ViewOptions> = writable({ 94 95 show_all: false, 95 96 show_archived: false, 97 + channel_filter: '', 96 98 })
+5
src/lib/filters.ts
··· 1 + import { writable } from 'svelte/store' 2 + 3 + export const show_all = writable(false) 4 + export const show_archived = writable(false) 5 + export const channel_filter = writable('')