profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/bjoerge/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Bjørge Næss bjoerge @sanity-io Oslo, Norway http://sanity.io Frontend engineer @sanity-io

bjoerge/debounce-promise 198

Create a debounced version of a promise returning function

bjoerge/cut-release 107

A tool that helps you make faster npm releases

bjoerge/git-upstream-watch 5

Get notified when one or more local git repos diverge from the upstream tracking branch

bjoerge/airbrake-notice 2

Easy creation of Airbrake (or errbit) error notifications from Node.js or the browser

bjoerge/circular-at 2

Access array items at any positive or negative index. If the index is out of bounds, it will be wrapped around the length of the array

bjoerge/dfrrd.js 2

An ultra-simple Deferred implementation for Node and the browser

bjoerge/blacklistify 1

Protect files from accidental browserify bundling

bjoerge/commonjs.rb 1

Common JS for Ruby

bjoerge/deferred.js 1

A simple Promises/A implementation for Node and the browser

bjoerge/es_attachment_poc 1

Proof of concept indexing attachments (binary and other formats) in elasticsearch using tire

issue closedbjoerge/debounce-promise

then is not a function

Hi @bjoerge,

I have one issue with debounce function, here is what I'm doing

const fakeResponseFunc = ({ status, data}) => {
  return new Promise((resolve, reject) => resolve({ status, data })
};

function expensiveOperation() {
  return Promise.resolve(fakeResponseFunc({
      status: 200,
      data: "something",
    }))
    }

const afterDebounce = debounce(expensiveOperation, 300);

afterDebounce.then(({ data }) => console.log(data))

I'm getting for afterDebounce.then is not a function, I use latest v3.1.2 version this is really basic sample and weird that it doesn't do debounce as desired.

closed time in 13 hours

vaske

issue commentbjoerge/debounce-promise

then is not a function

debounce returns a function, try afterDebounce().then(({ data }) => console.log(data))

vaske

comment created time in 13 hours

PullRequestReviewEvent

push eventsanity-io/sanity

Bjørge Næss

commit sha a40c2853e6dafa53f586f54f75afaf755b345cd4

refactor(default-layout): clean up router typings switching to regular import from @sanity/base/router revealed some inconsistencies with typings. This updates the `navigate` method on the Router typing used internally by default-layout so that it matches the navigate method from the base router.

view details

hermanwikner

commit sha 9f5df36b4b23483c30d462bc520e4e0eaca264ea

refactor(default-layout): use `useDefaultLayout` hook

view details

hermanwikner

commit sha 6447a7efc2eab65de01c61f587f9890aafa7b335

refactor(default-layout): presence ui updates

view details

hermanwikner

commit sha b361f9b39e58fe045810d9a236bb96728c709902

refactor(default-layout): ui fix and rename prop in `Navbar`

view details

hermanwikner

commit sha b5d9e5cc14a85ae339ad7b6c958dc8cb3a8882f1

refactor(default-layout): ui updates in `DefaultLayout`

view details

Marius Lundgård

commit sha 353241b85dfdc074d690d50f8c95b874bbcedf63

build(default-layout): update dependency

view details

push time in 5 days

push eventsanity-io/sanity

Bjørge Næss

commit sha 487ed8570fe591fe5f963cce0244c7e0d288c977

refactor(default-layout): clean up router typings switching to regular import from @sanity/base/router revealed some inconsistencies with typings. This commit removes the `navigate` method on the Router typing used internally by default-layout.

view details

hermanwikner

commit sha 1c810952c30ea92af6de25247555fcc61e4f64c8

refactor(default-layout): use `useDefaultLayout` hook

view details

hermanwikner

commit sha bcb242b3624f49a2cd4666fbabaf948bea807166

refactor(default-layout): presence ui updates

view details

hermanwikner

commit sha 8de981fc6a7530f4eb3a13684075463fea39a105

refactor(default-layout): ui fix and rename prop in `Navbar`

view details

hermanwikner

commit sha 07319320cedf2ecf7512694d4609184d35986805

refactor(default-layout): ui updates in `DefaultLayout`

view details

Marius Lundgård

commit sha d4b723819f309dab40d12c3495a68e3acf5130cf

build(default-layout): update dependency

view details

push time in 5 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventsanity-io/sanity

Bjørge Næss

commit sha 68d87935870fc9870d13ade1442c6780380cd0ef

fixup! refactor(default-layout): clean up router typings

view details

push time in 10 days

push eventsanity-io/sanity

Bjørge Næss

commit sha a92eac9e9e1acd3c35ced391b165b595697c20c2

refactor(state-router): add exports directory

view details

Bjørge Næss

commit sha 86975d9e3d71505eea5f597e404864f50eaf62a4

refactor: replace router part import with package import

view details

hermanwikner

commit sha 27f7fc413fbb6cdbd061d60809e170028e9f8823

chore(default-layout): update dependencies

view details

hermanwikner

commit sha 641df98ff4207034f2b47e8884788a4b84b346e0

refactor(default-layout): migrate `SideMenu` to `@sanity/ui`

view details

hermanwikner

commit sha 3c01ae988a33bb038b7b1de5018a29bbbe2c60d2

refactor(default-layout): migrate `DatasetSelect` to `@sanity/ui`

view details

hermanwikner

commit sha 948657508abd0b6e09579b0542fb16a6698810e0

refactor(default-layout): migrate `LoginStatus` to `@sanity/ui`

view details

hermanwikner

commit sha 73a60345cdd860176f5f8c33532f6d29d5e3791a

refactor(default-layout): migrate `PresenceMenu` + `PresenceMenuItem` to `@sanity/ui`

view details

hermanwikner

commit sha edd169f1734c7d37ea1657006bafb5f5ca3885b1

refactor(default-layout): migrate `ToolMenu` to `@sanity/ui`

view details

hermanwikner

commit sha c2173a0fa63b6bd2a7b04723bac56bcd0958f406

refactor(default-layout): migrate `Navbar` to `@sanity/ui`

view details

hermanwikner

commit sha e130a3e1dc9d00b53daeaa4fe6b2b16735d3acad

refactor(default-layout): migrate `DefaultLayout` to `@sanity/ui`

view details

hermanwikner

commit sha 81ae680fd7daa1ab0153aee240e7fa9bd0b32bcb

refactor(default-layout): migrate search to `@sanity/ui`

view details

hermanwikner

commit sha 60ddad98c3f83fe669766acec69fb91567261c51

fix(default-layout): update file casing

view details

hermanwikner

commit sha b76b131fa23dda263fada54f688a30c2220dab60

refactor(default-layout): migrate `Sidecar` to `@sanity/ui`

view details

hermanwikner

commit sha f9cd361c24e582fbb9c82c89b5c46a22517c8f24

refactor(default-layout): migrate `CreateDocumentDialog` (previous name `ActionDialog`) to `@sanity/ui`

view details

hermanwikner

commit sha 5b1cd591bfab64177d4f57b616e8d5e993a46a70

refactor(default-layout): update `Navbar` layout

view details

Marius Lundgård

commit sha 6aff4c6f6b7aea87b70d2c0fd25fef06e43d94c2

fix(default-layout): add equality check to prevent render loop

view details

Marius Lundgård

commit sha 63d87c3215ad25c6991575c2549d4cf330d5b7cc

fix(state-router): fix equality check

view details

hermanwikner

commit sha d8cd710b5db01fab217b5af51bb9d6cf15f66fd5

refactor(default-layout): add `ToolCollapseMenu` component with updated `CollapseMenu` + `StatusButton`

view details

hermanwikner

commit sha aa49aec3825aa3a43ede8d0317d933864a51f07c

refactor(default-layout): migrate `studioStatus` to `@sanity/ui`

view details

hermanwikner

commit sha 897eda295098a8cb0cadb87e7eedd8ebb0ead6ff

refactor(default-layout): migrate `SchemaErrors` to `@sanity/ui`

view details

push time in 10 days

push eventsanity-io/sanity

Bjørge Næss

commit sha a92eac9e9e1acd3c35ced391b165b595697c20c2

refactor(state-router): add exports directory

view details

Bjørge Næss

commit sha 86975d9e3d71505eea5f597e404864f50eaf62a4

refactor: replace router part import with package import

view details

push time in 11 days

delete branch sanity-io/sanity

delete branch : refactor/replace-router-part-with-import

delete time in 11 days

PR merged sanity-io/sanity

Refactor/replace router part with regular import

Description

This adds the @sanity/base/router export and replaces internal usage of part:@sanity/base/router with it. This lets us not having to maintain a separate dependency to @sanity/state-router for studio packages that needs routing, and minimises the risk of consuming duplicate versions.

What to review

Check that the code looks sane, that studio routing still works

Notes for release

N/A. This is an internal refactoring.

+85 -59

1 comment

38 changed files

bjoerge

pr closed time in 11 days

push eventsanity-io/sanity

Bjørge Næss

commit sha bd7ecaa1ea6b87d02120850c1a7ba106a808f3ce

refactor: replace router part import with package import

view details

push time in 11 days

push eventsanity-io/sanity

Bjørge Næss

commit sha c83f24f48c6114d5690bb7891e53efb7d96e33ba

refactor: replace router part import with package import

view details

push time in 11 days

push eventsanity-io/sanity

Fred Carlsen

commit sha cec11e6b4fae3680bf9c91f5589adf45b39f4724

fix(base): fix image overflowing container in default preview

view details

Espen Hovlandsdal

commit sha dd6061018f045ac8bb62bf3c03e43c85a18a1b1e

v2.19.4

view details

Marius Lundgård

commit sha 999452d737f213123d714f3b0f5c2fb333d864e6

build: remove unused dependency

view details

Marius Lundgård

commit sha 1b2634e3b2d1cd23a60d7b91913ba120ac90e214

chore(workshop): improve client mock

view details

Marius Lundgård

commit sha 7ba459e379001d4dcd7e34656585b6976ff3fab3

test(base): add `UserAvatar` workshop

view details

Marius Lundgård

commit sha 5c5395134b0b1f7345c27de21b597c1f56847807

test(base): update `UserAvatar` workshop

view details

Marius Lundgård

commit sha 723b281112f4031a811d52b21802441ebfa4de04

chore: upgrade `@sanity/ui-workshop`

view details

Espen Hovlandsdal

commit sha bb5a7338702bf8c4ef1c4e18a69fe4e3bf5e0d73

chore: require node 12 (#2770)

view details

Marius Lundgård

commit sha e78d9eaa15deb33d0fdd7666d673e3d59af10bbe

chore(workshop): improve client mock

view details

Marius Lundgård

commit sha 00f66654e8e2a63cd6c113063bcbd33688dd9370

refactor(studio-hints): improve toggle button

view details

Marius Lundgård

commit sha 6c4dc57fbb3002f498adbb09eec8333491685bd6

fix(imagetool): add guard

view details

Marius Lundgård

commit sha e82d14f58e87b3d46b9d76345578a0d3aa4a327a

fix(base): export all names

view details

Marius Lundgård

commit sha d6cf8ebf43f8baf569213680055e943b4381c48c

feat(base): support `shortcut` property on legacy menu items

view details

Marius Lundgård

commit sha 511556b488c0f416e4411770a8de323c73be54ea

refactor(base): improve `MenuItem` typing

view details

Marius Lundgård

commit sha e27777d9c9556f7d75629229b48d5ff48db2f372

chore(base): add release tag

view details

Marius Lundgård

commit sha 84948a375c2ec68fdc4f918d005b1c053aea6071

refactor(base): improve types of presence components

view details

Marius Lundgård

commit sha 5b2754152dc9a852f3aeebf891375df1b82ce961

test(base): add workshop for `FormField`

view details

Marius Lundgård

commit sha a3bd5833db3b5acac285414b825b8d8489dd8d8c

refactor(base): improve types for legacy `DefaultButton`

view details

Marius Lundgård

commit sha d3e062ed2a9877b4e1f28feb48185339bbbaf804

fix(base): fix type export

view details

Marius Lundgård

commit sha 3360520df4eda8aa2aa3ab5b1ea398770b645c65

test(base): add workshop for change indicators

view details

push time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

 export const defaults: ZIndexContextValue = {   navbar: 200,   navbarPopover: 500000,   navbarDialog: 500001,++  // pane   pane: 100,   paneHeader: [110, 15000],   paneFooter: [120, 20000],-  paneResizer: 150,-  portal: 200,+  paneResizer: [130, 25000],++  //   popover: 200,   modal: 200,   movingItem: 10000,   drawershade: 1000000,   drawer: 1000001,   fullscreen: 1200000,-  toast: 11000,+  toast: [100, 11000],    // NOT IN USE

…so why is it still here? ;)

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+import {ChevronDownIcon, PublishIcon} from '@sanity/icons'+import {Button, Flex, Menu, MenuButton, MenuItem, Stack, useToast} from '@sanity/ui'+import React, {useCallback} from 'react'++export function DocumentActions() {+  const {push: pushToast} = useToast()++  const publish = useCallback(+    () => pushToast({status: 'success', title: 'Successfully published'}),+    [pushToast]+  )++  return (+    <Flex gap={1}>+      <Stack flex={1}>+        <Button icon={PublishIcon} onClick={publish} text="Publish" tone="positive" />+      </Stack>+      <MenuButton+        button={<Button icon={ChevronDownIcon} mode="ghost" />}+        id="actions"+        menu={+          <Menu>+            <MenuItem text="Discard changes" />+          </Menu>+        }+        popover={{constrainSize: true, portal: true}}

put this in a const?

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+import {useRef} from 'react'+import shallowEquals from 'shallow-equals'++export function useShallowUnique<ValueType>(value: ValueType): ValueType {

would be great with a comment describing the purpose and an outline of what use case(s) this solves

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

 import {LOADING_PANE} from '../constants' import {StructureError} from './StructureError'  export interface IntentResolverProps {+  intent: any

should be string?

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+export function raf(fn: () => void): () => void {+  const frameId = requestAnimationFrame(fn)++  return () => {+    cancelAnimationFrame(frameId)+  }+}++export function raf2(fn: () => void): () => void {

would be good to have a comment describing the purpose of this

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

 describe('@sanity/default-layout: Navbar', () => {       '500401'     ) -    cy.get(-      '[data-testid="desk-tool-list-pane"] [data-test="components-default-pane-header"]'-    ).should('have.css', 'z-index', '101')+    cy.get('[data-testid="desk-tool-list-pane"] [data-ui="PaneHeader"]').should(

would it be better to replace [data-ui="PaneHeader"] with a data-testid for it instead?

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+import {isEqual} from 'lodash'+import {useRef} from 'react'++export function useUnique<ValueType>(value: ValueType): ValueType {

could a better name for this be useDeepUnique to better reflect that it does a (potentially expensive) deep comparison on every render? I guess it's also worth adding a note about when not to use - I can easily imagine cases where rendering is cheap and using this will actually degrade performance.

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

 type ChildLinkProps = {   children?: React.ReactNode } -const ChildLink = React.forwardRef(function ChildLink(props: ChildLinkProps, ref: React.Ref<any>) {+const ChildLink = React.forwardRef(function ChildLink(+  props: ChildLinkProps,+  ref: React.Ref<typeof StateLink>

realizing it's not introduced in this commit, but the correct type of forwarded refs are React.ForwardedRef<...>

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+// @todo: remove the following line when part imports has been removed from this file+///<reference types="@sanity/types/parts" />++import {WarningOutlineIcon} from '@sanity/icons'+import {SanityDocument} from '@sanity/types'+import {assignWith} from 'lodash'+import {observeForPreview} from 'part:@sanity/base/preview'+import {getDraftId, getPublishedId} from 'part:@sanity/base/util/draft-utils'+import React from 'react'+import {combineLatest, Observable, of} from 'rxjs'+import {map, startWith} from 'rxjs/operators'+import {PreviewValue} from '../../types'+import {DraftStatus} from '../DraftStatus'+import {NotPublishedStatus} from '../NotPublishedStatus'+import {PaneItemPreviewState} from './types'++export const isLiveEditEnabled = (schemaType: any) => schemaType.liveEdit === true++export const getStatusIndicator = (+  draft?: SanityDocument | null,+  published?: SanityDocument | null+) => {+  if (draft) {+    return DraftStatus+  }++  return published ? null : NotPublishedStatus+}++export const getMissingDocumentFallback = (item: SanityDocument): PreviewValue => ({+  title: (+    <span style={{fontStyle: 'italic'}}>+      {item.title ? String(item.title) : 'Missing document'}+    </span>+  ),+  subtitle: (+    <span style={{fontStyle: 'italic'}}>+      {item.title ? `Missing document ID: ${item._id}` : `Document ID: ${item._id}`}+    </span>+  ),+  media: WarningOutlineIcon,+})++export const getValueWithFallback = ({+  value,+  draft,+  published,+}: {+  value: SanityDocument+  draft?: SanityDocument | null+  published?: SanityDocument | null+}): PreviewValue | SanityDocument => {+  const snapshot = draft || published++  if (!snapshot) {+    return getMissingDocumentFallback(value)+  }++  return assignWith({}, snapshot, value, (objValue, srcValue) => {+    return typeof srcValue === 'undefined' ? objValue : srcValue+  })+}++export function getPreviewState$(

don't think we usually suffix observable returning functions with $, so feel free to remove it

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+import {StructureBuilder} from '@sanity/structure'

This shouldn't be necessary now with the typesVersions field in package.json?

mariuslundgard

comment created time in 11 days

PullRequestReviewEvent

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+// @todo: remove the following line when part imports has been removed from this file+///<reference types="@sanity/types/parts" />+ import {SanityDocument} from '@sanity/types' import React from 'react' import schema from 'part:@sanity/base/schema' import {PreviewFields} from 'part:@sanity/base/preview'  export interface DocTitleProps {-  document: SanityDocument+  document: Partial<SanityDocument>

this isn't accurate since _type is required by this component (ref the non-null assertion)

mariuslundgard

comment created time in 11 days

PullRequestReviewEvent

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

-export function DraftStatusBadge(props) {+import {DocumentBadgeComponent} from '@sanity/base'++export const DraftStatusBadge: DocumentBadgeComponent = (props) => {

Nice!

mariuslundgard

comment created time in 11 days

Pull request review commentsanity-io/sanity

feat(desk-tool): new pane building block components + migrate desk-tool to `@sanity/ui`

+import {Rect} from '../overlay/types' import {hasOverflowScroll} from './scrollUtils' -const getOffsetsTo = (source: HTMLElement, target: HTMLElement) => {-  let el: HTMLElement | null = source+export const getOffsetsTo = (+  source: HTMLElement,+  target: HTMLElement+): {rect: Rect; bounds: Rect} => {+  const bounds: Rect = {+    top: 0,+    left: 0,+    height: target.offsetHeight, // Number.MAX_SAFE_INTEGER,

was it intentional to leave the comments here?

mariuslundgard

comment created time in 19 days