diff --git a/backend/app.js b/backend/app.js
index e38ecbe..173e6ed 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -1072,6 +1072,7 @@ app.post('/api/getAllFiles', optionalJwt, async function (req, res) {
let sort = req.body.sort;
let range = req.body.range;
let text_search = req.body.text_search;
+ let file_type_filter = req.body.file_type_filter;
const uuid = req.isAuthenticated() ? req.user.uid : null;
const filter_obj = {user_uid: uuid};
@@ -1083,6 +1084,9 @@ app.post('/api/getAllFiles', optionalJwt, async function (req, res) {
filter_obj['$text'] = { $search: utils.createEdgeNGrams(text_search) };
}
}
+
+ if (file_type_filter === 'audio_only') filter_obj['isAudio'] = true;
+ else if (file_type_filter === 'video_only') filter_obj['isAudio'] = false;
files = await db_api.getRecords('files', filter_obj, false, sort, range, text_search);
let file_count = await db_api.getRecords('files', filter_obj, true);
diff --git a/src/app/components/recent-videos/recent-videos.component.html b/src/app/components/recent-videos/recent-videos.component.html
index b56b0bc..14511d8 100644
--- a/src/app/components/recent-videos/recent-videos.component.html
+++ b/src/app/components/recent-videos/recent-videos.component.html
@@ -46,8 +46,20 @@
- 0" (page)="pageChangeEvent($event)" [length]="file_count"
- [pageSize]="pageSize"
- [pageSizeOptions]="[5, 10, 25, 100, this.paged_data && this.paged_data.length > 100 ? this.paged_data.length : 250]">
-
+
+
+
+ File type
+
+ Both
+ Video only
+ Audio only
+
+
+
+
0" (page)="pageChangeEvent($event)" [length]="file_count"
+ [pageSize]="pageSize"
+ [pageSizeOptions]="[5, 10, 25, 100, this.paged_data && this.paged_data.length > 100 ? this.paged_data.length : 250]">
+
+
\ No newline at end of file
diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts
index 566bf4e..d6ff044 100644
--- a/src/app/components/recent-videos/recent-videos.component.ts
+++ b/src/app/components/recent-videos/recent-videos.component.ts
@@ -52,6 +52,7 @@ export class RecentVideosComponent implements OnInit {
}
};
filterProperty = this.filterProperties['upload_date'];
+ fileTypeFilter = 'both';
playlists = null;
@@ -94,12 +95,18 @@ export class RecentVideosComponent implements OnInit {
}
});
- // set filter property to cached
+ // set filter property to cached value
const cached_filter_property = localStorage.getItem('filter_property');
if (cached_filter_property && this.filterProperties[cached_filter_property]) {
this.filterProperty = this.filterProperties[cached_filter_property];
}
+ // set file type filter to cached value
+ const cached_file_type_filter = localStorage.getItem('file_type_filter');
+ if (cached_file_type_filter) {
+ this.fileTypeFilter = cached_file_type_filter;
+ }
+
this.searchChangedSubject
.debounceTime(500)
.pipe(distinctUntilChanged()
@@ -131,6 +138,11 @@ export class RecentVideosComponent implements OnInit {
this.getAllFiles();
}
+ fileTypeFilterChanged(value) {
+ localStorage.setItem('file_type_filter', value);
+ this.getAllFiles();
+ }
+
toggleModeChange() {
this.descendingMode = !this.descendingMode;
this.getAllFiles();
@@ -143,7 +155,7 @@ export class RecentVideosComponent implements OnInit {
const current_file_index = (this.paginator?.pageIndex ? this.paginator.pageIndex : 0)*this.pageSize;
const sort = {by: this.filterProperty['property'], order: this.descendingMode ? -1 : 1};
const range = [current_file_index, current_file_index + this.pageSize];
- this.postsService.getAllFiles(sort, range, this.search_mode ? this.search_text : null).subscribe(res => {
+ this.postsService.getAllFiles(sort, range, this.search_mode ? this.search_text : null, this.fileTypeFilter).subscribe(res => {
this.file_count = res['file_count'];
this.paged_data = res['files'];
for (let i = 0; i < this.paged_data.length; i++) {
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts
index e978a15..c0c8b56 100644
--- a/src/app/posts.services.ts
+++ b/src/app/posts.services.ts
@@ -238,8 +238,8 @@ export class PostsService implements CanActivate {
return this.http.post(this.path + 'getFile', {uid: uid, type: type, uuid: uuid}, this.httpOptions);
}
- getAllFiles(sort, range, text_search) {
- return this.http.post(this.path + 'getAllFiles', {sort: sort, range: range, text_search: text_search}, this.httpOptions);
+ getAllFiles(sort, range, text_search, file_type_filter) {
+ return this.http.post(this.path + 'getAllFiles', {sort: sort, range: range, text_search: text_search, file_type_filter: file_type_filter}, this.httpOptions);
}
getFullTwitchChat(id, type, uuid = null, sub = null) {