|
|
@ -5,7 +5,7 @@ |
|
|
|
<!-- CONTENT --> |
|
|
|
<section id="Content" class="p-2 pb-24 max-w-3xl mx-auto"> |
|
|
|
<h1 id="ViewHeading" class="text-4xl text-center font-light px-4 mb-8"> |
|
|
|
Time Safari |
|
|
|
{{ AppString.APP_NAME }} |
|
|
|
</h1> |
|
|
|
|
|
|
|
<!-- prompt to install notifications --> |
|
|
@ -79,27 +79,37 @@ |
|
|
|
<!-- !isCreatingIdentifier --> |
|
|
|
<div |
|
|
|
v-if="!activeDid" |
|
|
|
class="bg-amber-200 rounded-md overflow-hidden text-center px-4 py-3 mb-4" |
|
|
|
class="bg-amber-200 rounded-md text-center px-4 py-3 mb-4" |
|
|
|
> |
|
|
|
<p class="text-lg mb-3"> |
|
|
|
Want to connect with your contacts, or share contributions or |
|
|
|
projects? |
|
|
|
Want to see info from your contacts, or share contributions? |
|
|
|
</p> |
|
|
|
<div class="flex justify-between"> |
|
|
|
<button |
|
|
|
class="block text-center text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mt-2 px-2 py-3 rounded-md" |
|
|
|
@click="generateIdentifier()" |
|
|
|
> |
|
|
|
Let me start the easiest (with a passkey). |
|
|
|
</button> |
|
|
|
<router-link |
|
|
|
:to="{ name: 'start' }" |
|
|
|
class="block text-center text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mt-2 px-2 py-3 rounded-md" |
|
|
|
> |
|
|
|
Create An Identifier |
|
|
|
Give me all the options. |
|
|
|
</router-link> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-else class="mb-4"> |
|
|
|
<!-- activeDid --> |
|
|
|
|
|
|
|
<div |
|
|
|
v-else-if="!isRegistered" |
|
|
|
v-if="!isRegistered" |
|
|
|
class="bg-amber-200 rounded-md overflow-hidden text-center px-4 py-3 mb-4" |
|
|
|
> |
|
|
|
<!-- activeDid && !isRegistered --> |
|
|
|
Someone must register you before you can give kudos or make offers or |
|
|
|
create projects... basically before doing anything. |
|
|
|
Someone must register you before you can give kudos or make offers |
|
|
|
or create projects... basically before doing anything. |
|
|
|
<router-link |
|
|
|
:to="{ name: 'contact-qr' }" |
|
|
|
class="block text-center text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mt-2 px-2 py-3 rounded-md" |
|
|
@ -166,6 +176,7 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<GiftedDialog ref="customDialog" /> |
|
|
|
<GiftedPrompts ref="giftedPrompts" /> |
|
|
@ -309,6 +320,7 @@ import { IIdentifier } from "@veramo/core"; |
|
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
|
import { Router } from "vue-router"; |
|
|
|
|
|
|
|
import App from "../App.vue"; |
|
|
|
import EntityIcon from "@/components/EntityIcon.vue"; |
|
|
|
import GiftedDialog from "@/components/GiftedDialog.vue"; |
|
|
|
import GiftedPrompts from "@/components/GiftedPrompts.vue"; |
|
|
@ -316,7 +328,7 @@ import FeedFilters from "@/components/FeedFilters.vue"; |
|
|
|
import InfiniteScroll from "@/components/InfiniteScroll.vue"; |
|
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
|
import TopMessage from "@/components/TopMessage.vue"; |
|
|
|
import { NotificationIface } from "@/constants/app"; |
|
|
|
import { AppString, NotificationIface } from "@/constants/app"; |
|
|
|
import { db, accountsDB } from "@/db/index"; |
|
|
|
import { Account } from "@/db/tables/accounts"; |
|
|
|
import { Contact } from "@/db/tables/contacts"; |
|
|
@ -336,7 +348,7 @@ import { |
|
|
|
GiverReceiverInputInfo, |
|
|
|
GiveSummaryRecord, |
|
|
|
} from "@/libs/endorserServer"; |
|
|
|
import { generateSaveAndActivateIdentity } from "@/libs/util"; |
|
|
|
import { registerSaveAndActivatePasskey } from "@/libs/util"; |
|
|
|
|
|
|
|
interface GiveRecordWithContactInfo extends GiveSummaryRecord { |
|
|
|
giver: { |
|
|
@ -354,6 +366,11 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord { |
|
|
|
} |
|
|
|
|
|
|
|
@Component({ |
|
|
|
computed: { |
|
|
|
App() { |
|
|
|
return App; |
|
|
|
}, |
|
|
|
}, |
|
|
|
components: { |
|
|
|
GiftedDialog, |
|
|
|
GiftedPrompts, |
|
|
@ -367,6 +384,8 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord { |
|
|
|
export default class HomeView extends Vue { |
|
|
|
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|
|
|
|
|
|
|
AppString = AppString; |
|
|
|
|
|
|
|
activeDid = ""; |
|
|
|
allContacts: Array<Contact> = []; |
|
|
|
allMyDids: Array<string> = []; |
|
|
@ -374,6 +393,7 @@ export default class HomeView extends Vue { |
|
|
|
feedData: GiveRecordWithContactInfo[] = []; |
|
|
|
feedPreviousOldestId?: string; |
|
|
|
feedLastViewedClaimId?: string; |
|
|
|
givenName = ""; |
|
|
|
isAnyFeedFilterOn: boolean; |
|
|
|
isCreatingIdentifier = false; |
|
|
|
isFeedFilteredByVisible = false; |
|
|
@ -397,15 +417,6 @@ export default class HomeView extends Vue { |
|
|
|
return identity; // may be null |
|
|
|
} |
|
|
|
|
|
|
|
public async getHeaders(identity: IIdentifier) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
const headers = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
Authorization: "Bearer " + token, |
|
|
|
}; |
|
|
|
return headers; |
|
|
|
} |
|
|
|
|
|
|
|
async mounted() { |
|
|
|
try { |
|
|
|
await accountsDB.open(); |
|
|
@ -418,6 +429,7 @@ export default class HomeView extends Vue { |
|
|
|
this.activeDid = settings?.activeDid || ""; |
|
|
|
this.allContacts = await db.contacts.toArray(); |
|
|
|
this.feedLastViewedClaimId = settings?.lastViewedClaimId; |
|
|
|
this.givenName = settings?.firstName || ""; |
|
|
|
this.isFeedFilteredByVisible = !!settings?.filterFeedByVisible; |
|
|
|
this.isFeedFilteredByNearby = !!settings?.filterFeedByNearby; |
|
|
|
this.isRegistered = !!settings?.isRegistered; |
|
|
@ -426,14 +438,7 @@ export default class HomeView extends Vue { |
|
|
|
|
|
|
|
this.isAnyFeedFilterOn = isAnyFeedFilterOn(settings); |
|
|
|
|
|
|
|
if (this.allMyDids.length === 0) { |
|
|
|
this.isCreatingIdentifier = true; |
|
|
|
this.activeDid = await generateSaveAndActivateIdentity(); |
|
|
|
this.allMyDids = [this.activeDid]; |
|
|
|
this.isCreatingIdentifier = false; |
|
|
|
} |
|
|
|
|
|
|
|
// someone may have have registered after sharing contact info |
|
|
|
// someone may have have registered after sharing contact info, so recheck |
|
|
|
if (!this.isRegistered && this.activeDid) { |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
try { |
|
|
@ -475,6 +480,15 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async generateIdentifier() { |
|
|
|
this.isCreatingIdentifier = true; |
|
|
|
const account = await registerSaveAndActivatePasskey( |
|
|
|
AppString.APP_NAME + (this.givenName ? " - " + this.givenName : ""), |
|
|
|
); |
|
|
|
this.activeDid = account.did; |
|
|
|
this.allMyDids = this.allMyDids.concat(this.activeDid); |
|
|
|
this.isCreatingIdentifier = false; |
|
|
|
} |
|
|
|
resultsAreFiltered() { |
|
|
|
return this.isFeedFilteredByVisible || this.isFeedFilteredByNearby; |
|
|
|
} |
|
|
@ -483,7 +497,7 @@ export default class HomeView extends Vue { |
|
|
|
return "Notification" in window; |
|
|
|
} |
|
|
|
|
|
|
|
public async buildHeaders() { |
|
|
|
async buildHeaders() { |
|
|
|
const headers: HeadersInit = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
@ -520,7 +534,7 @@ export default class HomeView extends Vue { |
|
|
|
* Data loader used by infinite scroller |
|
|
|
* @param payload is the flag from the InfiniteScroll indicating if it should load |
|
|
|
**/ |
|
|
|
public async loadMoreGives(payload: boolean) { |
|
|
|
async loadMoreGives(payload: boolean) { |
|
|
|
// Since feed now loads projects along the way, it takes longer |
|
|
|
// and the InfiniteScroll component triggers a load before finished. |
|
|
|
// One alternative is to totally separate the project link loading. |
|
|
@ -542,7 +556,7 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async updateAllFeed() { |
|
|
|
async updateAllFeed() { |
|
|
|
this.isFeedLoading = true; |
|
|
|
let endOfResults = true; |
|
|
|
await this.retrieveGives(this.apiServer, this.feedPreviousOldestId) |
|
|
@ -650,7 +664,7 @@ export default class HomeView extends Vue { |
|
|
|
* @param beforeId the earliest ID (of previous searches) to search earlier |
|
|
|
* @return claims in reverse chronological order |
|
|
|
*/ |
|
|
|
public async retrieveGives(endorserApiServer: string, beforeId?: string) { |
|
|
|
async retrieveGives(endorserApiServer: string, beforeId?: string) { |
|
|
|
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId; |
|
|
|
const response = await fetch( |
|
|
|
endorserApiServer + |
|
|
|