Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-4994: Prompt Users to Create a Snapshot #1517

Merged
merged 35 commits into from
Jan 24, 2024
Merged

PE-4994: Prompt Users to Create a Snapshot #1517

merged 35 commits into from
Jan 24, 2024

Conversation

matibat
Copy link
Contributor

@matibat matibat commented Dec 12, 2023

Changes

  • Adds a new modal prompting to make a snapshot.
  • Makes the modal be triggered after selecting a drive, with a debouncer of 20s.
  • Makes the GQL Drive History count for the transactions, per drive.
  • Introduces a class responsible for tracking the count of transactions synced through GQL. As a second responsibility, it determines whether or not it's a good time to make a snapshot for a certain drive.
    • Maybe TODO: Implement cache of TXs count.
  • After snapshot time, the TXs count gets reset.
    • TODO: it should be aware of the non-snapshotted TXs after making one because of any recent uploads. That's a question: how many GQL-synced TXs didn't get snapshotted? This shouldn't conflict with the yet-not-synced ones.
    • Maybe fix: get the last synced height and filter against the snapshot sync data.

Note - we're leaving those TODOs for a later improvement.

--- Releases ---
Android release: https://appdistribution.firebase.google.com/testerapps/1:305132849030:android:6cf0cd5ec064fad3ffce07/releases/1ijhutiqe6nno

Copy link

github-actions bot commented Dec 12, 2023

Visit the preview URL for this PR (updated for commit e643868):

https://ardrive-web--pr1517-pe-4994-1koigns7.web.app

(expires Tue, 30 Jan 2024 23:00:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0

Copy link
Contributor Author

@matibat matibat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review checkpoint.

lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
lib/pages/drive_detail/drive_detail_page.dart Outdated Show resolved Hide resolved
lib/components/prompt_to_snapshot_dialog.dart Outdated Show resolved Hide resolved
lib/components/prompt_to_snapshot_dialog.dart Outdated Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - Renamed the ARB key for this because I created another with the same name.

logger.d('Done fetching data - ${gqlDriveHistory.driveId}');

promptToSnapshotBloc.add(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - Here we pass the count to the cubit to let it consider whether to prompt to make a snapshot

@matibat matibat marked this pull request as ready for review December 13, 2023 02:52
if (syncState is! SyncInProgress) {
final promptToSnapshotBloc =
context.read<PromptToSnapshotBloc>();
promptToSnapshotBloc.add(SelectedDrive(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - we now add to the bloc the SelectDrive event after the sync has finished.

Comment on lines +153 to +156
CountOfTxsSyncedWithGql.countForDrive(
event.driveId,
event.txsSyncedWithGqlCount,
);
Copy link
Contributor Author

@matibat matibat Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - This is currently counting zero, but later on we're gonna track that number to be more precise.

}
}

abstract class CountOfTxsSyncedWithGql {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @thiagocarvalhodev, this is the class I mentioned earlier.

  • We can extend this class and/or compose it with other similar ones to track stats as you suggested.
  • And we can add the persistence here.

Copy link
Contributor Author

@matibat matibat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review checkpoint.

atticusofsparta
atticusofsparta previously approved these changes Jan 3, 2024
@thiagocarvalhodev thiagocarvalhodev self-assigned this Jan 5, 2024
Copy link
Contributor Author

@matibat matibat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review checkpoint.

Copy link
Contributor Author

@matibat matibat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review checkpoint.

lib/blocs/drives/drives_cubit.dart Outdated Show resolved Hide resolved
lib/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart Outdated Show resolved Hide resolved
}
}

class PromptToSnapshotSnapshotting extends PromptToSnapshotState {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - Implemented a new state in order not to prompt while snapshotting.

Comment on lines +15 to +17
class PromptToSnapshotIdle extends PromptToSnapshotState {
const PromptToSnapshotIdle() : super(driveId: null);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - Made the Idle state not to have a driveId.

Comment on lines +80 to +81
// TODO
/// txsSyncedWithGqlCount: state.notSnapshottedTxsCount,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer - TODO for the next iteration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reviewer -

  1. Once the modal gets opened, it will tell the bloc we're snapshotting.
  2. On success it will emit Snapshotted so the count gets reset.
  3. Once it's closed, it will tell the bloc no drive is selected so it goes Idle.

@matibat matibat requested a review from karlprieb January 11, 2024 19:51
karlprieb
karlprieb previously approved these changes Jan 12, 2024
thiagocarvalhodev and others added 2 commits January 19, 2024 09:12
- add event for when the modal is closed
…r-after-closing-with-x

PE-5457: modal doesnt reappear after closing with x
@matibat matibat removed their assignment Jan 23, 2024
@thiagocarvalhodev thiagocarvalhodev merged commit 8d4cdef into dev Jan 24, 2024
6 checks passed
@thiagocarvalhodev thiagocarvalhodev deleted the PE-4994 branch January 24, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants