cleanup width / height

This commit is contained in:
Aaron Gutierrez
2022-01-19 19:03:26 -07:00
parent d96d63da8e
commit 9538523723
2 changed files with 23 additions and 24 deletions

24
pub.py
View File

@@ -5,6 +5,7 @@ import hashlib
import os
import subprocess
import sys
from functools import cache
import boto3
@@ -37,18 +38,25 @@ def cache_length(ext):
else:
return '31536000'
@cache
def current_keys():
print('Fetching existing keys in {}'.format(BUCKET))
existing = s3.list_objects_v2(Bucket=BUCKET)
keys = set([content['Key'] for content in existing['Contents']])
while existing['IsTruncated']:
existing = s3.list_objects_v2(Bucket=BUCKET, ContinuationToken=existing['NextContinuationToken'])
keys = keys.union(set([content['Key'] for content in existing['Contents']]))
return keys
def upload_file(filename, overwrite=True):
print('Uploading {} to {}/{}'.format(filename, BUCKET, filename))
ext = filename.split('.')[-1]
if not overwrite:
try:
existing = s3.get_object(Bucket=BUCKET, Key=filename)
print('\tSkipping existing key ', filename)
return
except:
pass
if not overwrite and filename in current_keys():
print('Skipping existing key {}'.format(filename))
return
print('Uploading {} to {}/{}'.format(filename, BUCKET, filename))
s3.upload_file(filename, BUCKET, filename, ExtraArgs={
'ACL': 'public-read',
'ContentType': TYPE_MAP[ext],

View File

@@ -21,33 +21,24 @@ export class Root extends React.PureComponent<Props, State> {
// innerWidth gets messed up when rotating phones from landscape -> portrait,
// and chrome seems to not report innerWidth correctly when scrollbars are present
private _viewWidth = (): number => {
// iOS Safari does not set outerWidth/outerHeight
if (!window.outerWidth) {
return window.innerWidth;
}
return Math.min(
window.innerWidth,
window.outerWidth,
document.getElementById("mount")!.clientWidth
window.outerWidth || Infinity,
document.getElementById("mount")!.clientWidth || Infinity
);
};
private _viewHeight = (): number => {
// iOS Safari does not set outerWidth/outerHeight
if (!window.outerHeight) {
return window.innerHeight;
}
private _viewHeight = (): number => {
return Math.min(
window.innerHeight,
window.outerHeight,
document.body.clientHeight
window.outerHeight || Infinity,
document.body.clientHeight || Infinity
);
};
state: State = {
gridHeights: [],
pageBottom: window.innerHeight + window.pageYOffset,
pageBottom: this._viewHeight() + window.pageYOffset,
width: this._viewWidth(),
height: this._viewHeight()
};
@@ -123,7 +114,7 @@ export class Root extends React.PureComponent<Props, State> {
private _onViewChange = () => {
this.setState({
pageBottom: window.innerHeight + window.pageYOffset,
pageBottom: this._viewHeight() + window.pageYOffset,
width: this._viewWidth(),
height: this._viewHeight(),
});