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

Join Study: Add content that directs user to Chrome store where they have to download the extension #314

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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