mirror of
https://github.com/documize/community.git
synced 2025-08-05 05:25:27 +02:00
Provide in-app What's New & new release notifications
This commit is contained in:
parent
97cc5374f0
commit
eaf46f06c1
25 changed files with 1166 additions and 772 deletions
|
@ -9,6 +9,7 @@
|
|||
//
|
||||
// https://documize.com
|
||||
|
||||
import $ from 'jquery';
|
||||
import { htmlSafe } from '@ember/string';
|
||||
import { resolve } from 'rsvp';
|
||||
import Service, { inject as service } from '@ember/service';
|
||||
|
@ -63,6 +64,7 @@ export default Service.extend({
|
|||
|
||||
return this.get('ajax').request('public/meta').then((response) => {
|
||||
this.setProperties(response);
|
||||
this.set('version', 'v' + this.get('version'));
|
||||
|
||||
if (requestedRoute === 'secure') {
|
||||
this.setProperties({
|
||||
|
@ -70,12 +72,32 @@ export default Service.extend({
|
|||
allowAnonymousAccess: true,
|
||||
secureMode: true
|
||||
});
|
||||
|
||||
|
||||
this.get('localStorage').clearAll();
|
||||
} else if (is.not.include(requestedUrl, '/auth/')) {
|
||||
this.get('localStorage').storeSessionItem('entryUrl', requestedUrl);
|
||||
}
|
||||
|
||||
let self = this;
|
||||
let cacheBuster = + new Date();
|
||||
$.getJSON(`https://storage.googleapis.com/documize/downloads/updates/meta.json?cb=${cacheBuster}`, function (versions) {
|
||||
let cv = 'v' + versions.community.version;
|
||||
let ev = 'v' + versions.enterprise.version;
|
||||
let re = self.get('edition');
|
||||
let rv = self.get('version');
|
||||
|
||||
self.set('communityLatest', cv);
|
||||
self.set('enterpriseLatest', ev);
|
||||
self.set('updateAvailable', false); // set to true for testing
|
||||
|
||||
if (re === 'Community' && rv < cv) {
|
||||
self.set('updateAvailable', true);
|
||||
}
|
||||
if (re === 'Enterprise' && rv < ev) {
|
||||
self.set('updateAvailable', true);
|
||||
}
|
||||
});
|
||||
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,11 +11,13 @@
|
|||
|
||||
import { inject as service } from '@ember/service';
|
||||
import { computed } from '@ember/object';
|
||||
import { Promise as EmberPromise } from 'rsvp';
|
||||
import SimpleAuthSession from 'ember-simple-auth/services/session';
|
||||
|
||||
export default SimpleAuthSession.extend({
|
||||
ajax: service(),
|
||||
appMeta: service(),
|
||||
userSvc: service('user'),
|
||||
store: service(),
|
||||
localStorage: service(),
|
||||
folderPermissions: null,
|
||||
|
@ -23,11 +25,11 @@ export default SimpleAuthSession.extend({
|
|||
isMac: false,
|
||||
isMobile: false,
|
||||
|
||||
hasAccounts: computed('isAuthenticated', 'session.content.authenticated.user', function() {
|
||||
hasAccounts: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
return this.get('session.authenticator') !== 'authenticator:anonymous' && this.get('session.content.authenticated.user.accounts').length > 0;
|
||||
}),
|
||||
|
||||
accounts: computed('hasAccounts', function() {
|
||||
accounts: computed('hasAccounts', function () {
|
||||
return this.get('session.content.authenticated.user.accounts');
|
||||
}),
|
||||
|
||||
|
@ -35,7 +37,9 @@ export default SimpleAuthSession.extend({
|
|||
if (this.get('isAuthenticated')) {
|
||||
let user = this.get('session.content.authenticated.user') || { id: '0' };
|
||||
let data = this.get('store').normalize('user', user);
|
||||
return this.get('store').push(data);
|
||||
let um = this.get('store').push(data)
|
||||
|
||||
return um;
|
||||
}
|
||||
}),
|
||||
|
||||
|
@ -71,5 +75,21 @@ export default SimpleAuthSession.extend({
|
|||
|
||||
logout() {
|
||||
this.get('localStorage').clearAll();
|
||||
},
|
||||
|
||||
seenNewVersion() {
|
||||
this.get('userSvc').getUser(this.get('user.id')).then((user) => {
|
||||
user.set('lastVersion', this.get('appMeta.version'));
|
||||
this.get('userSvc').save(user);
|
||||
});
|
||||
},
|
||||
|
||||
// set what's new indicator
|
||||
hasWhatsNew() {
|
||||
return new EmberPromise((resolve) => {
|
||||
return this.get('userSvc').getUser(this.get('user.id')).then((user) => {
|
||||
resolve(user.get('lastVersion') !== this.get('appMeta.version'));
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue