Skip to content

Commit

Permalink
devop: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olgakup committed Jan 13, 2025
1 parent cf0c453 commit 4bbff4d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/extension/src/libs/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const trackUpdatesEvents = (event: UpdatesEventType, options: {
network: NetworkNames;
location?: UpdatesOpenLocation;
duration?: number;
}) => {
}): void => {
metrics.track('updatesClick', { event, ...options });

}
Expand Down
38 changes: 19 additions & 19 deletions packages/extension/src/libs/updates-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@ class UpdatesState {
}

async getState(): Promise<IState> {
return this.storage.get(StorageKeys.updatesInfo);
const state = this.storage.get(StorageKeys.updatesInfo);
if (!state) {
const newState: IState = {
lastVersionViewed: '',
currentRelease: '',
currentReleaseTimestamp: 0,
}
return newState
}
return state;
}

async getLastVersionViewed(): Promise<IState['lastVersionViewed']> {
const state: IState | undefined = await this.getState();
if (state && state.lastVersionViewed) {
return state.lastVersionViewed;
}
return '';
const state: IState = await this.getState();
return state?.lastVersionViewed ?? '';
}
async setLastVersionViewed(lastVersionViewed: string): Promise<void> {
const state: IState | undefined = await this.getState();
const state: IState = await this.getState();
const newState: IState = { ...state, lastVersionViewed }
await this.setState(newState);
}

async getCurrentRelease(): Promise<IState['currentRelease']> {
const state: IState | undefined = await this.getState();
if (state && state.currentRelease) {
return state.currentRelease;
}
return ''
const state: IState = await this.getState();
return state?.currentRelease ?? '';
}

async setCurrentRelease(currentRelease: string): Promise<void> {
const state: IState | undefined = await this.getState();
const state: IState = await this.getState();
const newState: IState = { ...state, currentRelease }
await this.setState(newState);
}

async getCurrentReleaseTimestamp(): Promise<IState['currentReleaseTimestamp']> {
const state: IState | undefined = await this.getState();
if (state && state.currentReleaseTimestamp) {
return state.currentReleaseTimestamp;
}
return 0
const state: IState = await this.getState();
return state?.currentReleaseTimestamp ?? 0;
}

async setCurrentReleaseTimestamp(currentReleaseTimestamp: number): Promise<void> {
const state: IState | undefined = await this.getState();
const state: IState = await this.getState();
const newState: IState = { ...state, currentReleaseTimestamp }
await this.setState(newState);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/src/ui/action/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ const initUpdateState = async () => {
const currentReleaseInState = await updatesState.getCurrentRelease();
stateCurrentReleaseTimestamp.value =
await updatesState.getCurrentReleaseTimestamp();
if (currentReleaseInState !== currentVersion) {
if (
currentReleaseInState === '' ||
currentReleaseInState !== currentVersion
) {
await updatesState.setCurrentRelease(currentVersion);
const newReleaseTimestamp = Date.now();
await updatesState.setCurrentReleaseTimestamp(newReleaseTimestamp);
Expand Down
12 changes: 6 additions & 6 deletions packages/extension/src/ui/action/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ export const getLatestEnkryptVersion = (): Promise<string> => {
.catch(() => null);
};

export const getLatestEnkryptUpdates = (): Promise<Updates> => {
export const getLatestEnkryptUpdates = (): Promise<Updates | null> => {

const browser = detectBrowser();
const url = 'https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/configs/release-versions'
const fetchUrl = browser === BROWSER_NAMES.safari ? `${url}-safari.json` : `${url}.json`
console.log(fetchUrl)
return fetch(
fetchUrl
)
.then(res => res.json())
.then(releases => {
return releases;
})
.catch(() => null);
.catch((error) => {
console.error('Failed to fetch updates:', error);
return null
}
);
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<template>
<div class="settings__header">
<h2>What's New</h2>
<a class="settings__close" @click="$emit('window:close')">
<button
type="button"
class="settings__close"
@click="$emit('window:close')"
aria-label="Close what's new popup"
>
<close-icon />
</a>
</button>
</div>
</template>

Expand All @@ -27,6 +32,16 @@ defineEmits<{
padding: 24px 72px 12px 32px;
margin-bottom: 8px;
button {
background: none;
color: inherit;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit;
}
h2 {
font-style: normal;
font-weight: 700;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const props = defineProps({
const resolvedImg = ref('');
const isLoaded = ref(false);
const networkName = ref('Unkown');
const networkName = ref('Unknown');
getNetworkByName(props.networkId)
.then(network => {
Expand All @@ -42,7 +42,7 @@ getNetworkByName(props.networkId)
`Failed to load image in news for: ${props.networkId}`,
error,
);
isLoaded.value = true;
isLoaded.value = false;
resolvedImg.value = '';
});
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/ui/action/views/updates/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const displayVersions = computed(() => {
if (index === -1) {
return props.versions.slice(0, 10);
} else {
return props.versions.slice(index, 10);
return props.versions.slice(index, index + 10);
}
});
Expand Down

0 comments on commit 4bbff4d

Please sign in to comment.