Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit 6a4f2a0

Browse files
committed
Sync. Edits and Merges
1 parent ee43a1e commit 6a4f2a0

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ Next the client will ask for a name, this name has to be unique for
9696
each device and will be shown in the stats view of the other devices.
9797
`ttt conf sync directory` has to be run on each device.
9898

99-
> Merges and edits of tasks will not be synchronized.
100-
> Edits and merges affecting the current day will be synchronized
101-
> only when completing another task on this day.
102-
10399
## Setup
104100
The tool supports Linux (like Ubuntu, Linux Mint), macOS and Windows.
105101
We have tested it under Linux Mint 18, macOS Catalina and Windows 10.

core/Recorder.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,7 @@ private function saveTaskTime(JSONReader $r) : void {
8080
"category" => $r->getValue(['category'])
8181
));
8282
// also save to sync
83-
$c = Config::getStorageReader('config');
84-
if( $c->isValue(['sync', 'directory']) ){
85-
(new DirectoryStatsAccess())->setDayTasks($data->getArray());
86-
}
87-
if( $c->isValue(['sync', 'server']) ){
88-
(new ServerStatsAccess())->setDayTasks($data->getArray());
89-
}
83+
StatsLoader::saveDayTasks( $data->getArray() );
9084

9185
$this->dialog->setLastTask(
9286
$r->getValue(['name']),

core/Settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ private function edit(array $commands) : void {
177177
}
178178
while( $s->isValue([$id]) );
179179
$this->output->print(array("Exit!"), CLIOutput::YELLOW, 1);
180+
181+
StatsLoader::saveDayTasks( $s->getArray() );
180182
}
181183
else{
182184
$this->output->print(array(array(

core/StatsData.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@ public function merge($merge, $mergeTo) : bool {
6363
$ret = true;
6464
foreach( $this->loader->getLocalFilelist() as $f ){
6565
$r = Config::getStorageReader(substr($f, 0, -5));
66+
$rUnchanged = true;
6667
foreach( $r->getArray() as $k => $a ){
6768
if( $a['name'] === $merge ){
6869
$ret &= $r->setValue([$k, 'name'], $mergeTo);
70+
$rUnchanged = false;
6971
}
7072
}
73+
if(!$rUnchanged){
74+
StatsLoader::saveDayTasks( $r->getArray() );
75+
}
7176
unset($r);
7277
}
7378

core/Utilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
class Utilities {
66

7-
const VERSION = 'v0.9.3 beta';
7+
const VERSION = 'v0.9.4 beta';
88

99
/**
1010
* OS Consts

core/sync/StatsLoader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,14 @@ public function getContents() : array {
7575
}
7676
return $dataset;
7777
}
78+
79+
public static function saveDayTasks(array $array ) : void {
80+
$c = Config::getStorageReader('config');
81+
if( $c->isValue(['sync', 'directory']) ){
82+
(new DirectoryStatsAccess())->setDayTasks($array);
83+
}
84+
if( $c->isValue(['sync', 'server']) ){
85+
(new ServerStatsAccess())->setDayTasks($array);
86+
}
87+
}
7888
}

0 commit comments

Comments
 (0)