Skip to content

Commit

Permalink
Merge pull request #1461 from ecency/bugfix/app-crash
Browse files Browse the repository at this point in the history
Bugfix/app crash
  • Loading branch information
feruzm authored Sep 10, 2023
2 parents 09698b0 + 2709f65 commit 9967acf
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/common/api/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface MetaData {
community?: string;
description?: string;
video?: any;
type?: string;
}

export interface BeneficiaryRoute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ exports[`(1) Default render 1`] = `
</div>
<div
className="editor-tool"
id="editor-tool-emoji-picker"
role="none"
title="Emoji"
>
Expand Down Expand Up @@ -544,6 +545,7 @@ exports[`(2) Cancellable, in progress 1`] = `
</div>
<div
className="editor-tool"
id="editor-tool-emoji-picker"
role="none"
title="Emoji"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ exports[`(1) Full render with active user 1`] = `
dangerouslySetInnerHTML={
Object {
"__html": "<p><span><a class=\\"markdown-author-link\\" href=\\"/@esteemapp\\">@esteemapp</a></span><br />
Bug report <a href=\\"/esteem/@iliyan90/bug-report-to-esteemapp\\" class=\\"markdown-post-link\\">click here</a></p>",
Bug report <a href=\\"https://esteem.app/esteem/@iliyan90/bug-report-to-esteemapp\\" class=\\"markdown-external-link\\" target=\\"_blank\\" rel=\\"noopener\\">click here</a></p>",
}
}
/>
Expand Down Expand Up @@ -2696,7 +2696,7 @@ exports[`(3) With selected item 1`] = `
dangerouslySetInnerHTML={
Object {
"__html": "<p><span><a class=\\"markdown-author-link\\" href=\\"/@esteemapp\\">@esteemapp</a></span><br />
Bug report <a href=\\"/esteem/@iliyan90/bug-report-to-esteemapp\\" class=\\"markdown-post-link\\">click here</a></p>",
Bug report <a href=\\"https://esteem.app/esteem/@iliyan90/bug-report-to-esteemapp\\" class=\\"markdown-external-link\\" target=\\"_blank\\" rel=\\"noopener\\">click here</a></p>",
}
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/entry-menu/menu-items-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function useMenuItemsGenerator(
useEffect(() => {
setCanMute(
activeUser && community
? !!community.team.find(
? !!community.team?.find(
(m) =>
m[0] === activeUser.username &&
[ROLES.OWNER.toString(), ROLES.ADMIN.toString(), ROLES.MOD.toString()].includes(m[1])
Expand Down Expand Up @@ -216,7 +216,7 @@ export function useMenuItemsGenerator(

const isTeamManager = () =>
activeUser && community
? !!community.team.find((m) => {
? !!community.team?.find((m) => {
return (
m[0] === activeUser.username &&
[ROLES.OWNER.toString(), ROLES.ADMIN.toString(), ROLES.MOD.toString()].includes(m[1])
Expand Down
9 changes: 6 additions & 3 deletions src/common/components/video-upload-threespeak/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createFile } from "../../util/create-file";
import { useMappedStore } from "../../store/use-mapped-store";
import { recordVideoSvg } from "../../img/svg";
import { VideoUploadRecorder } from "./video-upload-recorder";
import useMountedState from "react-use/lib/useMountedState";

const DEFAULT_THUMBNAIL = require("./assets/thumbnail-play.jpg");

Expand Down Expand Up @@ -48,6 +49,8 @@ export const VideoUpload = (props: Props & React.HTMLAttributes<HTMLDivElement>)

const canUpload = videoUrl;

const isMounted = useMountedState();

// Reset on dialog hide
useEffect(() => {
if (!props.show) {
Expand Down Expand Up @@ -124,7 +127,7 @@ export const VideoUpload = (props: Props & React.HTMLAttributes<HTMLDivElement>)
/>
) : (
<div className="video-source">
{!selectedFile && "MediaRecorder" in window ? (
{isMounted() && !selectedFile && "MediaRecorder" in window ? (
<div
className="d-flex align-items-center flex-column border rounded p-3 video-upload-item"
onClick={() => setShowRecorder(true)}
Expand All @@ -139,7 +142,7 @@ export const VideoUpload = (props: Props & React.HTMLAttributes<HTMLDivElement>)
label={_t("video-upload.choose-video")}
onFileChange={handleVideoChange}
type="video"
accept="video/*"
accept="video/mp4, video/webm"
completed={videoPercentage}
/>
</div>
Expand All @@ -149,7 +152,7 @@ export const VideoUpload = (props: Props & React.HTMLAttributes<HTMLDivElement>)
label={_t("video-upload.choose-thumbnail")}
onFileChange={handleThumbnailChange}
type="thumbnail"
accept="image/*"
accept="image/jpg, image/jpeg, image/png"
completed={thumbnailPercentage}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProgressBar } from "react-bootstrap";
interface Props {
onFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
type: "video" | "thumbnail";
accept: "video/*" | "image/*";
accept: string;
label: string;
completed: number;
}
Expand Down
5 changes: 2 additions & 3 deletions src/common/helper/posting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import getSlug from "speakingurl";

import { diff_match_patch } from "diff-match-patch";

import { MetaData, CommentOptions, RewardType } from "../api/operations";
import { BeneficiaryRoute, CommentOptions, MetaData, RewardType } from "../api/operations";

import isElectron from "../util/is-electron";

import { BeneficiaryRoute } from "../api/operations";

const permlinkRnd = () => (Math.random() + 1).toString(16).substring(2);

export const createPermlink = (title: string, random: boolean = false): string => {
Expand Down Expand Up @@ -95,6 +93,7 @@ export const makeCommentOptions = (
): CommentOptions => {
beneficiaries?.forEach((b) => delete b.src);

beneficiaries?.sort();
const opt: CommentOptions = {
allow_curation_rewards: true,
allow_votes: true,
Expand Down
3 changes: 1 addition & 2 deletions src/common/pages/community-functional.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { pageMapDispatchToProps, pageMapStateToProps, PageProps } from "./common
import { match } from "react-router";
import React, { Fragment, useEffect, useState } from "react";
import { search as searchApi, SearchResult } from "../api/search-api";
import { getCommunity, getSubscriptions } from "../api/bridge";
import { getSubscriptions } from "../api/bridge";
import { EntryFilter, ListStyle } from "../store/global/types";
import { usePrevious } from "../util/use-previous";
import { makeGroupKey } from "../store/entries";
Expand All @@ -22,7 +22,6 @@ import _c from "../util/fix-class-names";
import EntryListLoadingItem from "../components/entry-list-loading-item";
import DetectBottom from "../components/detect-bottom";
import capitalize from "../util/capitalize";
import { Community } from "../store/communities/types";
import { Account } from "../store/accounts/types";
import { CommunityMenu } from "../components/community-menu";
import { CommunityCover } from "../components/community-cover";
Expand Down
4 changes: 4 additions & 0 deletions src/common/pages/submit/api/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export function usePublishApi(history: History, onClear: () => void) {
permlink = speakPermlink;
// update speak video with title, body and tags
await updateSpeakVideoInfo(activeUser.username, body, videoId, title, tags, isNsfw);

// set specific metadata for 3speak
jsonMeta.app = "3speak/0.3.0";
jsonMeta.type = "video";
}

const options = makeCommentOptions(author, permlink, reward, beneficiaries);
Expand Down

0 comments on commit 9967acf

Please sign in to comment.