resetTwoWaySyncTimestamps at first run

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-10-26 09:15:39 +02:00 committed by Alper Öztürk
parent 26d7a0111a
commit a0f14bc778
3 changed files with 19 additions and 0 deletions

View file

@ -55,4 +55,7 @@ interface FileDao {
"ORDER BY internal_two_way_sync_timestamp DESC"
)
fun getInternalTwoWaySyncFolders(fileOwner: String): List<FileEntity>
@Query("UPDATE filelist SET internal_two_way_sync_timestamp = -1 WHERE internal_two_way_sync_timestamp IS NULL OR internal_two_way_sync_timestamp >= 0")
fun setInternalTwoWaySyncTimestampToMinusOne()
}

View file

@ -394,4 +394,7 @@ public interface AppPreferences {
void setTwoWayInternalSyncStatus(boolean value);
boolean getTwoWayInternalSyncStatus();
void setTwoWaySyncTimestampDefault(boolean value);
boolean isTwoWaySyncTimestampDefault();
}

View file

@ -44,6 +44,8 @@ import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.appinfo.AppInfo;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.database.NextcloudDatabase;
import com.nextcloud.client.database.dao.FileDao;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.di.ActivityInjector;
import com.nextcloud.client.di.AppComponent;
@ -382,6 +384,17 @@ public class MainApp extends Application implements HasAndroidInjector, NetworkC
registerGlobalPassCodeProtection();
networkChangeReceiver = new NetworkChangeReceiver(this, connectivityService);
registerNetworkChangeReceiver();
resetTwoWaySyncTimestamps();
}
private void resetTwoWaySyncTimestamps() {
if (preferences.isTwoWaySyncTimestampDefault()) {
return;
}
FileDao fileDao = NextcloudDatabase.getInstance(this).fileDao();
fileDao.setInternalTwoWaySyncTimestampToMinusOne();
preferences.setTwoWaySyncTimestampDefault(true);
}
private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {