|
78 | 78 | </template>
|
79 | 79 |
|
80 | 80 | <script>
|
81 |
| -import { generateFilePath, generateRemoteUrl, generateUrl } from '@nextcloud/router' |
82 |
| -import { getCurrentUser } from '@nextcloud/auth' |
| 81 | +import { generateFilePath, generateUrl } from '@nextcloud/router' |
83 | 82 | import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
|
84 | 83 | import { loadState } from '@nextcloud/initial-state'
|
85 |
| -import { Palette } from 'node-vibrant/lib/color.js' |
86 | 84 | import axios from '@nextcloud/axios'
|
87 | 85 | import debounce from 'debounce'
|
88 | 86 | import NcColorPicker from '@nextcloud/vue/dist/Components/NcColorPicker.js'
|
89 |
| -import Vibrant from 'node-vibrant' |
90 | 87 |
|
91 | 88 | import Check from 'vue-material-design-icons/Check.vue'
|
92 | 89 | import ImageEdit from 'vue-material-design-icons/ImageEdit.vue'
|
@@ -217,9 +214,9 @@ export default {
|
217 | 214 | this.update(result.data)
|
218 | 215 | },
|
219 | 216 |
|
220 |
| - async setFile(path, color = null) { |
| 217 | + async setFile(path) { |
221 | 218 | this.loading = 'custom'
|
222 |
| - const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path, color }) |
| 219 | + const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path }) |
223 | 220 | this.update(result.data)
|
224 | 221 | },
|
225 | 222 |
|
@@ -264,45 +261,7 @@ export default {
|
264 | 261 | }
|
265 | 262 |
|
266 | 263 | this.loading = 'custom'
|
267 |
| - |
268 |
| - // Extract primary color from image |
269 |
| - let response = null |
270 |
| - let color = null |
271 |
| - try { |
272 |
| - const fileUrl = generateRemoteUrl('dav/files/' + getCurrentUser().uid + path) |
273 |
| - response = await axios.get(fileUrl, { responseType: 'blob' }) |
274 |
| - const blobUrl = URL.createObjectURL(response.data) |
275 |
| - const palette = await this.getColorPaletteFromBlob(blobUrl) |
276 |
| - |
277 |
| - // DarkVibrant is accessible AND visually pleasing |
278 |
| - // Vibrant is not accessible enough and others are boring |
279 |
| - color = palette?.DarkVibrant?.hex |
280 |
| - this.setFile(path, color) |
281 |
| - |
282 |
| - // Log data |
283 |
| - console.debug('Extracted colour', color, 'from custom image', path, palette) |
284 |
| - } catch (error) { |
285 |
| - this.setFile(path) |
286 |
| - console.error('Unable to extract colour from custom image', { error, path, response, color }) |
287 |
| - } |
288 |
| - }, |
289 |
| - |
290 |
| - /** |
291 |
| - * Extract a Vibrant color palette from a blob URL |
292 |
| - * |
293 |
| - * @param {string} blobUrl the blob URL |
294 |
| - * @return {Promise<Palette>} |
295 |
| - */ |
296 |
| - getColorPaletteFromBlob(blobUrl) { |
297 |
| - return new Promise((resolve, reject) => { |
298 |
| - const vibrant = new Vibrant(blobUrl) |
299 |
| - vibrant.getPalette((error, palette) => { |
300 |
| - if (error) { |
301 |
| - reject(error) |
302 |
| - } |
303 |
| - resolve(palette) |
304 |
| - }) |
305 |
| - }) |
| 264 | + this.setFile(path) |
306 | 265 | },
|
307 | 266 | },
|
308 | 267 | }
|
|
0 commit comments