fix #81: fix dropbox folder selection

This commit is contained in:
Antelle 2016-03-14 08:16:33 +03:00
parent a75a1bc66c
commit 0de302c61b
5 changed files with 16 additions and 6 deletions

View File

@ -248,7 +248,6 @@ var DropboxLink = {
var isSelfHostedApp = !/^http(s?):\/\/localhost:8085/.test(location.href) &&
!/http(s?):\/\/antelle\.github\.io\/keeweb/.test(location.href) &&
!/http(s?):\/\/app\.keeweb\.info/.test(location.href);
isSelfHostedApp = true;
return Launcher || !isSelfHostedApp || getKey() !== DropboxKeys.AppFolderKeyParts.join('');
},

View File

@ -2,6 +2,7 @@
var DropboxLink = require('../comp/dropbox-link'),
AppSettingsModel = require('../models/app-settings-model'),
Locale = require('../util/locale'),
UrlUtils = require('../util/url-util'),
Logger = require('../util/logger');
@ -128,7 +129,7 @@ var StorageDropbox = {
if (err) { return callback(err); }
DropboxLink.list(that._toFullPath(''), function(err, files, dirStat, filesStat) {
if (err) { return callback(err); }
var result = filesStat
var fileList = filesStat
.filter(function(f) { return !f.isFolder && !f.isRemoved; })
.map(function(f) {
return {
@ -137,7 +138,8 @@ var StorageDropbox = {
rev: f.versionTag
};
});
callback(null, result);
var dir = dirStat.inAppFolder ? Locale.openAppFolder : UrlUtils.trimStartSlash(dirStat.path);
callback(null, fileList, dir);
});
});
}

View File

@ -118,7 +118,8 @@ var Locale = {
openDropHere: 'drop files here',
openFailedRead: 'Failed to read file',
openNothingFound: 'Nothing found',
openNothingFoundBody: 'No files which could be opened.',
openNothingFoundBody: 'No files which could be opened (files are searched inside {} folder).',
openAppFolder: 'app',
openSelectFile: 'Select a file',
openSelectFileBody: 'Select a file which you would like to open',
openPassFor: 'Password for',

View File

@ -3,6 +3,7 @@
var UrlUtil = {
multiSlashRegex: /\/{2,}/g,
lastPartRegex: /[^\/]+$/,
trimStartSlashRegex: /^\\/,
getDataFileName: function(url) {
var ix = url.lastIndexOf('/');
@ -19,6 +20,10 @@ var UrlUtil = {
fileToDir: function(url) {
return url.replace(this.lastPartRegex, '');
},
trimStartSlash: function(url) {
return url.replace(this.trimStartSlashRegex, '');
}
};

View File

@ -503,7 +503,7 @@ var OpenView = Backbone.View.extend({
var that = this;
that.busy = true;
icon.toggleClass('flip3d', true);
storage.list(function(err, files) {
storage.list(function(err, files, dir) {
icon.toggleClass('flip3d', false);
that.busy = false;
if (err || !files) {
@ -518,7 +518,10 @@ var OpenView = Backbone.View.extend({
allStorageFiles[file.path] = file;
});
if (!buttons.length) {
Alerts.error({ header: Locale.openNothingFound, body: Locale.openNothingFoundBody });
Alerts.error({
header: Locale.openNothingFound,
body: Locale.openNothingFoundBody.replace('{}', dir)
});
return;
}
buttons.push({result: '', title: Locale.alertCancel});