Skip to content

Commit

Permalink
work on #291
Browse files Browse the repository at this point in the history
  • Loading branch information
drive4ik committed Jul 3, 2024
1 parent abe9645 commit f1d3faf
Show file tree
Hide file tree
Showing 14 changed files with 604 additions and 319 deletions.
82 changes: 81 additions & 1 deletion addon/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"message": "OK",
"description": "OK button"
},
"load": {
"message": "Load",
"description": "Load"
},
"save": {
"message": "Save",
"description": "Save"
Expand Down Expand Up @@ -1233,20 +1237,96 @@
"message": "Help",
"description": "Help"
},
"lastUpdateAgo": {
"message": "Last update: $relativeTime$",
"description": "Last update/active relative time",
"placeholders": {
"relativeTime": {
"content": "$1",
"example": "5 days ago"
}
}
},
"syncStart": {
"message": "Start synchronization",
"description": "Start synchronization"
},
"syncEnableTitle": {
"message": "Enable auto backup to the cloud",
"description": "Enable auto backup to the cloud"
},
"syncSettingsLocation": {
"message": "Sync settings location",
"description": "Enable auto backup to the cloud"
},
"githubSecretTitle": {
"message": "Secret",
"description": "Secret"
},
"githubGistCloudSettingsTitle": {
"message": "GitHub Gist cloud settings",
"description": "GitHub Gist cloud settings"
},
"githubGistTokenTitle": {
"message": "Personal access token",
"description": "Github gist Personal access token"
},
"checkGithubGistToken": {
"githubGistCheckToken": {
"message": "Check token",
"description": "Check Github gist personal access token"
},
"githubGistBackupDescription": {
"message": "Simple Tab Groups backup file for cloud sync",
"description": "Simple Tab Groups backup file for cloud sync"
},
"githubCantUploadBackupToGist": {
"message": "Failed to upload the backup to GitHub Gist. Please try again later.",
"description": "Failed to upload the backup to GitHub Gist. Please try again later."
},
"githubCantCreateBackupIntoGist": {
"message": "Cannot create a backup to GitHub Gist. Please try again later.",
"description": "Cannot create a backup to GitHub Gist. Please try again later."
},
"githubInvalidGistContent": {
"message": "GitHub Gist backup has incorrect data",
"description": "GitHub Gist backup has incorrect data"
},
"githubInvalidToken": {
"message": "Your GitHub token is invalid",
"description": "Your GitHub token is invalid"
},
"githubTokenNoAccess": {
"message": "Your GitHub token doesn't have the right access.",
"description": "Your GitHub token doesn't have the right access."
},
"syncOptionLocatedFFSync": {
"message": "Use settings located in Firefox synchronisation",
"description": "Use settings located in Firefox synchronisation"
},
"syncOptionLocatedLocally": {
"message": "Use settings located locally in the current browser profile",
"description": "Use settings located locally in the current browser profile"
},
"browserIsNotFirefox": {
"message": "Your browser is: $browserName$, it doesn't support <a href=\"https://www.mozilla.org/firefox/sync/\" target=\"_blank\" class=\"is-underlined\">Firefox Sync</a>",
"description": "Browser doesn't support FF sync",
"placeholders": {
"browserName": {
"content": "$1",
"example": "some Gecko browser"
}
}
},
"downloadFirefox": {
"message": "Download Firefox",
"description": "Download Firefox"
},
"saveSettings": {
"message": "Save settings",
"description": "Save settings"
},
"ffSyncNotSupported": {
"message": "Firefox sync isn't supported",
"description": "Firefox sync isn't supported"
}
}
14 changes: 0 additions & 14 deletions addon/src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ hr {
display: inline-flex;
}

.is-align-items-center {
align-items: center;
}

.is-column {
flex-direction: column;
}
Expand All @@ -236,16 +232,6 @@ hr {
flex-grow: 1;
}

.is-flex > .is-start,
.is-inline-flex > .is-start {
align-self: flex-start;
}

.is-flex > .is-end,
.is-inline-flex > .is-end {
align-self: flex-end;
}

.tab-discarded {
color: var(--discarded-text-color);
}
Expand Down
4 changes: 4 additions & 0 deletions addon/src/css/startup.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,7 @@ html[data-theme=dark] .select:not(.is-multiple):not(.is-loading):hover::after {
.pr-indent {
padding-right: var(--indent);
}

.indent-gap {
gap: var(--indent);
}
95 changes: 41 additions & 54 deletions addon/src/js/mixins/sync-cloud.mixin.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,52 @@

// import * as Constants from '/js/constants.js';
import Logger from '/js/logger.js';
import Messages from '/js/messages.js';
// import * as Storage from '/js/storage.js';
// import * as Groups from '/js/groups.js';
// import * as Utils from '/js/utils.js';
// import * as Cache from '/js/cache.js';
// import JSON from '/js/json.js';
// import * as SyncStorage from '/js/sync/sync-storage.js';
// import {GithubGist, syncData} from '/js/sync/cloud/cloud.js';

const logger = new Logger('cloud mixin');
const logger = new Logger('sync.cloud-mixin');

let instance;

const {disconnect} = Messages.connectToBackground('sync-progress-mixin', [
'sync-start',
'sync-progress',
'sync-end',
'sync-error',
], ({action, progress, message}) => {
logger.assert(instance, 'instance of vue not found');
logger.log(action, progress, message);

if (!instance) {
return;
}

if (action === 'sync-start') {
instance.synchronisationError = '';
instance.synchronisationInProgress = true;
} if (action === 'sync-progress') {
instance.synchronisationProgress = progress;
} else if (action === 'sync-end') {
instance.synchronisationError = '';
instance.synchronisationInProgress = false;
} else if (action === 'sync-error') {
instance.synchronisationError = message;
instance.synchronisationInProgress = false;
}
});

window.addEventListener('unload', disconnect);

export default {
// data() {
// return {
// openEditDefaultGroup: false,
// };
// },
data() {
return {
synchronisationInProgress: false,
synchronisationProgress: 0,
synchronisationError: '',
};
},
methods: {
async syncCloud() {
// const log = logger.start('sync button');
console.clear();
let res2 = await Messages.sendMessageModule('BG.cloudSync');
console.debug('res2', res2);
// const result = [];
// console.time('cloud');
// const syncOptions = await SyncStorage.get();
// const GithubGistCloud = new GithubGist(syncOptions.githubGistToken, syncOptions.githubGistFileName, syncOptions.githubGistId);
// console.debug(await GithubGistCloud.findGistId());
// let localData = await Storage.get();
// let {groups} = await Groups.load(null, true);
// // const allTabs = Utils.concatTabs(groups);
// // await Promise.all(allTabs.map(tab => browser.sessions.setTabValue(tab.id, 'syncId', 16879931)))
// // console.debug('finish')
// // return;
// console.debug('groups:', groups);
// localData.groups = groups;
// let cloud = await GithubGistCloud.getGist();
// let cloudData = JSON.parse(cloud.content);
// console.debug('cloudData:', JSON.clone(cloudData));
// console.debug('before', JSON.clone(localData.groups), JSON.clone(cloudData.groups));
// await syncData(localData, cloudData);
// console.debug('after', localData.groups, cloudData.groups);
// const result = await GitHub.findFileId(localStorage.token, 'STG-backup.json')
// let id = await github.foundStgGistId();
// let data = await github.getGist();
// let createdata = await github.createGist(utils.stringify({
// aaa: 123,
// bbb: [1, '3', '@'],
// }, 2));
// let result = await github.updateGist(utils.stringify({
// aaa: 123,
// bbb: [2, '4', '99999'],
// }, 2));

// console.debug('gist id', id)
// console.debug('get gist data', data)
// console.debug('create gist data', createdata)
// console.timeEnd('cloud');
// console.debug('gist result', result)
instance = this;
await Messages.sendMessageModule('BG.cloudSync');
},
},
}
Loading

0 comments on commit f1d3faf

Please sign in to comment.