Rename share to sync

This commit is contained in:
crschnick 2024-08-25 12:46:47 +00:00
parent 41d419f19d
commit 6044cd3ead
7 changed files with 41 additions and 41 deletions

View file

@ -26,7 +26,7 @@ public class StoreCategoryWrapper {
private final DataStoreCategory category;
private final Property<Instant> lastAccess;
private final Property<StoreSortMode> sortMode;
private final Property<Boolean> share;
private final Property<Boolean> sync;
private final ObservableList<StoreCategoryWrapper> children;
private final ObservableList<StoreEntryWrapper> containedEntries;
private final BooleanProperty expanded = new SimpleBooleanProperty();
@ -50,7 +50,7 @@ public class StoreCategoryWrapper {
this.name = new SimpleStringProperty(category.getName());
this.lastAccess = new SimpleObjectProperty<>(category.getLastAccess());
this.sortMode = new SimpleObjectProperty<>(category.getSortMode());
this.share = new SimpleObjectProperty<>(category.isShare());
this.sync = new SimpleObjectProperty<>(category.isSync());
this.children = FXCollections.observableArrayList();
this.containedEntries = FXCollections.observableArrayList();
this.color.setValue(category.getColor());
@ -108,8 +108,8 @@ public class StoreCategoryWrapper {
category.setSortMode(newValue);
});
share.addListener((observable, oldValue, newValue) -> {
DataStorage.get().shareCategory(category, newValue);
sync.addListener((observable, oldValue, newValue) -> {
DataStorage.get().syncCategory(category, newValue);
});
}
@ -131,7 +131,7 @@ public class StoreCategoryWrapper {
lastAccess.setValue(category.getLastAccess().minus(Duration.ofMillis(500)));
sortMode.setValue(category.getSortMode());
share.setValue(category.isShare());
sync.setValue(category.isSync());
expanded.setValue(category.isExpanded());
color.setValue(category.getColor());

View file

@ -14,7 +14,7 @@ import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.GitStorageHandler;
import io.xpipe.app.storage.DataStorageSyncHandler;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.*;
@ -54,8 +54,8 @@ public class BaseMode extends OperationMode {
AppPrefs.setLocalDefaultsIfNeeded();
// Initialize beacon server as we should be prepared for git askpass commands
AppBeaconServer.init();
GitStorageHandler.getInstance().init();
GitStorageHandler.getInstance().setupRepositoryAndPull();
DataStorageSyncHandler.getInstance().init();
DataStorageSyncHandler.getInstance().retrieveSyncedData();
AppPrefs.initSharedRemote();
UnlockAlert.showIfNeeded();
DataStorage.init();

View file

@ -89,9 +89,9 @@ public class StoreCategoryComp extends SimpleComp {
return "mdi2a-account-lock";
}
return category.getShare().getValue() ? "mdi2g-git" : "mdi2a-account-cancel";
return category.getSync().getValue() ? "mdi2g-git" : "mdi2a-account-cancel";
},
category.getShare(),
category.getSync(),
hover);
var statusButton = new IconButtonComp(statusIcon)
.apply(struc -> AppFont.small(struc.get()))
@ -217,25 +217,25 @@ public class StoreCategoryComp extends SimpleComp {
share.textProperty()
.bind(Bindings.createStringBinding(
() -> {
if (category.getShare().getValue()) {
if (category.getSync().getValue()) {
return AppI18n.get("unshare");
} else {
return AppI18n.get("share");
}
},
category.getShare()));
category.getSync()));
share.graphicProperty()
.bind(Bindings.createObjectBinding(
() -> {
if (category.getShare().getValue()) {
if (category.getSync().getValue()) {
return new FontIcon("mdi2b-block-helper");
} else {
return new FontIcon("mdi2g-git");
}
},
category.getShare()));
category.getSync()));
share.setOnAction(event -> {
category.getShare().setValue(!category.getShare().getValue());
category.getSync().setValue(!category.getSync().getValue());
});
contextMenu.getItems().add(share);
}

View file

@ -315,8 +315,8 @@ public abstract class DataStorage {
saveAsync();
}
public void shareCategory(DataStoreCategory category, boolean share) {
category.setShare(share);
public void syncCategory(DataStoreCategory category, boolean share) {
category.setSync(share);
DataStoreCategory p = category;
if (share) {
@ -324,7 +324,7 @@ public abstract class DataStorage {
.getStoreCategoryIfPresent(p.getParentCategory())
.orElse(null))
!= null) {
p.setShare(true);
p.setSync(true);
}
}

View file

@ -4,17 +4,17 @@ import io.xpipe.core.process.ProcessControlProvider;
import java.nio.file.Path;
public interface GitStorageHandler {
public interface DataStorageSyncHandler {
static GitStorageHandler getInstance() {
return (GitStorageHandler) ProcessControlProvider.get().getGitStorageHandler();
static DataStorageSyncHandler getInstance() {
return (DataStorageSyncHandler) ProcessControlProvider.get().getGitStorageHandler();
}
boolean supportsShare();
boolean supportsSync();
void init();
void setupRepositoryAndPull();
void retrieveSyncedData();
void afterStorageLoad();

View file

@ -31,7 +31,7 @@ public class DataStoreCategory extends StorageElement {
StoreSortMode sortMode;
@NonFinal
boolean share;
boolean sync;
public DataStoreCategory(
Path directory,
@ -43,12 +43,12 @@ public class DataStoreCategory extends StorageElement {
boolean dirty,
UUID parentCategory,
StoreSortMode sortMode,
boolean share,
boolean sync,
boolean expanded) {
super(directory, uuid, name, lastUsed, lastModified, color, expanded, dirty);
this.parentCategory = parentCategory;
this.sortMode = sortMode;
this.share = share;
this.sync = sync;
}
public static DataStoreCategory createNew(UUID parentCategory, @NonNull String name) {
@ -140,10 +140,10 @@ public class DataStoreCategory extends StorageElement {
}
}
public void setShare(boolean newShare) {
var changed = share != newShare;
public void setSync(boolean newShare) {
var changed = sync != newShare;
if (changed) {
this.share = newShare;
this.sync = newShare;
notifyUpdate(false, true);
}
}
@ -174,7 +174,7 @@ public class DataStoreCategory extends StorageElement {
return false;
}
return isShare();
return isSync();
}
@Override
@ -192,7 +192,7 @@ public class DataStoreCategory extends StorageElement {
ObjectNode stateObj = JsonNodeFactory.instance.objectNode();
obj.put("uuid", uuid.toString());
obj.put("name", name);
obj.put("share", share);
obj.put("share", sync);
obj.set("color", mapper.valueToTree(color));
stateObj.put("lastUsed", lastUsed.toString());
stateObj.put("lastModified", lastModified.toString());

View file

@ -29,7 +29,7 @@ public class StandardStorage extends DataStorage {
private final List<Path> directoriesToKeep = new ArrayList<>();
@Getter
private final GitStorageHandler gitStorageHandler;
private final DataStorageSyncHandler dataStorageSyncHandler;
private String vaultKey;
@ -37,7 +37,7 @@ public class StandardStorage extends DataStorage {
private boolean disposed;
StandardStorage() {
this.gitStorageHandler = GitStorageHandler.getInstance();
this.dataStorageSyncHandler = DataStorageSyncHandler.getInstance();
}
@Override
@ -263,7 +263,7 @@ public class StandardStorage extends DataStorage {
loaded = true;
busyIo.unlock();
this.gitStorageHandler.afterStorageLoad();
this.dataStorageSyncHandler.afterStorageLoad();
}
private void callProviders() {
@ -297,7 +297,7 @@ public class StandardStorage extends DataStorage {
return;
}
this.gitStorageHandler.beforeStorageSave();
this.dataStorageSyncHandler.beforeStorageSave();
try {
FileUtils.forceMkdir(getStoresDir().toFile());
@ -317,7 +317,7 @@ public class StandardStorage extends DataStorage {
var exists = Files.exists(e.getDirectory());
var dirty = e.isDirty();
e.writeDataToDisk();
gitStorageHandler.handleCategory(e, exists, dirty);
dataStorageSyncHandler.handleCategory(e, exists, dirty);
} catch (IOException ex) {
// IO exceptions are not expected
exception.set(ex);
@ -334,7 +334,7 @@ public class StandardStorage extends DataStorage {
var exists = Files.exists(e.getDirectory());
var dirty = e.isDirty();
e.writeDataToDisk();
gitStorageHandler.handleEntry(e, exists, dirty);
dataStorageSyncHandler.handleEntry(e, exists, dirty);
} catch (Exception ex) {
// Data corruption and schema changes are expected
exception.set(ex);
@ -348,7 +348,7 @@ public class StandardStorage extends DataStorage {
}
deleteLeftovers();
gitStorageHandler.afterStorageSave();
dataStorageSyncHandler.afterStorageSave();
if (dispose) {
disposed = true;
}
@ -357,7 +357,7 @@ public class StandardStorage extends DataStorage {
@Override
public boolean supportsSharing() {
return gitStorageHandler.supportsShare();
return dataStorageSyncHandler.supportsSync();
}
private void deleteLeftovers() {
@ -387,7 +387,7 @@ public class StandardStorage extends DataStorage {
.tag("uuid", uuid)
.handle();
FileUtils.forceDelete(file.toFile());
gitStorageHandler.handleDeletion(file, uuid.toString());
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
@ -420,7 +420,7 @@ public class StandardStorage extends DataStorage {
.tag("uuid", uuid)
.handle();
FileUtils.forceDelete(file.toFile());
gitStorageHandler.handleDeletion(file, uuid.toString());
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();