Skip to content
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 js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/components/ImageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ export default {
const putUrl = origin + join(dirname(pathname), fullName)
logger.debug('Saving image...', { putUrl, src: this.src, fullName })

// toBlob is not very smart...
mimeType = mimeType.replace('jpg', 'jpeg')

// Sanity check, 0 < quality < 1
quality = Math.max(Math.min(quality, 1), 0) || 1

try {
const blob = await new Promise(resolve => imageCanvas.toBlob(resolve, mimeType, quality))
const response = await axios.put(putUrl, new File([blob], fullName))
Expand Down
22 changes: 5 additions & 17 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ export default {
// If the callback creates a new entry in browser history
// the title update will affect the new entry
// rather then the previous one.
this.onClose()
this.Viewer.onClose()

// swap back original title
const title = document.getElementsByTagName('head')[0].getElementsByTagName('title')[0]
Expand All @@ -855,7 +855,7 @@ export default {

const fileInfo = this.fileList[this.currentIndex]
this.openFileFromList(fileInfo)
this.onPrev(fileInfo, oldFileInfo)
this.Viewer.onPrev(fileInfo, oldFileInfo)
this.updateTitle(this.currentFile.basename)
},

Expand All @@ -871,7 +871,7 @@ export default {

const fileInfo = this.fileList[this.currentIndex]
this.openFileFromList(fileInfo)
this.onNext(fileInfo, oldFileInfo)
this.Viewer.onNext(fileInfo, oldFileInfo)
this.updateTitle(this.currentFile.basename)
},

Expand Down Expand Up @@ -925,18 +925,6 @@ export default {
}
},

onPrev(info, oldFileInfo) {
this.Viewer.onPrev(info, oldFileInfo)
},

onNext(info, oldFileInfo) {
this.Viewer.onNext(info, oldFileInfo)
},

onClose() {
this.Viewer.onClose()
},

async onDelete() {
try {
const fileid = this.currentFile.fileid
Expand All @@ -945,12 +933,12 @@ export default {
await axios.delete(url)
emit('files:file:deleted', { fileid })

// fileid is not unique, basename is
const currentIndex = this.fileList.findIndex(file => file.basename === this.currentFile.basename)
if (this.hasPrevious || this.hasNext) {
// Checking the previous or next file
this.hasPrevious ? this.previous() : this.next()

// fileid is not unique, basename is
const currentIndex = this.fileList.findIndex(file => file.basename === this.currentFile.basename)
this.fileList.splice(currentIndex, 1)
} else {
this.close()
Expand Down