|
|
@ -320,7 +320,7 @@ import { |
|
|
|
} from "../constants/app"; |
|
|
|
import { logConsoleAndDb } from "../db/index"; |
|
|
|
import { Contact } from "../db/tables/contacts"; |
|
|
|
import { BoundingBox, checkIsAnyFeedFilterOn } from "../db/tables/settings"; |
|
|
|
import { BoundingBox, checkIsAnyFeedFilterOn, MASTER_SETTINGS_KEY } from "../db/tables/settings"; |
|
|
|
import * as databaseUtil from "../db/databaseUtil"; |
|
|
|
import { |
|
|
|
contactForDid, |
|
|
@ -342,7 +342,7 @@ import { GiveSummaryRecord } from "../interfaces/records"; |
|
|
|
import * as serverUtil from "../libs/endorserServer"; |
|
|
|
import { logger } from "../utils/logger"; |
|
|
|
import { GiveRecordWithContactInfo } from "../interfaces/give"; |
|
|
|
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; |
|
|
|
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; |
|
|
|
import * as Package from "../../package.json"; |
|
|
|
|
|
|
|
interface Claim { |
|
|
@ -427,6 +427,7 @@ interface FeedError { |
|
|
|
ImageViewer, |
|
|
|
ActivityListItem, |
|
|
|
}, |
|
|
|
mixins: [PlatformServiceMixin], |
|
|
|
}) |
|
|
|
export default class HomeView extends Vue { |
|
|
|
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|
|
@ -537,10 +538,14 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Load settings with better error context |
|
|
|
// Load settings with better error context using enhanced mixin |
|
|
|
let settings; |
|
|
|
try { |
|
|
|
settings = await databaseUtil.retrieveSettingsForActiveAccount(); |
|
|
|
settings = await (this as any).$getSettings(MASTER_SETTINGS_KEY, { |
|
|
|
apiServer: "", |
|
|
|
activeDid: "", |
|
|
|
isRegistered: false, |
|
|
|
}); |
|
|
|
} catch (error) { |
|
|
|
logConsoleAndDb( |
|
|
|
`[HomeView] Failed to retrieve settings: ${error}`, |
|
|
@ -605,9 +610,10 @@ export default class HomeView extends Vue { |
|
|
|
this.activeDid, |
|
|
|
); |
|
|
|
if (resp.status === 200) { |
|
|
|
const currentSettings = await (this as any).$getSettings(MASTER_SETTINGS_KEY, {}); |
|
|
|
await databaseUtil.updateDidSpecificSettings(this.activeDid, { |
|
|
|
isRegistered: true, |
|
|
|
...(await databaseUtil.retrieveSettingsForActiveAccount()), |
|
|
|
...currentSettings, |
|
|
|
}); |
|
|
|
this.isRegistered = true; |
|
|
|
} |
|
|
@ -675,19 +681,27 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Loads user settings from storage |
|
|
|
* Loads user settings from storage using enhanced mixin utilities |
|
|
|
* Sets component state for: |
|
|
|
* - API server |
|
|
|
* - Active DID |
|
|
|
* - Feed filters and view settings |
|
|
|
* - Registration status |
|
|
|
* - Notification acknowledgments |
|
|
|
* - API server, Active DID, Feed filters and view settings |
|
|
|
* - Registration status, Notification acknowledgments |
|
|
|
* |
|
|
|
* @internal |
|
|
|
* Called by mounted() and reloadFeedOnChange() |
|
|
|
*/ |
|
|
|
private async loadSettings() { |
|
|
|
const settings = await databaseUtil.retrieveSettingsForActiveAccount(); |
|
|
|
// Use enhanced mixin utility for default settings - much more concise! |
|
|
|
const settings = await (this as any).$getSettings( |
|
|
|
MASTER_SETTINGS_KEY, |
|
|
|
{ |
|
|
|
apiServer: "", |
|
|
|
activeDid: "", |
|
|
|
filterFeedByVisible: false, |
|
|
|
filterFeedByNearby: false, |
|
|
|
isRegistered: false, |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
this.apiServer = settings.apiServer || ""; |
|
|
|
this.activeDid = settings.activeDid || ""; |
|
|
|
this.feedLastViewedClaimId = settings.lastViewedClaimId; |
|
|
@ -711,8 +725,7 @@ export default class HomeView extends Vue { |
|
|
|
* Called by mounted() and initializeIdentity() |
|
|
|
*/ |
|
|
|
private async loadContacts() { |
|
|
|
const platformService = PlatformServiceFactory.getInstance(); |
|
|
|
const dbContacts = await platformService.dbQuery("SELECT * FROM contacts"); |
|
|
|
const dbContacts = await (this as any).$dbQuery("SELECT * FROM contacts"); |
|
|
|
this.allContacts = databaseUtil.mapQueryResultToValues( |
|
|
|
dbContacts, |
|
|
|
) as unknown as Contact[]; |
|
|
@ -739,12 +752,10 @@ export default class HomeView extends Vue { |
|
|
|
this.activeDid, |
|
|
|
); |
|
|
|
if (resp.status === 200) { |
|
|
|
const settings = |
|
|
|
await databaseUtil.retrieveSettingsForActiveAccount(); |
|
|
|
const currentSettings = await (this as any).$getSettings(MASTER_SETTINGS_KEY, {}); |
|
|
|
await databaseUtil.updateDidSpecificSettings(this.activeDid, { |
|
|
|
apiServer: this.apiServer, |
|
|
|
isRegistered: true, |
|
|
|
...settings, |
|
|
|
...currentSettings, |
|
|
|
}); |
|
|
|
this.isRegistered = true; |
|
|
|
} |
|
|
@ -799,14 +810,14 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Checks if user needs onboarding |
|
|
|
* Checks if user needs onboarding using enhanced mixin utilities |
|
|
|
* Opens onboarding dialog if not completed |
|
|
|
* |
|
|
|
* @internal |
|
|
|
* Called by mounted() |
|
|
|
*/ |
|
|
|
private async checkOnboarding() { |
|
|
|
const settings = await databaseUtil.retrieveSettingsForActiveAccount(); |
|
|
|
const settings = await (this as any).$getSettings(MASTER_SETTINGS_KEY, {}); |
|
|
|
if (!settings.finishedOnboarding) { |
|
|
|
(this.$refs.onboardingDialog as OnboardingDialog).open(OnboardPage.Home); |
|
|
|
} |
|
|
@ -866,16 +877,20 @@ export default class HomeView extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Reloads feed when filter settings change |
|
|
|
* Reloads feed when filter settings change using enhanced mixin utilities |
|
|
|
* - Updates filter states |
|
|
|
* - Clears existing feed data |
|
|
|
* - Clears existing feed data |
|
|
|
* - Triggers new feed load |
|
|
|
* |
|
|
|
* @public |
|
|
|
* Called by FeedFilters component when filters change |
|
|
|
*/ |
|
|
|
async reloadFeedOnChange() { |
|
|
|
const settings = await databaseUtil.retrieveSettingsForActiveAccount(); |
|
|
|
const settings = await (this as any).$getMergedSettings( |
|
|
|
MASTER_SETTINGS_KEY, |
|
|
|
this.activeDid, |
|
|
|
{ filterFeedByVisible: false, filterFeedByNearby: false } |
|
|
|
); |
|
|
|
this.isFeedFilteredByVisible = !!settings.filterFeedByVisible; |
|
|
|
this.isFeedFilteredByNearby = !!settings.filterFeedByNearby; |
|
|
|
this.isAnyFeedFilterOn = checkIsAnyFeedFilterOn(settings); |
|
|
|