Skip to content

Commit

Permalink
fix sharesheet, alert only on save
Browse files Browse the repository at this point in the history
  • Loading branch information
PatheticMustan authored Mar 8, 2022
1 parent 5ac84a1 commit 72df7c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Routes/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function About() {
/>

{title("2638 Scout")}
{text("Version 4.0 2/11/2022")}
{text("Version 4.0.1 2/11/2022")}

{spacer}

Expand Down
7 changes: 6 additions & 1 deletion Routes/PastMatchesComponents/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ export default function Header() {

FileSystem.writeAsStringAsync(FileSystem.documentDirectory + path, output, { encoding: FileSystem.EncodingType.UTF8 });
// share the new csv file we just made
await Sharing.shareAsync(FileSystem.documentDirectory + path);
try {
await Sharing.shareAsync(FileSystem.documentDirectory + path);
} catch (e) {
alert(e.message);
}

}

return (
Expand Down
14 changes: 8 additions & 6 deletions Routes/ScoutComponents/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export default function Header() {
AsyncStorage.setItem("matches", JSON.stringify(matches));
// now update matches in redux
dispatch(writeMatch(final));
// "hey you saved a match lmao"
//alert("Saved Match #" + kpv["MatchNumber"]);

// now we're finished
successCallback(final);
Expand Down Expand Up @@ -118,7 +116,7 @@ export default function Header() {
}
}

async function saveAndExport() {
function saveAndExport() {
save(final => {
if (final === undefined) return;

Expand Down Expand Up @@ -147,12 +145,16 @@ export default function Header() {
}
}

function mobileExport(output) {
async function mobileExport(output) {
const path = "./data.csv";

FileSystem.writeAsStringAsync(FileSystem.documentDirectory + path, output, { encoding: FileSystem.EncodingType.UTF8 });
// share the new csv file we just made
Sharing.shareAsync(FileSystem.documentDirectory + path);
try {
await Sharing.shareAsync(FileSystem.documentDirectory + path);
} catch (e) {
alert(e.message);
}
}

return (
Expand All @@ -174,7 +176,7 @@ export default function Header() {
}}
/>

<Link color={ScoutingColors.blue} onPress={() => save()}>Save</Link>
<Link color={ScoutingColors.blue} onPress={() => save(() => alert("Saved Match #" + kpv["MatchNumber"]))}>Save</Link>

<Link color={ScoutingColors.blue} onPress={() => saveAndExport()}>Save and Export</Link>
</View>
Expand Down

0 comments on commit 72df7c4

Please sign in to comment.