Client updated at
This commit is contained in:
@@ -326,19 +326,16 @@ angular.module('app')
|
||||
|
||||
this.togglePin = function() {
|
||||
this.note.setAppDataItem("pinned", !this.note.pinned);
|
||||
this.note.setDirty(true);
|
||||
this.changesMade();
|
||||
}
|
||||
|
||||
this.toggleLockNote = function() {
|
||||
this.note.setAppDataItem("locked", !this.note.locked);
|
||||
this.note.setDirty(true);
|
||||
this.changesMade();
|
||||
}
|
||||
|
||||
this.toggleArchiveNote = function() {
|
||||
this.note.setAppDataItem("archived", !this.note.archived);
|
||||
this.note.setDirty(true);
|
||||
this.changesMade(true);
|
||||
$rootScope.$broadcast("noteArchived");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,14 @@ angular.module('app')
|
||||
|
||||
this.loadPreferences = function() {
|
||||
let prevSortValue = this.sortBy;
|
||||
|
||||
this.sortBy = authManager.getUserPrefValue("sortBy", "created_at");
|
||||
|
||||
if(this.sortBy == "updated_at") {
|
||||
// use client_updated_at instead
|
||||
this.sortBy = "client_updated_at";
|
||||
}
|
||||
|
||||
if(prevSortValue && prevSortValue != this.sortBy) {
|
||||
$timeout(() => {
|
||||
this.selectFirstNote();
|
||||
@@ -120,7 +127,7 @@ angular.module('app')
|
||||
var base = "";
|
||||
if(this.sortBy == "created_at") {
|
||||
base += " Date Added";
|
||||
} else if(this.sortBy == "updated_at") {
|
||||
} else if(this.sortBy == "client_updated_at") {
|
||||
base += " Date Modifed";
|
||||
} else if(this.sortBy == "title") {
|
||||
base += " Title";
|
||||
@@ -274,7 +281,7 @@ angular.module('app')
|
||||
}
|
||||
|
||||
this.selectedSortByUpdated = function() {
|
||||
this.setSortBy("updated_at");
|
||||
this.setSortBy("client_updated_at");
|
||||
this.sortDescending = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ class Item {
|
||||
this.updated_at = new Date();
|
||||
}
|
||||
|
||||
// Allows the getter to be re-invoked
|
||||
this._client_updated_at = null;
|
||||
|
||||
if(json.content) {
|
||||
this.mapContentToLocalProperties(this.contentObject);
|
||||
} else if(json.deleted == true) {
|
||||
@@ -68,7 +71,7 @@ class Item {
|
||||
// Subclasses can override
|
||||
}
|
||||
|
||||
setDirty(dirty) {
|
||||
setDirty(dirty, dontUpdateClientDate) {
|
||||
this.dirty = dirty;
|
||||
|
||||
// Allows the syncManager to check if an item has been marked dirty after a sync has been started
|
||||
@@ -81,6 +84,11 @@ class Item {
|
||||
this.dirtyCount = 0;
|
||||
}
|
||||
|
||||
if(dirty && !dontUpdateClientDate) {
|
||||
// Set the client modified date to now if marking the item as dirty
|
||||
this.client_updated_at = new Date();
|
||||
}
|
||||
|
||||
if(dirty) {
|
||||
this.notifyObserversOfChange();
|
||||
}
|
||||
@@ -214,6 +222,24 @@ class Item {
|
||||
return this.getAppDataItem("locked");
|
||||
}
|
||||
|
||||
get client_updated_at() {
|
||||
if(!this._client_updated_at) {
|
||||
var saved = this.getAppDataItem("client_updated_at");
|
||||
if(saved) {
|
||||
this._client_updated_at = new Date(saved);
|
||||
} else {
|
||||
this._client_updated_at = new Date(this.updated_at);
|
||||
}
|
||||
}
|
||||
return this._client_updated_at;
|
||||
}
|
||||
|
||||
set client_updated_at(date) {
|
||||
this._client_updated_at = date;
|
||||
|
||||
this.setAppDataItem("client_updated_at", date);
|
||||
}
|
||||
|
||||
/*
|
||||
During sync conflicts, when determing whether to create a duplicate for an item, we can omit keys that have no
|
||||
meaningful weight and can be ignored. For example, if one component has active = true and another component has active = false,
|
||||
@@ -245,7 +271,7 @@ class Item {
|
||||
}
|
||||
|
||||
updatedAtString() {
|
||||
return this.dateToLocalizedString(this.updated_at);
|
||||
return this.dateToLocalizedString(this.client_updated_at);
|
||||
}
|
||||
|
||||
dateToLocalizedString(date) {
|
||||
|
||||
@@ -410,13 +410,13 @@ class ModelManager {
|
||||
}
|
||||
|
||||
/* Used when changing encryption key */
|
||||
setAllItemsDirty() {
|
||||
setAllItemsDirty(dontUpdateClientDates = true) {
|
||||
var relevantItems = this.allItems.filter(function(item){
|
||||
return _.includes(this.acceptableContentTypes, item.content_type);
|
||||
}.bind(this));
|
||||
|
||||
for(var item of relevantItems) {
|
||||
item.setDirty(true);
|
||||
item.setDirty(true, dontUpdateClientDates);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
%h4.title Sort By
|
||||
|
||||
%menu-row{"label" => "'Date Added'", "circle" => "ctrl.sortBy == 'created_at' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByCreated()", "desc" => "'Sort notes by newest first'"}
|
||||
%menu-row{"label" => "'Date Modified'", "circle" => "ctrl.sortBy == 'updated_at' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByUpdated()", "desc" => "'Sort notes with the most recently updated first'"}
|
||||
%menu-row{"label" => "'Date Modified'", "circle" => "ctrl.sortBy == 'client_updated_at' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByUpdated()", "desc" => "'Sort notes with the most recently updated first'"}
|
||||
%menu-row{"label" => "'Title'", "circle" => "ctrl.sortBy == 'title' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByTitle()", "desc" => "'Sort notes alphabetically by their title'"}
|
||||
|
||||
.section{"ng-if" => "!ctrl.tag.archiveTag"}
|
||||
@@ -64,7 +64,7 @@
|
||||
.note-preview{"ng-if" => "!ctrl.hideNotePreview"}
|
||||
{{note.text}}
|
||||
.date.faded{"ng-if" => "!ctrl.hideDate"}
|
||||
%span{"ng-if" => "ctrl.sortBy == 'updated_at'"} Modified {{note.updatedAtString() || 'Now'}}
|
||||
%span{"ng-if" => "ctrl.sortBy != 'updated_at'"} {{note.createdAtString() || 'Now'}}
|
||||
%span{"ng-if" => "ctrl.sortBy == 'client_updated_at'"} Modified {{note.updatedAtString() || 'Now'}}
|
||||
%span{"ng-if" => "ctrl.sortBy != 'client_updated_at'"} {{note.createdAtString() || 'Now'}}
|
||||
|
||||
%panel-resizer{"panel-id" => "'notes-column'", "on-resize-finish" => "ctrl.onPanelResize", "control" => "ctrl.panelController", "hoverable" => "true", "collapsable" => "true"}
|
||||
|
||||
Reference in New Issue
Block a user