Skip to content

Commit

Permalink
Merge pull request #65 from thinkonmay/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
epitchi authored Jun 1, 2024
2 parents 7b8decb + b60ff1d commit 5bec1ed
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src-tauri
Submodule src-tauri updated 1 files
+1 −1 tauri.conf.json
24 changes: 15 additions & 9 deletions src/backend/reducers/fetch/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export type StartRequest = {
export async function StartVirtdaemon(
computer: Computer,
volume_id?: string
): Promise<any> {
): Promise<Error | StartRequest> {
const { address } = computer;

const id = crypto.randomUUID();
Expand All @@ -146,19 +146,25 @@ export async function StartVirtdaemon(
vm: {
GPUs: ['GA104 [GeForce RTX 3060 Ti Lite Hash Rate]'],
Volumes: volume_id != undefined ? [volume_id] : [],
CPU: '16',
CPU: '12',
RAM: '16'
}
};

const interval = setInterval(
() => internalFetch<StartRequest>(address, '_new', req),
3000
);
const resp = await internalFetch(address, 'new', req);
clearInterval(interval);
if (resp instanceof Error) return resp;
let running = true;
(async () => {
await new Promise((r) => setTimeout(r, 1000));
while (running) {
internalFetch<{}>(address, '_new', req).catch(console.log);
await new Promise((r) => setTimeout(r, 1000));
}
})();

let resp: Error | StartRequest = new Error('unable to request');
try {
resp = await internalFetch<StartRequest>(address, 'new', req);
} catch {}
running = false;
return resp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/reducers/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function language() {
);
vn.set(
Contents.RUN_OUT_OF_GPU_STOCK_NOTIFY,
'Hệ thống đang hết máy, sẽ thông báo & tự động kết nối khi có máy trống. Bạn giữ tab và đợi xíu ạ!'
'Hệ thống đang hết máy, sẽ tự động kết nối & thông báo khi có máy trống. Vui lòng giữ tab!'
);

en.set(Contents.NOT_READY, "Installing, wait 3-5' until game logo appears");
Expand Down
4 changes: 2 additions & 2 deletions src/backend/reducers/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import { RemoteDesktopClient } from '../../../src-tauri/core/app';
import { AxisType } from '../../../src-tauri/core/models/hid.model';
import { EventCode, HIDMsg } from '../../../src-tauri/core/models/keys.model';
import { convertJSKey } from '../../../src-tauri/core/utils/convert';
import { getVolumeIdByEmail } from '../actions';
import { sleep } from '../utils/sleep';
import { isMobile } from './../utils/checking';
import { CAUSE, pb, supabase } from './fetch/createClient';
import { BuilderHelper } from './helper';
import { getVolumeIdByEmail } from '../actions';

const size = () =>
client != null
? client.video.video.videoHeight * client.video.video.videoWidth
: 1920 * 1080;
export const MAX_BITRATE = () => (20000 / (1920 * 1080)) * size();
export const MAX_BITRATE = () => (10000 / (1920 * 1080)) * size();
export const MIN_BITRATE = () => (1000 / (1920 * 1080)) * size();
export const MAX_FRAMERATE = 240;
export const MIN_FRAMERATE = 40;
Expand Down
5 changes: 4 additions & 1 deletion src/backend/reducers/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export const workerAsync = {
}>();
const volume_id = all.at(0)?.local_id;

for (let i = 0; i < 2; i++) {
const now = () => new Date().getTime() / 1000 / 60;
const start = now();
while (now() - start < 180) {
// 3 hours
const node = new RenderNode(
(getState() as RootState).worker.data
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/start/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export const SidePane = () => {
max="100"
value={remote.bitrate}
/>
<span>20mbs</span>
<span>10mbs</span>
</div>
</div>

Expand Down
16 changes: 0 additions & 16 deletions src/containers/background/back.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,7 @@
transition: all 0.2s ease;
}

.remote {
object-fit: contain;
width: 100vw;
height: 100vh;
//background-color: var(--wintheme);
background-color: rgb(0, 0, 0);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
transition: all 0.2s ease;
}

@media (1px < width < 1024px) {
.remote {
object-fit: contain;
}
}

.bootscreen {
position: absolute;
Expand Down
35 changes: 29 additions & 6 deletions src/containers/popup/modal/notify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@ import { TbLoader3 } from 'react-icons/tb';
import { useAppSelector } from '../../../backend/reducers';
import { Contents } from '../../../backend/reducers/locales';

export function notify({ data: { title, tips, loading, text } }) {
const TIME_RUN_OUT_OF_GPU = 120 * 1000; //sec
export function notify({ data: { title, tips = true, loading = true, text } }) {
const t = useAppSelector((state) => state.globals.translation);
const [textTrans, setTextTrans] = useState('');
const [isLaterThan15s, setIsLaterThan15s] = useState(false);

useEffect(() => {
let interval;
if (title == 'Connect to PC') {
const referenceTime = new Date();
const laterTime = new Date(
referenceTime.getTime() + TIME_RUN_OUT_OF_GPU
);

interval = setInterval(() => {
const currentTime = new Date();
if (currentTime > laterTime) {
setIsLaterThan15s(true);
setTextTrans(t[Contents.RUN_OUT_OF_GPU_STOCK_NOTIFY]);
clearInterval(interval);
}
}, 6000);
}

return () => clearInterval(interval);
}, [title]);
useEffect(() => {
setTextTrans(t[text]);
}, [text]);
Expand All @@ -16,12 +39,12 @@ export function notify({ data: { title, tips, loading, text } }) {
<div className="notify-icon">
<TbLoader3 className="animate-spin" />
</div>
<p className="text-center text-[1.2rem] mb-[24px]">
<p className="text-center text-[1.2rem] mb-[16px]">
{title ?? 'Please wait...'}
</p>
{textTrans ? <p>{textTrans} </p> : null}
{loading ?? true ? <LoadingProgressBar /> : null}
{tips ?? true ? <Protip /> : null}
{loading && !isLaterThan15s ? <LoadingProgressBar /> : null}
{tips ? <Protip /> : null}
</div>
);
}
Expand Down Expand Up @@ -83,9 +106,9 @@ const Protip = () => {
};
}, []);
return (
<div className="mt-[14px]">
<div className="mt-[24px]">
<strong>Pro tip:</strong>
<p>{listDemoTip[currentTip]}</p>
<p className="mt-[8px]">{listDemoTip[currentTip]}</p>
</div>
);
};
1 change: 0 additions & 1 deletion src/containers/remote/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export const Remote = () => {
autoPlay
muted
playsInline
objectfit={'contain'}
loop
></video>
<audio
Expand Down
18 changes: 18 additions & 0 deletions src/containers/remote/remote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
transition: all 0.2s ease;
}

.remote {
object-fit: fill;
width: 100vw;
height: 100vh;
//background-color: var(--wintheme);
background-color: rgb(0, 0, 0);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
transition: all 0.2s ease;
}

@media (1px < width < 1024px) {
.remote {
object-fit: contain;
}
}

.bootscreen {
position: absolute;
top: 0;
Expand Down

0 comments on commit 5bec1ed

Please sign in to comment.