Skip to content

Commit

Permalink
Merge pull request #26 from CS2103-AY1819S2-W13-3/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
suriruhani committed Apr 7, 2019
2 parents 8c04536 + 49fe56f commit c3ac302
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
29 changes: 29 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,35 @@ Step 3. The user executes `restore 1` and only one entry will be deleted, which
* **Alternative 2 (current choice):** Using Json Managers and DeletedSources in the Model
// end::restore[]

// tag::panic[]
=== Panic Mode feature
The panic mode feature allows the user to temporarily hide user data and replace it with dummy data.

==== Overview
The user's original data is replaced by dummy data for the duration that panic mode is enabled.
Enabling panic mode can be thought of as "stashing" the user's data temporarily in memory.
This is reflected both on-screen and on-disk.
On the screen, the list of sources is replaced by an empty dummy list.
On disk, the contents of the JSON file storing the user's sources is replaced by dummy content that tracks and reflects the dummy data.

==== Implementation
This is implemented by "swapping" the source manager with an empty dummy source manager.
This "swap" is carried out by storing the original source manager in a private variable `sourceManagerBackup`, and then resetting the original source manager with a new empty source manager instance.
We also set the boolean variable `panicMode = true`.

When the user disables panic mode, we restore the original source manager, and reset `panicMode = false`.

==== Elaboration
We use a boolean variable `panicMode` to keep track of whether panic mode has been activated.
This is to guard against the scenario of entering panic mode while already in panic mode, which results in permanent data loss.

This is because when panic mode is activated, we store the original source manager in the private variable `sourceManagerBackup`, and reset the original source manager, as described above.

Therefore, should panic mode be activated while already in panic mode, `sourceManagerBackup` will now store the dummy source manager, and the original source manager will be deallocated and eventually purged from memory by Java's garbage collector.

Since the JSON file on disk automatically tracks the source manager through the observer pattern, it automatically updates to track and reflect the data in the dummy source manager.


// tag::alias[]
=== Command Alias feature
The command alias feature allows users to use shorthand commands to rapidly "get things done", for instance using `a` instead of `add`, or `c` instead of `count`.
Expand Down
28 changes: 25 additions & 3 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,38 @@ The `redo` command fails as there are no `undo` commands executed previously.
`redo` (reapplies the `clear` command) +
// end::undoredo[]

// tag::panic[]
=== Enabling panic mode : `panic`

Allows user to temporarily hide data. +
Allows the user to temporarily hide data. +
Format: `panic`

=== Enabling panic mode : `unpanic`
Research data may be sensitive.
Panic mode is a privacy-focused feature that swaps out the user's data store with an empty dummy data store.

Restores user data. +
When it is enabled, the application window replaces the original list of sources with an empty list.
This change is reflected on disk too; the JSON file of sources is replaced by an empty dummy file that tracks the dummy data store.
The original data store exists only in memory, until panic mode is disabled.

In panic mode, the dummy data store behaves exactly like a real one.
Therefore, all commands (e.g. add, remove, etc.) mutate the dummy data store (and the dummy JSON file), **without affecting the actual data store.**

[NOTE]
====
If the user exits the application in panic mode (using the `exit` command), the application automatically restores the user's original data from memory and saves it to disk before exiting, to prevent permanent data loss.
However, if the application is closed directly **while in panic mode**, **permanent data loss** will occur.
====

// tag::unpanic[]
=== Disabling panic mode : `unpanic`

Restores the user's original data. +
Format: `unpanic`

This reverses the effect of panic mode by restoring the user's original data.
The restorated is reflected on the disk too; the JSON file is reset to its original state and will now track the original data store.

=== Clearing all entries : `clear`

Clears all entries from the source manager and all the deleted sources as well. +
Expand Down

0 comments on commit c3ac302

Please sign in to comment.