Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
JAlbertoGonzalez committed Jul 23, 2021
1 parent 7adde1c commit bd941dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 67 deletions.
6 changes: 3 additions & 3 deletions src/renderer/components/FileStatus/FileStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="flex justify-between fixed bg-white p-2 px-6 w-full">
<div class="text-base text-black font-bold">Activity</div>
<div>
<div v-if="this.isSyncing" class="text-gray-300 text-sm cursor-not-allowed hover:text-gray-300">Clear</div>
<div v-if="this.isSyncing" class="text-gray-300 text-sm cursor-pointer hover:text-gray-300">Clear</div>
<div v-else @click="clearFileLogger()" class="text-blue-600 text-sm cursor-pointer hover:text-blue-800">Clear</div>
</div>

Expand All @@ -20,10 +20,10 @@
v-for="(item, index) in FileStatusSync"
v-bind:key="index"
>
<!-- {{ Upload in progress}} -->
<!-- {{ En progreso upload entra aquí }} -->
<div
class="flex mb-2"
v-if="!item.state && (item.action === 'upload')"
v-if="item.state === null && (item.action === 'upload')"
>
<UilFileUpload
class="text-2xl mr-3 fill-current text-gray-500"
Expand Down
93 changes: 34 additions & 59 deletions src/renderer/components/SyncButtonAction/SyncButtonAction.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<template>
<div class="flex justify-between p-4 px-6">
<div class="flex">
<syncStatusText :msg="message" :syncState="syncState" />

<syncStatusText :msg = "message" :syncState = "syncState"/>

<!-- Error - string= 'error' -->
</div>
<div class="flex justify-center">
<div class="flex">
<div v-if="this.playButtonState !== 'loading'" @click="forceSync()">
<PlayIcon :playButtonState="playButtonState" />
<PlayIcon :playButtonState="playButtonState"/>
</div>
<div v-else>
<LoadingSpinAnimation />
<LoadingSpinAnimation/>
</div>
<div @click="stopSync()">
<StopIcon :stopButtonState="stopButtonState" />
<StopIcon :stopButtonState="stopButtonState"/>
</div>
</div>
</div>
Expand All @@ -33,20 +34,33 @@ import ConfigStore from '../../../main/config-store'
import StopIcon from '../ExportIcons/StopIcon.vue'
import PlayIcon from '../ExportIcons/PlayIcon.vue'
import LoadingSpinAnimation from '../ExportIcons/LoadingSpinAnimation'
import syncButtonState from '../../logic/syncButtonStateMachine'
import syncStatusText from './syncStatusText'
import getMessage from './statusMessage'
import Logger from '../../../libs/logger'
const remote = require('@electron/remote')
export default {
data() {
return {
syncState: 'default',
syncButtonState: ConfigStore.get('isSyncing'),
playButtonState: 'active',
stopButtonState: 'inactive',
message: getMessage('default'),
blockTimeout: undefined,
syncState: 'default'
stopButtonSync: 'inactiveButtonSync',
message: {},
changeSyncButton: isSyncing => {
this.syncButtonState = isSyncing
},
changeSyncStatus: status => {
// console.log(`%c Status Change. STATUS: ${this.syncState}, PLAY BUTTON: ${this.playButtonState}, STOP BUTTON: ${this.stopButtonState}, TRANSITION: ${status}`, 'color: #FFA500')
const { syncState, playButtonState, stopButtonState } = syncButtonState(this.syncState, status)
this.syncState = syncState
this.playButtonState = playButtonState
this.stopButtonState = stopButtonState
this.message = getMessage(syncState)
// console.log(`%c NEW STATE: ${this.syncState}, PLAY BUTTON: ${this.playButtonState}, STOP BUTTON: ${this.stopButtonState}`, 'color: #FFA500')
}
}
},
props: {
Expand All @@ -57,70 +71,31 @@ export default {
},
methods: {
forceSync() {
if (this.playButtonState === 'active' || this.playButtonState === 'loading') {
this.playButtonState = 'loading'
this.stopButtonState = 'inactive'
this.message = getMessage('starting')
if (this.playButtonState === 'active') {
remote.app.emit('sync-start')
}
},
// Stop forceSync
StopForceSync() {
remote.app.on('sync-off', _ => {
// TODO
})
},
// Stop sync
stopSync() {
if (this.stopButtonState === 'active') {
remote.app.emit('sync-stop')
this.playButtonState = 'loading'
this.stopButtonState = 'inactive'
this.message = getMessage('stopping')
}
}
},
created: function() {
remote.app.on('ui-sync-status', status => {
if (status === 'success') {
this.playButtonState = 'active'
this.stopButtonState = 'inactive'
this.message = getMessage('complete')
}
if (status === 'default') {
this.playButtonState = 'active'
this.stopButtonState = 'inactive'
this.message = getMessage('default')
}
if (status === 'block') {
if (!this.blockTimeout) {
this.blockTimeout = setTimeout(() => {
this.playButtonState = 'active'
this.stopButtonState = 'inactive'
this.blockTimeout = undefined
}, 60 * 1000)
}
this.playButtonState = 'inactive'
this.stopButtonState = 'inactive'
this.message = getMessage('block')
}
/*
if (status === 'error') {
this.playButtonState = 'active'
this.stopButtonState = 'inactive'
this.message = getMessage('error')
}
*/
if (status === 'pending') {
clearTimeout(this.blockTimeout)
this.timeout = undefined
this.playButtonState = 'loading'
this.stopButtonState = 'active'
this.message = getMessage('pending')
}
if (status === 'stop') {
this.playButtonState = 'active'
this.stopButtonState = 'inactive'
this.message = getMessage('stop')
}
})
remote.app.on('sync-on', this.changeSyncButton)
remote.app.on('sync-off', this.changeSyncButton)
remote.app.on('ui-sync-status', this.changeSyncStatus)
},
beforeDestroy: function() {
remote.app.removeListener('sync-off', this.changeSyncButton)
remote.app.removeListener('sync-on', this.changeSyncButton)
remote.app.removeListener('ui-sync-status', this.changeSyncStatus)
},
updated: function() {},
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/logic/sync/NewTwoWayUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ async function SyncLogic(callback) {
}
}
const syncComplete = async function(err) {
let syncStopped = false
if (err) {
Logger.error('Error sync monitor:', err.message ? err.message : err)
if (/it violates the unique constraint/.test(err.message)) {
Tree.tryFixDuplicateFolder()
Logger.log('sending request for rename duplicate folder')
}
if (/stop sync/.test(err.message)) {
syncStopped = true
app.emit('ui-sync-status', 'stop')
} else {
app.emit('ui-sync-status', 'error')
Expand All @@ -108,15 +106,13 @@ async function SyncLogic(callback) {
if (ConfigStore.get('forceUpload') === 1) {
ConfigStore.set('forceUpload', 0)
}
app.emit('ui-sync-status', 'success')
}
// console.timeEnd('desktop')
const basePath = await Database.Get('xPath')
NameTest.removeTestFolder(basePath)
app.emit('set-tooltip')
app.emit('sync-off', false)
if (!syncStopped) {
app.emit('ui-sync-status', 'success')
}
app.removeListener('sync-stop', syncStop)
app.removeListener('user-logout', DeviceLock.stopUpdateDeviceSync)
ConfigStore.set('stopSync', false)
Expand Down

0 comments on commit bd941dc

Please sign in to comment.