@christianriedl/media 1.0.206 → 1.0.207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.206",
3
+ "version": "1.0.207",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -79,12 +79,13 @@
79
79
  }
80
80
  return idxs;
81
81
  }
82
- async function searchPictures(titlePattern: string, searchPerson: boolean, searchLocation: boolean): Promise<IPictureFile[]> {
82
+ async function searchPictures(titlePattern: string, searchPerson: boolean, searchLocation: boolean, rating: number, maxPictures: number = 200): Promise<IPictureFile[]> {
83
83
  const regex = new RegExp(`^.*${titlePattern.toLowerCase()}.*$`);
84
84
  const root = mediaService.getFolder("ph.all.ye|");
85
85
  const result: IPictureFile[] = [];
86
86
  const personIdxs = searchPerson ? inMediaList ("Picture.Person", regex) : undefined;
87
87
  const locationIdxs = searchLocation ? inMediaList ("Picture.Location", regex) : undefined;
88
+ let count = 0;
88
89
 
89
90
  photos.value.splice(0, photos.value.length);
90
91
  for (let i = 0; i < root.folders.length; i++) {
@@ -98,6 +99,8 @@
98
99
  for (let k = 0; k < album.files.length; k++) {
99
100
  let match = false;
100
101
  const photo = album.files[k] as IPictureFile;
102
+ if (photo.rating < rating)
103
+ continue;
101
104
  if (personIdxs && photo.personIdxs) {
102
105
  for (let l = 0; l < photo.personIdxs.length; l++) {
103
106
  if (personIdxs.includes (photo.personIdxs[l])) {
@@ -112,16 +115,22 @@
112
115
  if (regex.test (photo.name.toLowerCase()))
113
116
  match = true;
114
117
 
115
- if (match)
116
- result.push(photo);
118
+ if (match) {
119
+ count++;
120
+ if (result.length < maxPictures)
121
+ result.push(photo);
122
+ }
117
123
  }
118
124
  }
119
125
  }
120
126
  }
127
+ if (result.length >= maxPictures) {
128
+ alert (`Too many pictures (${count}) found, limit : ${result.length}`)
129
+ }
121
130
  return result;
122
131
  }
123
132
  async function onSearch() {
124
- const list = await searchPictures (title.value, withPerson.value, withLocation.value);
133
+ const list = await searchPictures (title.value, withPerson.value, withLocation.value, mediaService.photoSelection.rating, isMobile ? 200 : 500);
125
134
  photos.value.splice(0, photos.value.length, ...list);
126
135
  console.log(photos.value.length);
127
136
  }