Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS] Fix pagination controls #9357

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<script setup lang="ts">
import { I18n } from 'megashark-lib';
import { onUnmounted, ref, watch } from 'vue';
import { onUnmounted, ref, watch, computed } from 'vue';
import { FileControlsGroup, FileControlsInput } from '@/components/viewers';

const props = defineProps<{
Expand All @@ -40,6 +40,9 @@ defineExpose({

const inputRef = ref();
const currentPage = ref('1');
const inputLengthStyle = computed(() => {
return `${5 + props.length.toString().length * 1}rem`;
});

const pageWatchCancel = watch(
() => props.page,
Expand Down Expand Up @@ -90,6 +93,6 @@ onUnmounted(() => {

<style scoped lang="scss">
.page-number-input {
width: 6rem;
width: v-bind(inputLengthStyle);
}
</style>
34 changes: 17 additions & 17 deletions client/src/parsec/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export async function readFile(
fd: FileDescriptor,
offset: number,
size: number,
): Promise<Result<ArrayBuffer, WorkspaceFdReadError>> {
): Promise<Result<Uint8Array, WorkspaceFdReadError>> {
if (!needsMocks()) {
return await libparsec.workspaceFdRead(workspaceHandle, fd, offset, size);
} else {
Expand All @@ -325,29 +325,29 @@ export async function readFile(

switch (ext) {
case 'xlsx':
console.log('Using XLSX content');
return { ok: true, value: MockFiles.XLSX };
offset === 0 && console.log('Using XLSX content');
return { ok: true, value: MockFiles.XLSX.slice(offset, offset + size) };
case 'png':
console.log('Using PNG content');
return { ok: true, value: MockFiles.PNG };
offset === 0 && console.log('Using PNG content');
return { ok: true, value: MockFiles.PNG.slice(offset, offset + size) };
case 'docx':
console.log('Using DOCX content');
return { ok: true, value: MockFiles.DOCX };
offset === 0 && console.log('Using DOCX content');
return { ok: true, value: MockFiles.DOCX.slice(offset, offset + size) };
case 'txt':
console.log('Using TXT content');
return { ok: true, value: MockFiles.TXT };
offset === 0 && console.log('Using TXT content');
return { ok: true, value: MockFiles.TXT.slice(offset, offset + size) };
case 'py':
console.log('Using PY content');
return { ok: true, value: MockFiles.PY };
offset === 0 && console.log('Using PY content');
return { ok: true, value: MockFiles.PY.slice(offset, offset + size) };
case 'pdf':
console.log('Using PDF content');
return { ok: true, value: MockFiles.PDF };
offset === 0 && console.log('Using PDF content');
return { ok: true, value: MockFiles.PDF.slice(offset, offset + size) };
case 'mp3':
console.log('Using MP3 content');
return { ok: true, value: MockFiles.MP3 };
offset === 0 && console.log('Using MP3 content');
return { ok: true, value: MockFiles.MP3.slice(offset, offset + size) };
case 'mp4':
console.log('Using MP4 content');
return { ok: true, value: MockFiles.MP4 };
offset === 0 && console.log('Using MP4 content');
return { ok: true, value: MockFiles.MP4.slice(offset, offset + size) };
}
console.log('Using default file content');
return {
Expand Down
Loading