mirror of https://github.com/TriliumNext/Notes
Merge remote-tracking branch 'origin/master' into next
# Conflicts: # package-lock.json # src/public/app/services/note_content_renderer.js # src/public/stylesheets/style.css # src/routes/api/files.js # src/routes/routes.jspull/255/head
commit
7494491560
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,36 @@
|
|||||||
|
import ws from "./ws.js";
|
||||||
|
import appContext from "./app_context.js";
|
||||||
|
|
||||||
|
const fileModificationStatus = {};
|
||||||
|
|
||||||
|
function getFileModificationStatus(noteId) {
|
||||||
|
return fileModificationStatus[noteId];
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileModificationUploaded(noteId) {
|
||||||
|
delete fileModificationStatus[noteId];
|
||||||
|
}
|
||||||
|
|
||||||
|
function ignoreModification(noteId) {
|
||||||
|
delete fileModificationStatus[noteId];
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.subscribeToMessages(async message => {
|
||||||
|
if (message.type !== 'openedFileUpdated') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileModificationStatus[message.noteId] = message;
|
||||||
|
|
||||||
|
appContext.triggerEvent('openedFileUpdated', {
|
||||||
|
noteId: message.noteId,
|
||||||
|
lastModifiedMs: message.lastModifiedMs,
|
||||||
|
filePath: message.filePath
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getFileModificationStatus,
|
||||||
|
fileModificationUploaded,
|
||||||
|
ignoreModification
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
import TabAwareWidget from "./tab_aware_widget.js";
|
||||||
|
import server from "../services/server.js";
|
||||||
|
import fileWatcher from "../services/file_watcher.js";
|
||||||
|
|
||||||
|
const TPL = `
|
||||||
|
<div class="dropdown note-update-status-widget alert alert-warning">
|
||||||
|
<style>
|
||||||
|
.note-update-status-widget {
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<p>File <code class="file-path"></code> has been last modified on <span class="file-last-modified"></span>.</p>
|
||||||
|
|
||||||
|
<div style="display: flex; flex-direction: row; justify-content: space-evenly;">
|
||||||
|
<button class="btn btn-sm file-upload-button">Upload modified file</button>
|
||||||
|
|
||||||
|
<button class="btn btn-sm ignore-this-change-button">Ignore this change</button>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
export default class NoteUpdateStatusWidget extends TabAwareWidget {
|
||||||
|
isEnabled() {
|
||||||
|
return super.isEnabled()
|
||||||
|
&& !!fileWatcher.getFileModificationStatus(this.noteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
doRender() {
|
||||||
|
this.$widget = $(TPL);
|
||||||
|
this.overflowing();
|
||||||
|
|
||||||
|
this.$filePath = this.$widget.find(".file-path");
|
||||||
|
this.$fileLastModified = this.$widget.find(".file-last-modified");
|
||||||
|
this.$fileUploadButton = this.$widget.find(".file-upload-button");
|
||||||
|
|
||||||
|
this.$fileUploadButton.on("click", async () => {
|
||||||
|
await server.post(`notes/${this.noteId}/upload-modified-file`, {
|
||||||
|
filePath: this.$filePath.text()
|
||||||
|
});
|
||||||
|
|
||||||
|
fileWatcher.fileModificationUploaded(this.noteId);
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$ignoreThisChangeButton = this.$widget.find(".ignore-this-change-button");
|
||||||
|
this.$ignoreThisChangeButton.on('click', () => {
|
||||||
|
fileWatcher.ignoreModification(this.noteId);
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshWithNote(note) {
|
||||||
|
const status = fileWatcher.getFileModificationStatus(note.noteId);
|
||||||
|
|
||||||
|
this.$filePath.text(status.filePath);
|
||||||
|
this.$fileLastModified.text(dayjs.unix(status.lastModifiedMs / 1000).format("HH:mm:ss"));
|
||||||
|
}
|
||||||
|
|
||||||
|
openedFileUpdatedEvent(data) {
|
||||||
|
if (data.noteId === this.noteId) {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@ -1 +1 @@
|
|||||||
module.exports = { buildDate:"2021-04-11T22:29:56+02:00", buildRevision: "58e4bd4974275a113c50e4ed7a554987921d55fc" };
|
module.exports = { buildDate:"2021-04-19T22:43:03+02:00", buildRevision: "6136243d6117910b80feafad4fc7121ecc42d794" };
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const Expression = require('./expression');
|
||||||
|
|
||||||
|
class TrueExp extends Expression {
|
||||||
|
execute(inputNoteSet, executionContext) {
|
||||||
|
return inputNoteSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TrueExp;
|
||||||
Loading…
Reference in New Issue