Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Join Study: Add content that directs user to Chrome store where they …
Browse files Browse the repository at this point in the history
…have to download the extension Fixes: #284

Update src/routes/studies/index.svelte

Co-Authored-By: Robert Helmer <rhelmer@rhelmer.org>
  • Loading branch information
thomik-corp and rhelmer committed Apr 11, 2022
1 parent 9c6eafc commit 03b7056
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
27 changes: 23 additions & 4 deletions src/lib/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface State {

export interface User {
uid: string;
createdOn: { seconds: number; nanoseconds: number };
createdOn: { seconds: number; nanoseconds: number; };
enrolled: boolean;
onboarded: boolean;
demographicsData: object;
Expand All @@ -36,9 +36,28 @@ export interface UserStudies {
}

export interface UserStudy {
joinedOn: { seconds: number; nanoseconds: number };
joinedOn: { seconds: number; nanoseconds: number; };
enrolled: false;
}

// FIXME: this should be well-defined and probably should live elsewhere.
export interface StudyMetadata { }
export interface StudyMetadata {
name: string;
description: string;
studyId?: string;
tags: string[];
icons: Record<string, string>;
addonId?: string;
authors: {
name: string;
url?: string;
};
endDate: string;
version: string;
studyEnded: boolean;
studyPaused: boolean;
downloadLink: string;
schemaNamespace?: string;
studyDetailsLink: string;
minimumCoreVersion?: string;
dataCollectionDetails: string[];
}
12 changes: 10 additions & 2 deletions src/routes/studies/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@
const notifications: NotificationStore = getContext("rally:notifications");
function joinStudy(studyId) {
const study = $store.studies.find((s) => s.studyId === studyId);
if (!study) {
throw new Error(`Study with id: ${studyId} not found.`);
}
window.open(study.downloadLink, "_blank");
store.updateStudyEnrollment(studyId, true);
notifications.send({ code: "SUCCESSFULLY_JOINED_STUDY" });
}
function leaveStudy(studyId) {
store.updateStudyEnrollment(studyId, false);
notifications.send({ code: "SUCCESSFULLY_LEFT_STUDY" });
}
$: if ($store._initialized) {
if (!$store?.user?.uid) {
goto("/signup");
} else if (!$store?.user?.enrolled) {
goto("/welcome/terms");
}
Expand Down

0 comments on commit 03b7056

Please sign in to comment.