Skip to content

Commit

Permalink
feat(owner): add owner id on create
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Apr 24, 2020
1 parent 8bb63b7 commit 5442c42
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import MinimizedView from './views/Minimized';
import UserListView from './views/UserList';

onmessage = (message) => {
console.log(message.data.pluginMessage);
if (message.data.pluginMessage) {
const { type, payload } = message.data.pluginMessage;

Expand Down
14 changes: 10 additions & 4 deletions src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ async function main() {
let history = figma.root.getPluginData('history');
let roomName = figma.root.getPluginData('roomName');
let secret = figma.root.getPluginData('secret');
let ownerId = figma.root.getPluginData('ownerId');

if (!instanceId) {
instanceId = 'user-' + uniqid() + '-' + generateString(15);
await figma.clientStorage.setAsync('id', instanceId);
}

if(!roomName && !secret) {
figma.root.setPluginData('ownerId', instanceId);
}

if (!roomName) {
let randomRoomName = uniqid() + '-' + generateString(15);
Expand All @@ -42,10 +52,6 @@ async function main() {
figma.root.setPluginData('history', history);
}

if (!instanceId) {
instanceId = 'user-' + uniqid() + '-' + generateString(15);
await figma.clientStorage.setAsync('id', instanceId);
}



Expand Down
2 changes: 1 addition & 1 deletion src/components/Chatbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const ChatBarForm = styled.form`
`;

const SelectionCheckbox = styled.div`
position: fixed;
position: absolute;
right: 0;
top: 0;
animation-delay: 0.4s;
Expand Down
10 changes: 6 additions & 4 deletions src/views/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const ChatView: FunctionComponent<ChatProps> = (props) => {
)}

<Chat hasSelection={state.selection.length > 0}>
<FloatingButtonRight>
<FloatingButtonRight isSettings={isSettings}>
<Online onClick={() => history.push('/user-list')}>
{state.online.length}
</Online>
Expand Down Expand Up @@ -245,11 +245,13 @@ const ChatView: FunctionComponent<ChatProps> = (props) => {
const FloatingButtonRight = styled.div`
position: fixed;
z-index: 9;
right: 20px;
top: 20px;
right: 10px;
top: 10px;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
border-radius: 5px;
transition: transform 0.5s;
transform: translate(${({ isSettings }) => (isSettings ? 150 : 0)}px);
`;

const SettingsArrow = styled.div`
Expand Down Expand Up @@ -300,7 +302,7 @@ const Messages = styled.div`
background-color: #fff;
border-radius: 0 0 15px 15px;
transition: height 0.4s;
height: ${({ isSettings }) => (isSettings ? 70 : 371)}px;
height: ${({ isSettings }) => (isSettings ? 50 : 371)}px;
`;

const Online = styled.div`
Expand Down

0 comments on commit 5442c42

Please sign in to comment.