-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vibrate the device on game lost (#454)
* vibrate on lost * add preference in setting view * move to constants, slight naming change
- Loading branch information
Showing
6 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { get, set } from "idb-keyval"; | ||
|
||
const DEFAULT: boolean = true; | ||
|
||
/** | ||
* Set vibration preference (true means will vibrate) | ||
* | ||
* @param vibrate | ||
*/ | ||
export async function setVibrationPreference(vibrate: boolean): Promise<void> { | ||
await set("vibrate", vibrate); | ||
} | ||
|
||
export async function getVibrationPreference(): Promise<boolean> { | ||
const vibrate = await get("vibrate"); | ||
if (typeof vibrate === "boolean") { | ||
return vibrate; | ||
} | ||
// if no value is assigned to "vibrate", return default value | ||
return DEFAULT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters