Skip to content

Commit

Permalink
chore: resolve type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed May 9, 2024
1 parent 7a2276e commit e878b9a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 54 deletions.
9 changes: 2 additions & 7 deletions packages/hoppscotch-common/src/components/app/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,6 @@ const myTeams = useReadonlyStream(teamListAdapter.teamList$, null)
const workspace = workspaceService.currentWorkspace
const workspaceName = computed(() =>
workspace.value.type === "personal"
? t("workspace.personal")
: workspace.value.teamName
)
const refetchTeams = () => {
teamListAdapter.fetchList()
}
Expand Down Expand Up @@ -373,7 +367,8 @@ watch(
const newWorkspaceService = useService(NewWorkspaceService)
const activeWorkspaceName = computed(() => {
const activeWorkspaceHandleRef = newWorkspaceService.activeWorkspaceHandle.value?.get()
const activeWorkspaceHandleRef =
newWorkspaceService.activeWorkspaceHandle.value?.get()
if (activeWorkspaceHandleRef?.value.type === "ok") {
return activeWorkspaceHandleRef.value.data.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ const handleImportToStore = async (collections: HoppCollection[]) => {
const resultHandle = collectionHandleResult.right
if (resultHandle.value.type === "invalid") {
const requestHandleRef = resultHandle.get()
if (requestHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
}
Expand Down Expand Up @@ -638,12 +640,14 @@ const getCollectionJSON = async () => {
const collectionJSONHandle = collectionJSONHandleResult.right
if (collectionJSONHandle.value.type === "invalid") {
const collectionJSONHandleRef = collectionJSONHandle.get()
if (collectionJSONHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return E.left("WORKSPACE_INVALIDATED")
}
return E.right(collectionJSONHandle.value.data.content)
return E.right(collectionJSONHandleRef.value.data.content)
}
return E.left("INVALID_SELECTED_TEAM_OR_INVALID_COLLECTION_TYPE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ const saveRequestAs = async () => {
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED | INVALID_COLLECTION_HANDLE
return
}
Expand Down Expand Up @@ -287,7 +289,9 @@ const saveRequestAs = async () => {
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ import {
import { currentReorderingStatus$ } from "~/newstore/reordering"
import { platform } from "~/platform"
import { NewWorkspaceService } from "~/services/new-workspace"
import { HandleRef } from "~/services/new-workspace/handle"
import { Handle } from "~/services/new-workspace/handle"
import { RESTCollectionViewRequest } from "~/services/new-workspace/view"
import { Workspace } from "~/services/new-workspace/workspace"
import { RESTTabService } from "~/services/tab/rest"
Expand All @@ -539,7 +539,7 @@ const currentUser = useReadonlyStream(
const restCollectionState = useReadonlyStream(restCollections$, [])
const props = defineProps<{
workspaceHandle: HandleRef<Workspace>
workspaceHandle: Handle<Workspace>
picked?: Picked | null
saveRequest?: boolean
}>()
Expand Down Expand Up @@ -751,9 +751,11 @@ const onRemoveRootCollection = async () => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -791,9 +793,11 @@ const onAddRequest = async (requestName: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand All @@ -813,9 +817,11 @@ const onAddRequest = async (requestName: string) => {
return
}
const requestHandle = requestHandleResult.right.get()
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// COLLECTION_INVALIDATED
return
}
Expand Down Expand Up @@ -874,9 +880,11 @@ const onAddChildCollection = async (newChildCollectionName: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -924,9 +932,11 @@ const onEditRootCollection = async (newCollectionName: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -969,9 +979,11 @@ const onEditChildCollection = async (newChildCollectionName: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1010,9 +1022,11 @@ const onRemoveChildCollection = async () => {
return
}
const parentCollectionHandle = parentCollectionHandleResult.right.get()
const parentCollectionHandle = parentCollectionHandleResult.right
const parentCollectionHandleRef = parentCollectionHandle.get()
if (parentCollectionHandle.value.type === "invalid") {
if (parentCollectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1061,9 +1075,11 @@ const onRemoveRequest = async () => {
return
}
const requestHandle = requestHandleResult.right.get()
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// COLLECTION_INVALIDATED
return
}
Expand Down Expand Up @@ -1150,11 +1166,11 @@ const selectRequest = async (requestIndexPath: string) => {
requestHandle,
})
const requestHandleRef = requestHandle.get()
if (possibleTab) {
tabs.setActiveTab(possibleTab.value.id)
} else {
const requestHandleRef = requestHandle.get()
} else if (requestHandleRef.value.type === "ok") {
// If not, open the request in a new tab
tabs.createNewTab({
request: requestHandleRef.value.data.request,
Expand Down Expand Up @@ -1232,9 +1248,11 @@ const onEditRequest = async (newRequestName: string) => {
return
}
const requestHandle = requestHandleResult.right.get()
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// COLLECTION_INVALIDATED
return
}
Expand Down Expand Up @@ -1292,9 +1310,11 @@ const editCollectionProperties = async (collectionIndexPath: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1358,9 +1378,11 @@ const setCollectionProperties = async (updatedCollectionProps: {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1423,9 +1445,11 @@ const exportCollection = async (collectionIndexPath: string) => {
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1522,9 +1546,11 @@ const dropToRoot = async ({ dataTransfer }: DragEvent) => {
return
}
const draggedCollectionHandle = draggedCollectionHandleResult.right.get()
const draggedCollectionHandle = draggedCollectionHandleResult.right
if (draggedCollectionHandle.value.type === "invalid") {
const draggedCollectionHandleRef = draggedCollectionHandle.get()
if (draggedCollectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1560,9 +1586,12 @@ const dropToRoot = async ({ dataTransfer }: DragEvent) => {
}
const destinationRootCollectionHandle =
destinationRootCollectionHandleResult.right.get()
destinationRootCollectionHandleResult.right
const destinationRootCollectionHandleRef =
destinationRootCollectionHandle.get()
if (destinationRootCollectionHandle.value.type === "invalid") {
if (destinationRootCollectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1756,9 +1785,11 @@ const dropCollection = async (payload: {
return
}
const draggedCollectionHandle = draggedCollectionHandleResult.right.get()
const draggedCollectionHandle = draggedCollectionHandleResult.right
const draggedCollectionHandleRef = draggedCollectionHandle.get()
if (draggedCollectionHandle.value.type === "invalid") {
if (draggedCollectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1826,10 +1857,11 @@ const dropCollection = async (payload: {
return
}
const destinationCollectionHandle =
destinationCollectionHandleResult.right.get()
const destinationCollectionHandle = destinationCollectionHandleResult.right
if (destinationCollectionHandle.value.type === "invalid") {
const destinationCollectionHandleRef = destinationCollectionHandle.get()
if (destinationCollectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down Expand Up @@ -1912,9 +1944,11 @@ const updateRequestOrder = async (
return
}
const requestHandle = requestHandleResult.right.get()
const requestHandle = requestHandleResult.right
if (requestHandle.value.type === "invalid") {
const requestHandleRef = requestHandle.get()
if (requestHandleRef.value.type === "invalid") {
// COLLECTION_INVALIDATED
return
}
Expand Down Expand Up @@ -1972,9 +2006,11 @@ const updateCollectionOrder = async (
return
}
const collectionHandle = collectionHandleResult.right.get()
const collectionHandle = collectionHandleResult.right
const collectionHandleRef = collectionHandle.get()
if (collectionHandle.value.type === "invalid") {
if (collectionHandleRef.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
Expand Down

0 comments on commit e878b9a

Please sign in to comment.