Skip to content

Commit

Permalink
Merge pull request #184 from the-wright-jamie/development
Browse files Browse the repository at this point in the history
Development to Stage
  • Loading branch information
the-wright-jamie authored Feb 1, 2024
2 parents e7a8196 + 36a95d3 commit 88c6b4d
Show file tree
Hide file tree
Showing 11 changed files with 357 additions and 279 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build and test on Pull Request
on: pull_request
name: Build and Test
on: [push, pull_request]

jobs:
test:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish-to-stores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
name: tab-nine-chromium
- run: zip release.zip ./* -r
- run: npm install -g chrome-webstore-upload-cli
- run: chrome-webstore-upload upload --source release.zip --extension-id ${{ secrets.CHROME_EXTENSION_ID }} --client-id ${{ secrets.CI_GOOGLE_CLIENT_ID }} --client-secret ${{ secrets.CI_GOOGLE_CLIENT_SECRET }} --refresh-token ${{ secrets.CI_GOOGLE_REFRESH_TOKEN }} --auto-publish
- run: chrome-webstore-upload upload --source release.zip --extension-id ${{ secrets.CHROME_EXTENSION_ID }} --client-id ${{ secrets.CI_GOOGLE_CLIENT_ID }} --client-secret ${{ secrets.CI_GOOGLE_CLIENT_SECRET }} --refresh-token ${{ secrets.CI_GOOGLE_REFRESH_TOKEN }}
- run: chrome-webstore-upload publish --extension-id ${{ secrets.CHROME_EXTENSION_ID }} --client-id ${{ secrets.CI_GOOGLE_CLIENT_ID }} --client-secret ${{ secrets.CI_GOOGLE_CLIENT_SECRET }} --refresh-token ${{ secrets.CI_GOOGLE_REFRESH_TOKEN }}
upload-firefox-store:
needs: [build]
name: Upload extension to Firefox Store
Expand Down
504 changes: 258 additions & 246 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tab-nine",
"version": "1.3.0",
"version": "1.3.1",
"license": "GPL-3.0",
"private": true,
"scripts": {
Expand All @@ -16,49 +16,49 @@
"translations": "node ./scripts/translations.js"
},
"dependencies": {
"core-js": "^3.33.2",
"core-js": "^3.34.0",
"date-fns": "^2.28.0",
"date-fns-tz": "^2.0.0",
"feather-icons": "^4.29.1",
"github-calendar": "^2.3.2",
"in-browser-language": "^1.0.3",
"nanoid": "^3.2.0",
"nanoid": "^3.3.7",
"normalize.css": "^8.0.1",
"react": "^18.0.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-error-boundary": "^4.0.12",
"react-github-btn": "^1.4.0",
"react-intl": "^6.5.4",
"tlds": "^1.245.0",
"react-intl": "^6.5.5",
"tlds": "^1.249.0",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"@types/jest": "^29.5.7",
"@types/node": "^20.9.0",
"@types/react": "^18.2.36",
"@types/react-dom": "^18.2.15",
"@types/webextension-polyfill": "^0.10.6",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.3",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.17",
"@types/webextension-polyfill": "^0.10.7",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"dotenv": "^16.3.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.3",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"mini-css-extract-plugin": "^2.7.6",
"node-sass": "^9.0.0",
"prettier": "3.1.0",
"prettier": "3.1.1",
"raw-loader": "^4.0.2",
"react-intl-translations-manager": "^5.0.3",
"sass-loader": "^13.0.0",
"ts-loader": "^9.5.0",
"typescript": "^5.2.2",
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"typescript-react-intl": "^0.4.1",
"url-loader": "^4.1.1",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-ext-reloader": "^1.1.10",
"webpack-ext-reloader": "^1.1.12",
"workbox-webpack-plugin": "^7.0.0"
}
}
17 changes: 16 additions & 1 deletion src/plugins/backgrounds/unsplash/Unsplash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const Unsplash: React.FC<Props> = ({
}
}, [cache]);

const url = item ? buildLink(item.src) : null;
const url = item?.src.length ? buildLink(item.src) : null;

const go = (amount: number) =>
cache && cache.items[cache.cursor + amount]
Expand Down Expand Up @@ -211,6 +211,12 @@ type RotatingCache<Item> = {
deps: unknown[];
};

function arrayEquals(a: any[], b: any[]): boolean {
return (
a.length === b.length && a.every((element, index) => element === b[index])
);
}

/**
* Implementation adapted from react's hook source.
* Too bad they do not export it.
Expand All @@ -220,6 +226,15 @@ function areDepsEqual(prevDeps: unknown[], nextDeps: unknown[]) {
if (Object.is(nextDeps[i], prevDeps[i])) {
continue;
}
// if nextdeps and prevdeps are arrays, compare them via separate func
// because Object.is doesn't work for arrays
else if (
Array.isArray(nextDeps[i]) &&
Array.isArray(prevDeps[i]) &&
arrayEquals(nextDeps[i] as any[], prevDeps[i] as any[])
) {
continue;
}
return false;
}
return true;
Expand Down
15 changes: 14 additions & 1 deletion src/plugins/backgrounds/unsplash/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ export const fetchImages = async ({
const res = await fetch(`${url}?${params}`, { headers, cache: "no-cache" });
const body = await res.json();

// TODO: validate types
if (res.status != 200) {
const empty: Image[] = [
{
src: "",
credit: {
imageLink: "",
location: undefined,
userName: "",
userLink: "",
}
}
]
return empty;
};

return body.map((item: any) => ({
src: item.urls.raw,
Expand Down
25 changes: 18 additions & 7 deletions src/plugins/widgets/quote/QuoteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import { Props, defaultData } from "./types";

const QuoteSettings: React.FC<Props> = ({ data = defaultData, setData }) => (
<div className="QuoteSettings">
<p>
Daily Quotes from 'They Said So' are no longer available, please see{" "}
<a href="https://github.com/the-wright-jamie/tab-nine/issues/29">
this GitHub issue
</a>
. We apologize for the inconvenience this may have caused.
</p>
<h5>Hourly Quotes</h5>
<label>
<input
Expand All @@ -30,6 +23,24 @@ const QuoteSettings: React.FC<Props> = ({ data = defaultData, setData }) => (
Developer Excuses
</a>
</p>
<label>
<input
type="radio"
checked={data.category === "random"}
onChange={() => setData({ category: "random" })}
/>{" "}
Random
</label>
<p>
Powered by{" "}
<a
href="https://github.com/lukePeavey/quotable"
target="_blank"
rel="noopener noreferrer"
>
Quotable
</a>
</p>
</div>
);

Expand Down
30 changes: 28 additions & 2 deletions src/plugins/widgets/quote/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@ import { API } from "../../types";
import { Quote } from "./types";

// Get developer excuse
async function getDeveloperExcuse() {
async function getDeveloperExcuse(): Promise<{quote: string, author: string | undefined}> {
try {
const res = await fetch("https://api.tabliss.io/v1/developer-excuses");
const body = await res.json();

return {
quote: body.data,
author: undefined
};
} catch (err) {
return {
quote: "Unable to get a new developer excuse.",
author: undefined
};
}
}

async function getRandomQuote(): Promise<{quote: string, author: string | undefined}> {
try {
const res = await fetch("https://api.quotable.io/quotes/random?limit=1");
const body = await res.json();
const quote = body[0];

return {
quote: quote.content,
author: quote.author
};
} catch (err) {
return {
quote: "Unable to get random quote.",
author: undefined
};
}
}
Expand All @@ -21,17 +41,23 @@ export async function getQuote(
loader: API["loader"],
category: string,
): Promise<Quote> {

loader.push();

const data = await getDeveloperExcuse();
const data =
category === "developerexcuses"
? await getDeveloperExcuse()
: await getRandomQuote();

loader.pop();

const quote = cleanQuote(data.quote);
const author = data.author;

return {
...data,
quote,
author,
timestamp: Date.now(),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const Settings: React.FC = () => {
tagName="p"
/>
<p style={{ textAlign: "center" }}>
Tab Nine <code>v1.3.0</code>
Tab Nine <code>v1.3.1</code>
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion target/chromium/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Tab Nine",
"short_name": "Tab Nine",
"version": "1.3.0",
"version": "1.3.1",
"description": "A modern, highly customisable New Tab page with many widgets that does not require any permissions.",
"chrome_url_overrides": {
"newtab": "index.html"
Expand Down
2 changes: 1 addition & 1 deletion target/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Tab Nine",
"short_name": "Tab Nine",
"version": "1.3.0",
"version": "1.3.1",
"description": "A modern, highly customisable New Tab page with many widgets that does not require any permissions.",
"applications": {
"gecko": {
Expand Down

0 comments on commit 88c6b4d

Please sign in to comment.