Skip to content

Commit

Permalink
chore: changes for 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei0x309 committed Sep 29, 2023
1 parent 50abf0f commit d9b4531
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 37 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [Version 1.1.1]

- changed auth condition
- refactor image loader for notification images
- added constant for yup app base url
- other cleanups

## [Version 1.0.9]

- added: browser notifications(work similar to push notifications) for comment, mention, follow with the ability to open the notification in app
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yup live",
"description": "Light alternative extension for yup protocol",
"version": "1.0.9",
"version": "1.1.1",
"manifest_version": 3,
"icons": {
"16": "src/assets/icons/yup_ext_16.png",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yup-live-browser-extension",
"description": "Yup Live Browser Extension",
"version": "1.0.9",
"version": "1.1.0",
"type": "module",
"author": "andrei0x309",
"license": "MIT",
Expand Down
9 changes: 5 additions & 4 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setBadge, extrenalNavigate } from '@/utils/chrome-misc'
import { closeTo } from '@/utils/time';
import { getActionUsage } from '@/utils/user';
import { executeVote, getVotePayload } from '@/utils/votes';
import { YUP_APP_BASE } from '@/constants/config';

// Disable conflict with yup extension
const yupExtensionId = 'nhmeoaahigiljjdkoagafdccikgojjoi'
Expand All @@ -25,7 +26,7 @@ const buttons = {

const notificationActionListner = async (id: string) => {
try {
const url = new URL(notificationUrl ?? 'https://app.yup.io/notifications')
const url = new URL(notificationUrl ?? `${YUP_APP_BASE}/notifications`)
extrenalNavigate(url.href)
chrome.notifications.clear(id)
} catch {
Expand Down Expand Up @@ -124,7 +125,7 @@ const alarmHandler = async () => {
if (store?.settings.notificationsEnabled) {
try {
const notifications = await requests.notifications as Notification[]
const notSeen = notifications.reverse().filter(notif => !notif.seen)
const notSeen = notifications.filter(notif => !notif.seen)
const updateSettings = {} as Record<string, boolean>
if (notSeen.length > 0) {
setBadge(String(notSeen.length))
Expand Down Expand Up @@ -217,7 +218,7 @@ const alarmHandler = async () => {
chrome.alarms.create(
'alarm',
{
periodInMinutes: 1,
periodInMinutes: 0.1,
},
)

Expand Down Expand Up @@ -252,7 +253,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {

chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
try {
console.log('Message received', request)
// console.log('Message received', request)
const lastLoginNotifTime = Number(await getSetting('lastLoginNotif'))
const moreThanOneDay = (new Date().getTime() - lastLoginNotifTime) > 864e5
if (request.type === SEND_AUTH_NOTIF && moreThanOneDay) {
Expand Down
2 changes: 0 additions & 2 deletions src/client/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class WebCommunicator {
const allowRegex = /^((http:|https:))?([/][/])?(www.)?[a-zA-Z\-_0-9]{0,}\.?[a-zA-Z\-_0-9]{0,}(yup.info.gf|yup-live.pages.dev|.yup.io|yup-team.vercel.app|localhost\/|localhost:)(.*)/gm
const isAllowed = allowRegex.test(window.location.href)

console.log('isAllowed', isAllowed)

if(isAllowed) {
new WebCommunicator(true)
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ImgLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export let source
let loading = true
let loaded = false
let error = false
export let loading = true
export let loaded = false
export let error = false
export const onLoad = () => {
loading = false
Expand Down
17 changes: 10 additions & 7 deletions src/components/Notification.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import { chromeUrl } from "@/utils/chrome-misc";
import { extrenalNavigate } from "@/utils/chrome-misc";
import LikeIcon from '@/components/LikeIcon.svelte';
import { YUP_APP_BASE } from "@/constants/config";
let loader;
const appBase = "https://app.yup.io";
let loader;
export let notif: Notification;
</script>
Expand All @@ -35,7 +35,7 @@
</p>
<p class="text-xs text-gray-200 my-0 mt-1">
<span
on:click={() => extrenalNavigate(`${appBase}/post/${notif.meta.postid}`)}
on:click={() => extrenalNavigate(`${YUP_APP_BASE}/post/${notif.meta.postid}`)}
aria-hidden
class="text-blue-200 interactive-svg">{finalUrl}</span
>
Expand Down Expand Up @@ -73,11 +73,12 @@
<div class="flex flex-col notifBody">
{#each notif.senders as sender}
<div class="flex flex-row items-center">
<ImgLoader bind:this={loader} source="{sender?.avatar} ">

<ImgLoader bind:this={loader} source="{sender?.avatar}" loaded={loader?.loaded ?? false} error={loader?.error ?? false} loading={loader?.loading ?? true}>
<img
class="notificationImage"
on:load={() => loader.onLoad()}
on:error={() => loader.onError()}
on:load={() => { loader.loaded = true; loader.loading = false; }}
on:error={() => { loader.error = true; loader.loading = false; }}
style={$mainStore.settings.theme === "light" ? "filter: invert(0.9);" : ""}
slot="img"
src={sender.avatar}
Expand Down Expand Up @@ -107,7 +108,7 @@
<p
aria-hidden
class="text-xs text-gray-200 my-0 mt-1"
on:click={() => extrenalNavigate(`${appBase}/account/${sender?._id}`)}
on:click={() => extrenalNavigate(`${YUP_APP_BASE}/account/${sender?._id}`)}
>
<b>{sender?.handle || `${sender?._id?.slice(0, 6)}...`}</b>
followed you.
Expand Down Expand Up @@ -151,6 +152,8 @@
border-radius: 6px;
margin-left: 0.5rem;
margin-top: 0.5rem;
border: 1px solid rgba(0, 0, 0, 0.233);
background-image: linear-gradient(rgba(0, 0, 0, 0.123), rgba(0, 0, 0, 0.123));
}
.notifBody {
Expand Down
4 changes: 3 additions & 1 deletion src/components/RateWebsite.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ $: {
<div class="flex items-center flex-col text-[0.8rem] leading-4 mb-4">
<div class="mb relative">
<ImgLoader source={tab?.favIconUrl ?? ''} bind:this={loader}>
<img style="{ $mainStore.settings.theme === 'light'? 'filter: invert(0.9);' : '' }" slot="img" on:load={() => loader.onLoad()} on:error={() => loader.onError}
<img style="{ $mainStore.settings.theme === 'light'? 'filter: invert(0.9);' : '' }" slot="img"
on:load={() => loader.onLoad()}
on:error={() => loader.onError}
class="w-5 h-5 mt-2 rounded-full wicon" src="{tab?.favIconUrl ?? ''}" alt="favicon" />
<svg class="w-5 h-5 mt-2 rounded-full wicon" style="{ $mainStore.settings.theme === 'light'? 'filter: invert(0.9);' : '' }" slot="error" viewBox="0 0 512 512"><g><polygon points="40,38.999 40,468.998 215,293.998 270,348.998 360,258.998 470,358.998 470,38.999 " style="fill:#EFF3F6;"/>
<g><circle cx="150" cy="158.999" r="40" style="fill:#FCD884;"/></g><g><polygon points="470,358.998 470,468.998 385,468.998 385,463.998 270,348.998 360,258.998 " style="fill:#70993F;"/></g><g><polygon points="385,463.998 385,468.998 40,468.998 215,293.998 270,348.998" style="fill:#80AF52;"/></g></g><g/></svg>
Expand Down
4 changes: 1 addition & 3 deletions src/constants/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export const API_BASE = 'https://api.yup.io'
export const DEV_BASE = 'http://localhost:4566'
export const YUP_LIVE_BASE = 'https://app.yup.io'
export const APP_BASE = YUP_LIVE_BASE
export const YUP_APP_BASE = 'https://app.yup.io'
6 changes: 3 additions & 3 deletions src/pages/Entry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { navigate } from '@/utils/router'
import { mainStore } from '@/utils/store'
// https://yup-live.pages.dev
import { APP_BASE } from '@/constants/config'
import { YUP_APP_BASE } from '@/constants/config'
import Alert from '@/components/Alert.svelte'
import { alertStore } from '@/utils/store'
import PageLoader from "@/components/PageLoader.svelte";
Expand All @@ -29,7 +29,7 @@
onMount(async () => {
store = await getStore()
alertStore.set(alert)
auth = store?.user?.auth?.userId ?? false
auth = store?.user?.auth?.authToken ?? false
if(auth){
await mainStore.set(store)
await navigate('/')
Expand All @@ -45,7 +45,7 @@

<div class="entry" style="{ $mainStore.settings.theme === 'light'? 'filter: invert(1);' : '' }">

<a href="#app" on:click="{() => extrenalNavigate(APP_BASE)}">
<a href="#app" on:click="{() => extrenalNavigate(YUP_APP_BASE)}">
<h1 aria-label="logo" class="logo inline-flex items-center text-[1.6rem] font-bold gap-2.5 pl-8">
<span class="gradient-text" style="{ $mainStore.settings.theme === 'light'? 'filter: invert(1.1);' : '' }" >YUP</span>
</h1>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Info.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { onMount } from 'svelte';
import PageLoader from '@/components/PageLoader.svelte';
import { getExtensionVersion, extrenalNavigate } from '@/utils/chrome-misc';
import { YUP_APP_BASE } from '@/constants/config';
let loading = true;
let version = '';
const extensionSourceLink = 'https://github.com/andrei0x309/yup-live-chrome-extension'
const yupLiveSourceLink = 'https://github.com/andrei0x309/yup-live'
const yupLiveLink = 'https://yup-live.pages.dev'
const yupAppLink = 'https://app.yup.io'
const yupAppLink = YUP_APP_BASE
const discordLink = 'https://discord.com/invite/HnaTAXK'
const yupForumLink = 'https://forum.yup.io'
const yupDocsLink = 'https://docs.yup.io'
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Login.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<script lang="ts">
import { extrenalNavigate } from "@/utils/chrome-misc";
import { APP_BASE } from '@/constants/config'
import { YUP_APP_BASE } from '@/constants/config'
</script>

<a href="#app" on:click={() => extrenalNavigate(`${APP_BASE}/login`)}>
<a href="#app" on:click={() => extrenalNavigate(`${YUP_APP_BASE}/login`)}>
<svg enable-background="new 0 0 32 32" viewBox="0 0 32 32" class="w-20 mb-10 mt-8 svg-fill">
<g id="lock"><path d="M25,13V9c0-4.971-4.029-9-9-9c-4.971,0-9,4.029-9,9v4c-1.657,0-3,1.343-3,3v3v1v2v1c0,4.971,4.029,9,9,9h6 c4.971,0,9-4.029,9-9v-1v-2v-1v-3C28,14.342,26.656,13,25,13z M9,9c0-3.866,3.134-7,7-7c3.866,0,7,3.134,7,7v4h-2V9.002 c0-2.762-2.238-5-5-5c-2.762,0-5,2.238-5,5V13H9V9z M20,9v0.003V13h-8V9.002V9c0-2.209,1.791-4,4-4C18.209,5,20,6.791,20,9z M26,19 v1v2v1c0,3.859-3.141,7-7,7h-6c-3.859,0-7-3.141-7-7v-1v-2v-1v-3c0-0.552,0.448-1,1-1c0.667,0,1.333,0,2,0h14c0.666,0,1.332,0,2,0 c0.551,0,1,0.448,1,1V19z"/>
<path d="M16,19c-1.104,0-2,0.895-2,2c0,0.607,0.333,1.76,0.667,2.672c0.272,0.742,0.614,1.326,1.333,1.326 c0.782,0,1.061-0.578,1.334-1.316C17.672,22.768,18,21.609,18,21C18,19.895,17.104,19,16,19z"/></g>
</svg>
</a>
<div class="text-[1.6rem] mb-4 uppercase">
<a href="#app" on:click="{() => extrenalNavigate(`${APP_BASE}/auth`)}">
<a href="#app" on:click="{() => extrenalNavigate(`${YUP_APP_BASE}/auth`)}">
Login on web app
</a>
</div>
<a href="#app" on:click="{() => extrenalNavigate(`${APP_BASE}/auth`)}">
<a href="#app" on:click="{() => extrenalNavigate(`${YUP_APP_BASE}/auth`)}">
<svg enable-background="new 0 0 48 48" viewBox="0 0 48 48" class="w-14 svg-fill my-4"><path d="M0.115,30.348c0-7.771,6.303-14.073,14.074-14.073h0.002h14.071V8.051l19.622,15.261l-19.622,15.26v-8.225 H10.458c-3.887,0-7.037,3.152-7.037,7.037c0,0.906,0.186,1.768,0.5,2.564C1.566,37.434,0.115,34.064,0.115,30.348z"/></svg>
</a>
5 changes: 2 additions & 3 deletions src/pages/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { extrenalNavigate } from "@/utils/chrome-misc";
import ImgLoader from "@/components/ImgLoader.svelte";
import { onMount } from "svelte";
import { APP_BASE } from "@/constants/config";
import { YUP_APP_BASE } from "@/constants/config";
import RateWebsite from "@/components/RateWebsite.svelte";
import { mainStore } from "@/utils/store";
import { formatNumber, truncteEVMAddr } from "@/utils/misc";
Expand All @@ -19,7 +19,6 @@
};
onMount(async () => {
console.log($mainStore);
if ($mainStore?.user?.profile?.yup?.avatar && !$mainStore?.user?.profile?.yup?.avatar.endsWith(".mp4")) {
avatar = $mainStore?.user?.profile?.yup?.avatar;
} else if ($mainStore?.user?.profile?.lens?.avatar && !$mainStore?.user?.profile?.lens?.avatar.endsWith(".mp4")) {
Expand All @@ -41,7 +40,7 @@
>{$mainStore?.user?.profile?.yupScore?.toFixed(0)}</span
><span class="text-[0.7rem]">100<br />MAX</span>
</div>
<div on:click={() => extrenalNavigate(`${APP_BASE}/account/${$mainStore.user.auth.userId}`)} aria-hidden class="flex flex-col justify-center mb-1 w-16">
<div on:click={() => extrenalNavigate(`${YUP_APP_BASE}/account/${$mainStore.user.auth.userId}`)} aria-hidden class="flex flex-col justify-center mb-1 w-16">
<ImgLoader source={avatar} bind:this={loader}>
<img
style="{ $mainStore.settings.theme === 'light'? 'filter: invert(1);' : '' }"
Expand Down
1 change: 0 additions & 1 deletion src/pages/Notifications.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ onMount(async () => {
})
pastNotifsPromise = getNotifStorage()
console.log(notifs);
loading = false;
clearNotifications($mainStore).then(
() => {
Expand Down
1 change: 0 additions & 1 deletion src/pages/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const setSettingsLocal = async (setting: string, value = '') => {
onMount(async () => {
settings = $mainStore.settings
console.log(settings)
});
</script>
Expand Down
2 changes: 0 additions & 2 deletions src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export const lastRewardNotifDefault = {
id: '',
}



export type StorageType = typeof storageDefault

export const wipeStorage = async () => {
Expand Down

0 comments on commit d9b4531

Please sign in to comment.